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() {
return command_line.HasSwitch(switches::kEnableNetBenchmarking);
}
void NetBenchmarking::ClearCache(const ClearCacheCallback& callback) {
void NetBenchmarking::ClearCache(ClearCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) {
network_context->ClearHttpCache(base::Time(), base::Time(), nullptr,
callback);
}
CHECK(network_context);
network_context->ClearHttpCache(base::Time(), base::Time(), nullptr,
std::move(callback));
}
void NetBenchmarking::ClearHostResolverCache(
const ClearHostResolverCacheCallback& callback) {
ClearHostResolverCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) {
network_context->ClearHostCache(nullptr, callback);
}
CHECK(network_context);
network_context->ClearHostCache(nullptr, std::move(callback));
}
void NetBenchmarking::CloseCurrentConnections(
const CloseCurrentConnectionsCallback& callback) {
CloseCurrentConnectionsCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* network_context = GetNetworkContext(render_process_id_);
if (network_context) {
network_context->CloseAllConnections(callback);
}
CHECK(network_context);
network_context->CloseAllConnections(std::move(callback));
}
void NetBenchmarking::ClearPredictorCache(
const ClearPredictorCacheCallback& callback) {
ClearPredictorCacheCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (loading_predictor_)
loading_predictor_->resource_prefetch_predictor()->DeleteAllUrls();
if (predictor_)
predictor_->DiscardAllResultsAndClearPrefsOnUIThread();
callback.Run();
std::move(callback).Run();
}
......@@ -42,12 +42,10 @@ class NetBenchmarking : public chrome::mojom::NetBenchmarking {
private:
// chrome:mojom:NetBenchmarking.
void CloseCurrentConnections(
const CloseCurrentConnectionsCallback& callback) override;
void ClearCache(const ClearCacheCallback& callback) override;
void ClearHostResolverCache(
const ClearHostResolverCacheCallback& callback) override;
void ClearPredictorCache(
const ClearPredictorCacheCallback& callback) override;
CloseCurrentConnectionsCallback callback) override;
void ClearCache(ClearCacheCallback callback) override;
void ClearHostResolverCache(ClearHostResolverCacheCallback callback) override;
void ClearPredictorCache(ClearPredictorCacheCallback callback) override;
// These weak pointers should be dereferenced only on the UI thread.
base::WeakPtr<predictors::LoadingPredictor> loading_predictor_;
......
......@@ -209,7 +209,7 @@ void PluginInfoHostImpl::GetPluginInfo(int32_t render_frame_id,
const GURL& url,
const url::Origin& origin,
const std::string& mime_type,
const GetPluginInfoCallback& callback) {
GetPluginInfoCallback callback) {
GetPluginInfo_Params params = {render_frame_id, url, origin, mime_type};
PluginService::GetInstance()->GetPlugins(base::BindOnce(
&PluginInfoHostImpl::PluginsLoaded, this, params, std::move(callback)));
......
......@@ -135,7 +135,7 @@ class PluginInfoHostImpl
const GURL& url,
const url::Origin& origin,
const std::string& mime_type,
const GetPluginInfoCallback& callback) override;
GetPluginInfoCallback callback) override;
// |params| wraps the parameters passed to |OnGetPluginInfo|, because
// |base::Bind| doesn't support the required arity <http://crbug.com/98542>.
......
......@@ -58,9 +58,8 @@ class FakeChromeRenderFrame
mojo::AssociatedInterfaceRequest<ChromeRenderFrame>(std::move(handle)));
}
void GetWebApplicationInfo(
const GetWebApplicationInfoCallback& callback) override {
callback.Run(web_app_info_);
void GetWebApplicationInfo(GetWebApplicationInfoCallback callback) override {
std::move(callback).Run(web_app_info_);
}
private:
......
......@@ -719,9 +719,6 @@ mojom("mojo_bindings") {
]
component_deps = [ "//content/public/common" ]
# TODO(crbug.com/714018): Convert the implementation to use OnceCallback.
use_once_callback = false
}
mojom("search_mojom") {
......
......@@ -223,7 +223,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode(
int32_t thumbnail_min_area_pixels,
const gfx::Size& thumbnail_max_size_pixels,
chrome::mojom::ImageFormat image_format,
const RequestThumbnailForContextNodeCallback& callback) {
RequestThumbnailForContextNodeCallback callback) {
WebNode context_node = render_frame()->GetWebFrame()->ContextMenuNode();
SkBitmap thumbnail;
gfx::Size original_size;
......@@ -261,7 +261,7 @@ void ChromeRenderFrameObserver::RequestThumbnailForContextNode(
thumbnail_data.swap(data);
break;
}
callback.Run(thumbnail_data, original_size);
std::move(callback).Run(thumbnail_data, original_size);
}
void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
......@@ -274,7 +274,7 @@ void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
}
void ChromeRenderFrameObserver::GetWebApplicationInfo(
const GetWebApplicationInfoCallback& callback) {
GetWebApplicationInfoCallback callback) {
WebLocalFrame* frame = render_frame()->GetWebFrame();
WebApplicationInfo web_app_info;
......
......@@ -79,11 +79,10 @@ class ChromeRenderFrameObserver : public content::RenderFrameObserver,
int32_t thumbnail_min_area_pixels,
const gfx::Size& thumbnail_max_size_pixels,
chrome::mojom::ImageFormat image_format,
const RequestThumbnailForContextNodeCallback& callback) override;
RequestThumbnailForContextNodeCallback callback) override;
void RequestReloadImageForContextNode() override;
void SetClientSidePhishingDetection(bool enable_phishing_detection) override;
void GetWebApplicationInfo(
const GetWebApplicationInfoCallback& callback) override;
void GetWebApplicationInfo(GetWebApplicationInfoCallback callback) override;
#if defined(OS_ANDROID)
void UpdateBrowserControlsState(content::BrowserControlsState constraints,
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