Commit cd02d3b7 authored by tzik's avatar tzik Committed by Commit Bot

Use OnceCallback on Mojo interfaces in //chrome/common

This CL flips `use_once_callback` flag on the Mojo code generator for
//chrome/common, and fixes all compile errors after that. After
this CL, Mojo interfaces there service starts using base::OnceCallback
instead of base::Callback on its return value handling.

Bug: 714018
Change-Id: I70823c7a0ca0032fa3223e2a2926d37acc8f6523
Reviewed-on: https://chromium-review.googlesource.com/1152342Reviewed-by: default avatarAlexandr Ilin <alexilin@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581897}
parent 904ad03c
...@@ -77,39 +77,36 @@ bool NetBenchmarking::CheckBenchmarkingEnabled() { ...@@ -77,39 +77,36 @@ bool NetBenchmarking::CheckBenchmarkingEnabled() {
return command_line.HasSwitch(switches::kEnableNetBenchmarking); return command_line.HasSwitch(switches::kEnableNetBenchmarking);
} }
void NetBenchmarking::ClearCache(const ClearCacheCallback& callback) { void NetBenchmarking::ClearCache(ClearCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_); auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) { CHECK(network_context);
network_context->ClearHttpCache(base::Time(), base::Time(), nullptr, network_context->ClearHttpCache(base::Time(), base::Time(), nullptr,
callback); std::move(callback));
}
} }
void NetBenchmarking::ClearHostResolverCache( void NetBenchmarking::ClearHostResolverCache(
const ClearHostResolverCacheCallback& callback) { ClearHostResolverCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_); auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) { CHECK(network_context);
network_context->ClearHostCache(nullptr, callback); network_context->ClearHostCache(nullptr, std::move(callback));
}
} }
void NetBenchmarking::CloseCurrentConnections( void NetBenchmarking::CloseCurrentConnections(
const CloseCurrentConnectionsCallback& callback) { CloseCurrentConnectionsCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_); auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) { CHECK(network_context);
network_context->CloseAllConnections(callback); network_context->CloseAllConnections(std::move(callback));
}
} }
void NetBenchmarking::ClearPredictorCache( void NetBenchmarking::ClearPredictorCache(
const ClearPredictorCacheCallback& callback) { ClearPredictorCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (loading_predictor_) if (loading_predictor_)
loading_predictor_->resource_prefetch_predictor()->DeleteAllUrls(); loading_predictor_->resource_prefetch_predictor()->DeleteAllUrls();
if (predictor_) if (predictor_)
predictor_->DiscardAllResultsAndClearPrefsOnUIThread(); predictor_->DiscardAllResultsAndClearPrefsOnUIThread();
callback.Run(); std::move(callback).Run();
} }
...@@ -42,12 +42,10 @@ class NetBenchmarking : public chrome::mojom::NetBenchmarking { ...@@ -42,12 +42,10 @@ class NetBenchmarking : public chrome::mojom::NetBenchmarking {
private: private:
// chrome:mojom:NetBenchmarking. // chrome:mojom:NetBenchmarking.
void CloseCurrentConnections( void CloseCurrentConnections(
const CloseCurrentConnectionsCallback& callback) override; CloseCurrentConnectionsCallback callback) override;
void ClearCache(const ClearCacheCallback& callback) override; void ClearCache(ClearCacheCallback callback) override;
void ClearHostResolverCache( void ClearHostResolverCache(ClearHostResolverCacheCallback callback) override;
const ClearHostResolverCacheCallback& callback) override; void ClearPredictorCache(ClearPredictorCacheCallback callback) override;
void ClearPredictorCache(
const ClearPredictorCacheCallback& callback) override;
// These weak pointers should be dereferenced only on the UI thread. // These weak pointers should be dereferenced only on the UI thread.
base::WeakPtr<predictors::LoadingPredictor> loading_predictor_; base::WeakPtr<predictors::LoadingPredictor> loading_predictor_;
......
...@@ -209,7 +209,7 @@ void PluginInfoHostImpl::GetPluginInfo(int32_t render_frame_id, ...@@ -209,7 +209,7 @@ void PluginInfoHostImpl::GetPluginInfo(int32_t render_frame_id,
const GURL& url, const GURL& url,
const url::Origin& origin, const url::Origin& origin,
const std::string& mime_type, const std::string& mime_type,
const GetPluginInfoCallback& callback) { GetPluginInfoCallback callback) {
GetPluginInfo_Params params = {render_frame_id, url, origin, mime_type}; GetPluginInfo_Params params = {render_frame_id, url, origin, mime_type};
PluginService::GetInstance()->GetPlugins(base::BindOnce( PluginService::GetInstance()->GetPlugins(base::BindOnce(
&PluginInfoHostImpl::PluginsLoaded, this, params, std::move(callback))); &PluginInfoHostImpl::PluginsLoaded, this, params, std::move(callback)));
......
...@@ -135,7 +135,7 @@ class PluginInfoHostImpl ...@@ -135,7 +135,7 @@ class PluginInfoHostImpl
const GURL& url, const GURL& url,
const url::Origin& origin, const url::Origin& origin,
const std::string& mime_type, const std::string& mime_type,
const GetPluginInfoCallback& callback) override; GetPluginInfoCallback callback) override;
// |params| wraps the parameters passed to |OnGetPluginInfo|, because // |params| wraps the parameters passed to |OnGetPluginInfo|, because
// |base::Bind| doesn't support the required arity <http://crbug.com/98542>. // |base::Bind| doesn't support the required arity <http://crbug.com/98542>.
......
...@@ -58,9 +58,8 @@ class FakeChromeRenderFrame ...@@ -58,9 +58,8 @@ class FakeChromeRenderFrame
mojo::AssociatedInterfaceRequest<ChromeRenderFrame>(std::move(handle))); mojo::AssociatedInterfaceRequest<ChromeRenderFrame>(std::move(handle)));
} }
void GetWebApplicationInfo( void GetWebApplicationInfo(GetWebApplicationInfoCallback callback) override {
const GetWebApplicationInfoCallback& callback) override { std::move(callback).Run(web_app_info_);
callback.Run(web_app_info_);
} }
private: private:
......
...@@ -719,9 +719,6 @@ mojom("mojo_bindings") { ...@@ -719,9 +719,6 @@ mojom("mojo_bindings") {
] ]
component_deps = [ "//content/public/common" ] component_deps = [ "//content/public/common" ]
# TODO(crbug.com/714018): Convert the implementation to use OnceCallback.
use_once_callback = false
} }
mojom("search_mojom") { mojom("search_mojom") {
......
...@@ -223,7 +223,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode( ...@@ -223,7 +223,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode(
int32_t thumbnail_min_area_pixels, int32_t thumbnail_min_area_pixels,
const gfx::Size& thumbnail_max_size_pixels, const gfx::Size& thumbnail_max_size_pixels,
chrome::mojom::ImageFormat image_format, chrome::mojom::ImageFormat image_format,
const RequestThumbnailForContextNodeCallback& callback) { RequestThumbnailForContextNodeCallback callback) {
WebNode context_node = render_frame()->GetWebFrame()->ContextMenuNode(); WebNode context_node = render_frame()->GetWebFrame()->ContextMenuNode();
SkBitmap thumbnail; SkBitmap thumbnail;
gfx::Size original_size; gfx::Size original_size;
...@@ -261,7 +261,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode( ...@@ -261,7 +261,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode(
thumbnail_data.swap(data); thumbnail_data.swap(data);
break; break;
} }
callback.Run(thumbnail_data, original_size); std::move(callback).Run(thumbnail_data, original_size);
} }
void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
...@@ -274,7 +274,7 @@ void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { ...@@ -274,7 +274,7 @@ void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
} }
void ChromeRenderFrameObserver::GetWebApplicationInfo( void ChromeRenderFrameObserver::GetWebApplicationInfo(
const GetWebApplicationInfoCallback& callback) { GetWebApplicationInfoCallback callback) {
WebLocalFrame* frame = render_frame()->GetWebFrame(); WebLocalFrame* frame = render_frame()->GetWebFrame();
WebApplicationInfo web_app_info; WebApplicationInfo web_app_info;
......
...@@ -79,11 +79,10 @@ class ChromeRenderFrameObserver : public content::RenderFrameObserver, ...@@ -79,11 +79,10 @@ class ChromeRenderFrameObserver : public content::RenderFrameObserver,
int32_t thumbnail_min_area_pixels, int32_t thumbnail_min_area_pixels,
const gfx::Size& thumbnail_max_size_pixels, const gfx::Size& thumbnail_max_size_pixels,
chrome::mojom::ImageFormat image_format, chrome::mojom::ImageFormat image_format,
const RequestThumbnailForContextNodeCallback& callback) override; RequestThumbnailForContextNodeCallback callback) override;
void RequestReloadImageForContextNode() override; void RequestReloadImageForContextNode() override;
void SetClientSidePhishingDetection(bool enable_phishing_detection) override; void SetClientSidePhishingDetection(bool enable_phishing_detection) override;
void GetWebApplicationInfo( void GetWebApplicationInfo(GetWebApplicationInfoCallback callback) override;
const GetWebApplicationInfoCallback& callback) override;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void UpdateBrowserControlsState(content::BrowserControlsState constraints, void UpdateBrowserControlsState(content::BrowserControlsState constraints,
content::BrowserControlsState current, content::BrowserControlsState current,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment