Convert Callback to {Once,Repeating}Callback in //content/browser.
Use OnceCallback where possible, and use BindRepeating() where it is
meant to be a RepeatingCallback.
Majority of this change is a few typedefs that are very widely used:
- LoadedCallback
- ValidateTokenCallback
- ValidateRegistrationCallback
- GotDataCallback**
** Especially this one.
[email protected], [email protected], [email protected]
TBR=clamy
Bug: 1007760
Change-Id: I3e6b2bfbc1ff5d36a96628da1163f6a37fb2b204
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943327
Commit-Queue: danakj <[email protected]>
Reviewed-by: Mark Cogan <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#720205}
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 92ee935..3ca2f8c 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -887,7 +887,7 @@
bool AwContentBrowserClient::HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 6c639fe..e1ca9d47 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -183,7 +183,7 @@
LoginAuthRequiredCallback auth_required_callback) override;
bool HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/chrome/browser/accessibility/accessibility_ui.cc b/chrome/browser/accessibility/accessibility_ui.cc
index 110cca0..18a6966a2 100644
--- a/chrome/browser/accessibility/accessibility_ui.cc
+++ b/chrome/browser/accessibility/accessibility_ui.cc
@@ -163,7 +163,7 @@
void HandleAccessibilityRequestCallback(
content::BrowserContext* current_context,
const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
+ content::WebUIDataSource::GotDataCallback callback) {
DCHECK(ShouldHandleAccessibilityRequestCallback(path));
base::DictionaryValue data;
@@ -250,7 +250,7 @@
std::string json_string;
base::JSONWriter::Write(data, &json_string);
- callback.Run(base::RefCountedString::TakeString(&json_string));
+ std::move(callback).Run(base::RefCountedString::TakeString(&json_string));
}
bool MatchesPropertyFilters(
diff --git a/chrome/browser/apps/app_service/app_icon_source.cc b/chrome/browser/apps/app_service/app_icon_source.cc
index 997b847..4744dfa 100644
--- a/chrome/browser/apps/app_service/app_icon_source.cc
+++ b/chrome/browser/apps/app_service/app_icon_source.cc
@@ -24,7 +24,7 @@
namespace {
-void LoadDefaultImage(const content::URLDataSource::GotDataCallback& callback) {
+void LoadDefaultImage(content::URLDataSource::GotDataCallback callback) {
base::StringPiece contents =
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
IDR_APP_DEFAULT_ICON, apps_util::GetPrimaryDisplayUIScaleFactor());
@@ -32,18 +32,18 @@
base::RefCountedBytes* image_bytes = new base::RefCountedBytes();
image_bytes->data().assign(contents.data(),
contents.data() + contents.size());
- callback.Run(image_bytes);
+ std::move(callback).Run(image_bytes);
}
-void RunCallback(const content::URLDataSource::GotDataCallback& callback,
+void RunCallback(content::URLDataSource::GotDataCallback callback,
apps::mojom::IconValuePtr iv) {
if (!iv->compressed.has_value() || iv->compressed.value().empty()) {
- LoadDefaultImage(callback);
+ LoadDefaultImage(std::move(callback));
return;
}
base::RefCountedBytes* image_bytes =
new base::RefCountedBytes(iv->compressed.value());
- callback.Run(image_bytes);
+ std::move(callback).Run(image_bytes);
}
} // namespace
@@ -59,7 +59,7 @@
void AppIconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path_lower =
base::ToLowerASCII(content::URLDataSource::URLToRequestPath(url));
std::vector<std::string> path_parts = base::SplitString(
@@ -67,7 +67,7 @@
// Check data exists, load default image if it doesn't.
if (path_lower.empty() || path_parts.size() < 2) {
- LoadDefaultImage(callback);
+ LoadDefaultImage(std::move(callback));
return;
}
@@ -76,7 +76,7 @@
std::string size_param = path_parts[1];
int size = 0;
if (!base::StringToInt(size_param, &size)) {
- LoadDefaultImage(callback);
+ LoadDefaultImage(std::move(callback));
return;
}
constexpr bool quantize_to_supported_scale_factor = true;
@@ -86,7 +86,7 @@
apps::AppServiceProxy* app_service_proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
if (!app_service_proxy) {
- LoadDefaultImage(callback);
+ LoadDefaultImage(std::move(callback));
return;
}
@@ -95,7 +95,8 @@
constexpr bool allow_placeholder_icon = false;
app_service_proxy->LoadIcon(
app_type, app_id, apps::mojom::IconCompression::kCompressed, size_in_dip,
- allow_placeholder_icon, base::BindOnce(&RunCallback, callback));
+ allow_placeholder_icon,
+ base::BindOnce(&RunCallback, std::move(callback)));
}
std::string AppIconSource::GetMimeType(const std::string&) {
diff --git a/chrome/browser/apps/app_service/app_icon_source.h b/chrome/browser/apps/app_service/app_icon_source.h
index 296036d0..4a2c03c 100644
--- a/chrome/browser/apps/app_service/app_icon_source.h
+++ b/chrome/browser/apps/app_service/app_icon_source.h
@@ -39,7 +39,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool AllowCaching() override;
bool ShouldReplaceExistingSource() override;
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 8ebb3cc8..b39e5a0 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -940,13 +940,13 @@
}
void LaunchURL(const GURL& url,
- const content::WebContents::Getter& web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
ui::PageTransition page_transition,
bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin) {
// If there is no longer a WebContents, the request may have raced with tab
// closing. Don't fire the external request. (It may have been a prerender.)
- content::WebContents* web_contents = web_contents_getter.Run();
+ content::WebContents* web_contents = std::move(web_contents_getter).Run();
if (!web_contents)
return;
@@ -4768,7 +4768,7 @@
bool ChromeContentBrowserClient::HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
@@ -4799,8 +4799,8 @@
base::PostTask(
FROM_HERE, {BrowserThread::UI},
- base::BindOnce(&LaunchURL, url, web_contents_getter, page_transition,
- has_user_gesture, initiating_origin));
+ base::BindOnce(&LaunchURL, url, std::move(web_contents_getter),
+ page_transition, has_user_gesture, initiating_origin));
return true;
}
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index eac552d..7995a32 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -549,7 +549,7 @@
LoginAuthRequiredCallback auth_required_callback) override;
bool HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/chrome/browser/chrome_service_worker_browsertest.cc b/chrome/browser/chrome_service_worker_browsertest.cc
index 84a34c78..b5aa3d6 100644
--- a/chrome/browser/chrome_service_worker_browsertest.cc
+++ b/chrome/browser/chrome_service_worker_browsertest.cc
@@ -699,9 +699,9 @@
std::string GetSource() override { return source_; }
void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
- const GotDataCallback& callback) override {
+ GotDataCallback callback) override {
std::string data(content_);
- callback.Run(base::RefCountedString::TakeString(&data));
+ std::move(callback).Run(base::RefCountedString::TakeString(&data));
}
std::string GetMimeType(const std::string& path) override {
return "application/javascript";
diff --git a/chrome/browser/chromeos/file_manager/file_manager_jstest_base.cc b/chrome/browser/chromeos/file_manager/file_manager_jstest_base.cc
index c48bc46..dd33856 100644
--- a/chrome/browser/chromeos/file_manager/file_manager_jstest_base.cc
+++ b/chrome/browser/chromeos/file_manager/file_manager_jstest_base.cc
@@ -38,23 +38,24 @@
~TestFilesDataSource() override {}
private:
- // This has to match kTestResourceURL
+ // This has to match TestResourceUrl()
std::string GetSource() override { return "file_manager_test"; }
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override {
+ content::URLDataSource::GotDataCallback callback) override {
const std::string path = content::URLDataSource::URLToRequestPath(url);
- base::PostTask(FROM_HERE,
- {base::ThreadPool(), base::MayBlock(),
- base::TaskPriority::USER_BLOCKING},
- base::BindOnce(&TestFilesDataSource::ReadFile,
- base::Unretained(this), path, callback));
+ base::PostTask(
+ FROM_HERE,
+ {base::ThreadPool(), base::MayBlock(),
+ base::TaskPriority::USER_BLOCKING},
+ base::BindOnce(&TestFilesDataSource::ReadFile, base::Unretained(this),
+ path, std::move(callback)));
}
void ReadFile(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
if (source_root_.empty()) {
CHECK(base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root_));
}
@@ -85,7 +86,7 @@
scoped_refptr<base::RefCountedString> response =
base::RefCountedString::TakeString(&content);
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
// It currently only serves HTML/JS/CSS.
@@ -138,6 +139,11 @@
base::LazyInstance<TestWebUIProvider>::DestructorAtExit test_webui_provider_ =
LAZY_INSTANCE_INITIALIZER;
+static const GURL TestResourceUrl() {
+ static GURL url(content::GetWebUIURLString("file_manager_test"));
+ return url;
+}
+
} // namespace
FileManagerJsTestBase::FileManagerJsTestBase(const base::FilePath& base_path)
@@ -145,9 +151,6 @@
FileManagerJsTestBase::~FileManagerJsTestBase() {}
-const std::string FileManagerJsTestBase::kTestResourceURL =
- content::GetWebUIURLString("file_manager_test");
-
void FileManagerJsTestBase::RunTest(const base::FilePath& file) {
base::FilePath root_path;
ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &root_path));
@@ -196,15 +199,14 @@
std::make_unique<TestChromeWebUIControllerFactory>();
content::WebUIControllerFactory::RegisterFactory(
webui_controller_factory_.get());
- webui_controller_factory_->AddFactoryOverride(GURL(kTestResourceURL).host(),
+ webui_controller_factory_->AddFactoryOverride(TestResourceUrl().host(),
test_webui_provider_.Pointer());
}
void FileManagerJsTestBase::TearDownOnMainThread() {
InProcessBrowserTest::TearDownOnMainThread();
- webui_controller_factory_->RemoveFactoryOverride(
- GURL(kTestResourceURL).host());
+ webui_controller_factory_->RemoveFactoryOverride(TestResourceUrl().host());
content::WebUIControllerFactory::UnregisterFactoryForTesting(
webui_controller_factory_.get());
diff --git a/chrome/browser/chromeos/login/users/avatar/user_image_loader.cc b/chrome/browser/chromeos/login/users/avatar/user_image_loader.cc
index 81db0cb..ea09a655 100644
--- a/chrome/browser/chromeos/login/users/avatar/user_image_loader.cc
+++ b/chrome/browser/chromeos/login/users/avatar/user_image_loader.cc
@@ -32,17 +32,21 @@
ImageInfo(const base::FilePath& file_path,
int pixels_per_side,
ImageDecoder::ImageCodec image_codec,
- const LoadedCallback& loaded_cb)
+ LoadedCallback loaded_cb)
: file_path(file_path),
pixels_per_side(pixels_per_side),
image_codec(image_codec),
- loaded_cb(loaded_cb) {}
+ loaded_cb(std::move(loaded_cb)) {}
+
+ ImageInfo(ImageInfo&&) = default;
+ ImageInfo& operator=(ImageInfo&&) = default;
+
~ImageInfo() {}
- const base::FilePath file_path;
- const int pixels_per_side;
- const ImageDecoder::ImageCodec image_codec;
- const LoadedCallback loaded_cb;
+ base::FilePath file_path;
+ int pixels_per_side;
+ ImageDecoder::ImageCodec image_codec;
+ LoadedCallback loaded_cb;
};
// Crops |image| to the square format and downsizes the image to
@@ -106,10 +110,10 @@
class UserImageRequest : public ImageDecoder::ImageRequest {
public:
UserImageRequest(
- const ImageInfo& image_info,
+ ImageInfo image_info,
const std::string& image_data,
scoped_refptr<base::SequencedTaskRunner> background_task_runner)
- : image_info_(image_info),
+ : image_info_(std::move(image_info)),
// TODO(crbug.com/593251): Remove the data copy here.
image_data_(new base::RefCountedBytes(
reinterpret_cast<const unsigned char*>(image_data.data()),
@@ -134,7 +138,7 @@
bool image_bytes_regenerated);
private:
- const ImageInfo image_info_;
+ ImageInfo image_info_;
scoped_refptr<base::RefCountedBytes> image_data_;
scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
@@ -200,19 +204,20 @@
image_info_.image_codec == ImageDecoder::ROBUST_PNG_CODEC ||
image_bytes_regenerated)
user_image->MarkAsSafe();
- image_info_.loaded_cb.Run(std::move(user_image));
+ std::move(image_info_.loaded_cb).Run(std::move(user_image));
delete this;
}
void UserImageRequest::OnDecodeImageFailed() {
- image_info_.loaded_cb.Run(base::WrapUnique(new user_manager::UserImage));
+ std::move(image_info_.loaded_cb)
+ .Run(base::WrapUnique(new user_manager::UserImage));
delete this;
}
// Starts decoding the image with ImageDecoder for the image |data| if
// |data_is_ready| is true.
void DecodeImage(
- const ImageInfo& image_info,
+ ImageInfo image_info,
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
const std::string* data,
bool data_is_ready) {
@@ -220,15 +225,15 @@
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(
- image_info.loaded_cb,
+ std::move(image_info.loaded_cb),
base::Passed(base::WrapUnique(new user_manager::UserImage))));
return;
}
- UserImageRequest* image_request =
- new UserImageRequest(image_info, *data, background_task_runner);
- ImageDecoder::StartWithOptions(image_request, *data, image_info.image_codec,
- false);
+ ImageDecoder::ImageCodec codec = image_info.image_codec;
+ UserImageRequest* image_request = new UserImageRequest(
+ std::move(image_info), *data, background_task_runner);
+ ImageDecoder::StartWithOptions(image_request, *data, codec, false);
}
} // namespace
@@ -238,14 +243,15 @@
const base::FilePath& file_path,
ImageDecoder::ImageCodec image_codec,
int pixels_per_side,
- const LoadedCallback& loaded_cb) {
+ LoadedCallback loaded_cb) {
std::string* data = new std::string;
base::PostTaskAndReplyWithResult(
background_task_runner.get(), FROM_HERE,
- base::Bind(&base::ReadFileToString, file_path, data),
- base::Bind(&DecodeImage,
- ImageInfo(file_path, pixels_per_side, image_codec, loaded_cb),
- background_task_runner, base::Owned(data)));
+ base::BindOnce(&base::ReadFileToString, file_path, data),
+ base::BindOnce(&DecodeImage,
+ ImageInfo(file_path, pixels_per_side, image_codec,
+ std::move(loaded_cb)),
+ background_task_runner, base::Owned(data)));
}
void StartWithData(
@@ -253,10 +259,10 @@
std::unique_ptr<std::string> data,
ImageDecoder::ImageCodec image_codec,
int pixels_per_side,
- const LoadedCallback& loaded_cb) {
- DecodeImage(
- ImageInfo(base::FilePath(), pixels_per_side, image_codec, loaded_cb),
- background_task_runner, data.get(), true /* data_is_ready */);
+ LoadedCallback loaded_cb) {
+ DecodeImage(ImageInfo(base::FilePath(), pixels_per_side, image_codec,
+ std::move(loaded_cb)),
+ background_task_runner, data.get(), true /* data_is_ready */);
}
} // namespace user_image_loader
diff --git a/chrome/browser/chromeos/login/users/avatar/user_image_loader.h b/chrome/browser/chromeos/login/users/avatar/user_image_loader.h
index dc36329..b48d3ba 100644
--- a/chrome/browser/chromeos/login/users/avatar/user_image_loader.h
+++ b/chrome/browser/chromeos/login/users/avatar/user_image_loader.h
@@ -25,8 +25,8 @@
namespace chromeos {
namespace user_image_loader {
-typedef base::Callback<void(std::unique_ptr<user_manager::UserImage>)>
- LoadedCallback;
+using LoadedCallback =
+ base::OnceCallback<void(std::unique_ptr<user_manager::UserImage>)>;
// Loads an image with |image_codec| in the background and calls |loaded_cb|
// with the resulting UserImage (which may be empty in case of error). If
@@ -41,13 +41,13 @@
const base::FilePath& file_path,
ImageDecoder::ImageCodec image_codec,
int pixels_per_side,
- const LoadedCallback& loaded_cb);
+ LoadedCallback loaded_cb);
void StartWithData(
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
std::unique_ptr<std::string> data,
ImageDecoder::ImageCodec image_codec,
int pixels_per_side,
- const LoadedCallback& loaded_cb);
+ LoadedCallback loaded_cb);
} // namespace user_image_loader
} // namespace chromeos
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index b52a10b..dc5e645 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -2154,9 +2154,9 @@
std::string GetSource() override { return source_; }
void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
- const GotDataCallback& callback) override {
+ GotDataCallback callback) override {
std::string data(content_);
- callback.Run(base::RefCountedString::TakeString(&data));
+ std::move(callback).Run(base::RefCountedString::TakeString(&data));
}
std::string GetMimeType(const std::string& path) override {
return "text/html";
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc
index 42cc603..b97c0e7 100644
--- a/chrome/browser/push_messaging/push_messaging_service_impl.cc
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -726,31 +726,33 @@
int64_t service_worker_registration_id,
const std::string& sender_id,
const std::string& subscription_id,
- const SubscriptionInfoCallback& callback) {
+ SubscriptionInfoCallback callback) {
PushMessagingAppIdentifier app_identifier =
PushMessagingAppIdentifier::FindByServiceWorker(
profile_, origin, service_worker_registration_id);
if (app_identifier.is_null()) {
- callback.Run(false /* is_valid */, GURL::EmptyGURL() /*endpoint*/,
- std::vector<uint8_t>() /* p256dh */,
- std::vector<uint8_t>() /* auth */);
+ std::move(callback).Run(
+ false /* is_valid */, GURL::EmptyGURL() /*endpoint*/,
+ std::vector<uint8_t>() /* p256dh */, std::vector<uint8_t>() /* auth */);
return;
}
const GURL endpoint = CreateEndpoint(subscription_id);
const std::string& app_id = app_identifier.app_id();
- base::Callback<void(bool)> validate_cb = base::Bind(
- &PushMessagingServiceImpl::DidValidateSubscription,
- weak_factory_.GetWeakPtr(), app_id, sender_id, endpoint, callback);
+ base::OnceCallback<void(bool)> validate_cb =
+ base::BindOnce(&PushMessagingServiceImpl::DidValidateSubscription,
+ weak_factory_.GetWeakPtr(), app_id, sender_id, endpoint,
+ std::move(callback));
if (PushMessagingAppIdentifier::UseInstanceID(app_id)) {
GetInstanceIDDriver()->GetInstanceID(app_id)->ValidateToken(
NormalizeSenderInfo(sender_id), kGCMScope, subscription_id,
- validate_cb);
+ std::move(validate_cb));
} else {
GetGCMDriver()->ValidateRegistration(
- app_id, {NormalizeSenderInfo(sender_id)}, subscription_id, validate_cb);
+ app_id, {NormalizeSenderInfo(sender_id)}, subscription_id,
+ std::move(validate_cb));
}
}
@@ -758,31 +760,32 @@
const std::string& app_id,
const std::string& sender_id,
const GURL& endpoint,
- const SubscriptionInfoCallback& callback,
+ SubscriptionInfoCallback callback,
bool is_valid) {
if (!is_valid) {
- callback.Run(false /* is_valid */, GURL::EmptyGURL() /* endpoint */,
- std::vector<uint8_t>() /* p256dh */,
- std::vector<uint8_t>() /* auth */);
+ std::move(callback).Run(
+ false /* is_valid */, GURL::EmptyGURL() /* endpoint */,
+ std::vector<uint8_t>() /* p256dh */, std::vector<uint8_t>() /* auth */);
return;
}
GetEncryptionInfoForAppId(
app_id, sender_id,
base::BindOnce(&PushMessagingServiceImpl::DidGetEncryptionInfo,
- weak_factory_.GetWeakPtr(), endpoint, callback));
+ weak_factory_.GetWeakPtr(), endpoint,
+ std::move(callback)));
}
void PushMessagingServiceImpl::DidGetEncryptionInfo(
const GURL& endpoint,
- const SubscriptionInfoCallback& callback,
+ SubscriptionInfoCallback callback,
std::string p256dh,
std::string auth_secret) const {
// I/O errors might prevent the GCM Driver from retrieving a key-pair.
bool is_valid = !p256dh.empty();
- callback.Run(is_valid, endpoint,
- std::vector<uint8_t>(p256dh.begin(), p256dh.end()),
- std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()));
+ std::move(callback).Run(
+ is_valid, endpoint, std::vector<uint8_t>(p256dh.begin(), p256dh.end()),
+ std::vector<uint8_t>(auth_secret.begin(), auth_secret.end()));
}
// Unsubscribe methods ---------------------------------------------------------
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.h b/chrome/browser/push_messaging/push_messaging_service_impl.h
index d84b5b3..514abf5 100644
--- a/chrome/browser/push_messaging/push_messaging_service_impl.h
+++ b/chrome/browser/push_messaging/push_messaging_service_impl.h
@@ -105,7 +105,7 @@
int64_t service_worker_registration_id,
const std::string& sender_id,
const std::string& subscription_id,
- const SubscriptionInfoCallback& callback) override;
+ SubscriptionInfoCallback callback) override;
void Unsubscribe(blink::mojom::PushUnregistrationReason reason,
const GURL& requesting_origin,
int64_t service_worker_registration_id,
@@ -199,11 +199,11 @@
void DidValidateSubscription(const std::string& app_id,
const std::string& sender_id,
const GURL& endpoint,
- const SubscriptionInfoCallback& callback,
+ SubscriptionInfoCallback callback,
bool is_valid);
void DidGetEncryptionInfo(const GURL& endpoint,
- const SubscriptionInfoCallback& callback,
+ SubscriptionInfoCallback callback,
std::string p256dh,
std::string auth_secret) const;
diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc
index 620f789..33ebff2ba2 100644
--- a/chrome/browser/search/local_ntp_source.cc
+++ b/chrome/browser/search/local_ntp_source.cc
@@ -329,10 +329,9 @@
return data_string;
}
-void ServeBackgroundImageData(
- const content::URLDataSource::GotDataCallback& callback,
- std::string data_string) {
- callback.Run(base::RefCountedString::TakeString(&data_string));
+void ServeBackgroundImageData(content::URLDataSource::GotDataCallback callback,
+ std::string data_string) {
+ std::move(callback).Run(base::RefCountedString::TakeString(&data_string));
}
std::string GetLocalNtpPath() {
@@ -665,8 +664,8 @@
// Get the cached logo.
void GetCachedLogo(LogoService* service,
- const content::URLDataSource::GotDataCallback& callback) {
- StartGetLogo(service, callback, /*from_cache=*/true);
+ content::URLDataSource::GotDataCallback callback) {
+ StartGetLogo(service, std::move(callback), /*from_cache=*/true);
}
// Get the fresh logo corresponding to a previous request for a cached logo.
@@ -679,13 +678,13 @@
// request, or perhaps one newer.
void GetFreshLogo(LogoService* service,
int requested_version,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
bool from_cache = (requested_version <= version_finished_);
- StartGetLogo(service, callback, from_cache);
+ StartGetLogo(service, std::move(callback), from_cache);
}
private:
- void OnLogoAvailable(const content::URLDataSource::GotDataCallback& callback,
+ void OnLogoAvailable(content::URLDataSource::GotDataCallback callback,
LogoCallbackReason type,
const base::Optional<EncodedLogo>& logo) {
scoped_refptr<base::RefCountedString> response;
@@ -714,21 +713,19 @@
base::JSONWriter::Write(*ddl, &js);
js = "var ddl = " + js + ";";
response = base::RefCountedString::TakeString(&js);
- callback.Run(response);
+ std::move(callback).Run(response);
}
- void OnCachedLogoAvailable(
- const content::URLDataSource::GotDataCallback& callback,
- LogoCallbackReason type,
- const base::Optional<EncodedLogo>& logo) {
- OnLogoAvailable(callback, type, logo);
+ void OnCachedLogoAvailable(content::URLDataSource::GotDataCallback callback,
+ LogoCallbackReason type,
+ const base::Optional<EncodedLogo>& logo) {
+ OnLogoAvailable(std::move(callback), type, logo);
}
- void OnFreshLogoAvailable(
- const content::URLDataSource::GotDataCallback& callback,
- LogoCallbackReason type,
- const base::Optional<EncodedLogo>& logo) {
- OnLogoAvailable(callback, type, logo);
+ void OnFreshLogoAvailable(content::URLDataSource::GotDataCallback callback,
+ LogoCallbackReason type,
+ const base::Optional<EncodedLogo>& logo) {
+ OnLogoAvailable(std::move(callback), type, logo);
OnRequestCompleted(type, logo);
}
@@ -738,21 +735,21 @@
}
void StartGetLogo(LogoService* service,
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
bool from_cache) {
EncodedLogoCallback cached, fresh;
LogoCallbacks callbacks;
if (from_cache) {
callbacks.on_cached_encoded_logo_available =
base::BindOnce(&DesktopLogoObserver::OnCachedLogoAvailable,
- weak_ptr_factory_.GetWeakPtr(), callback);
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback));
callbacks.on_fresh_encoded_logo_available =
base::BindOnce(&DesktopLogoObserver::OnRequestCompleted,
weak_ptr_factory_.GetWeakPtr());
} else {
callbacks.on_fresh_encoded_logo_available =
base::BindOnce(&DesktopLogoObserver::OnFreshLogoAvailable,
- weak_ptr_factory_.GetWeakPtr(), callback);
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback));
}
if (!observing()) {
++version_started_;
@@ -826,7 +823,7 @@
void LocalNtpSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
@@ -834,12 +831,13 @@
std::string stripped_path = StripParameters(path);
if (stripped_path == kConfigDataFilename) {
std::string config_data_js = search_config_provider_->config_data_js();
- callback.Run(base::RefCountedString::TakeString(&config_data_js));
+ std::move(callback).Run(
+ base::RefCountedString::TakeString(&config_data_js));
return;
}
if (stripped_path == kThemeCSSFilename) {
std::string theme_css = GetThemeCSS(profile_);
- callback.Run(base::RefCountedString::TakeString(&theme_css));
+ std::move(callback).Run(base::RefCountedString::TakeString(&theme_css));
return;
}
@@ -849,24 +847,24 @@
{base::ThreadPool(), base::TaskPriority::USER_VISIBLE,
base::MayBlock()},
base::BindOnce(&ReadBackgroundImageData, profile_->GetPath()),
- base::BindOnce(&ServeBackgroundImageData, callback));
+ base::BindOnce(&ServeBackgroundImageData, std::move(callback)));
return;
}
if (stripped_path == kNtpBackgroundCollectionScriptFilename) {
if (!ntp_background_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
ntp_background_collections_requests_.emplace_back(base::TimeTicks::Now(),
- callback);
+ std::move(callback));
ntp_background_service_->FetchCollectionInfo();
return;
}
if (stripped_path == kNtpBackgroundImageScriptFilename) {
if (!ntp_background_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
std::string collection_id_param;
@@ -874,28 +872,28 @@
if (net::GetValueForKeyInQuery(path_url, "collection_id",
&collection_id_param)) {
ntp_background_image_info_requests_.emplace_back(base::TimeTicks::Now(),
- callback);
+ std::move(callback));
ntp_background_service_->FetchCollectionImageInfo(collection_id_param);
} else {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
}
return;
}
if (stripped_path == kOneGoogleBarScriptFilename) {
if (!one_google_bar_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
} else {
- ServeOneGoogleBarWhenAvailable(callback);
+ ServeOneGoogleBarWhenAvailable(std::move(callback));
}
return;
}
if (stripped_path == kPromoScriptFilename) {
if (!promo_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
} else {
- ServePromoWhenAvailable(callback);
+ ServePromoWhenAvailable(std::move(callback));
}
return;
}
@@ -904,7 +902,7 @@
// refresh the data until the old data is used.
if (stripped_path == kSearchSuggestionsScriptFilename) {
if (!search_suggest_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -914,11 +912,12 @@
if (one_google_bar_service_->language_code() != kEnUSLanguageCode) {
std::string no_suggestions =
"var searchSuggestions = {suggestionsHtml: ''}";
- callback.Run(base::RefCountedString::TakeString(&no_suggestions));
+ std::move(callback).Run(
+ base::RefCountedString::TakeString(&no_suggestions));
return;
}
- ServeSearchSuggestionsIfAvailable(callback);
+ ServeSearchSuggestionsIfAvailable(std::move(callback));
pending_search_suggest_request_ = base::TimeTicks::Now();
search_suggest_service_->Refresh();
@@ -927,7 +926,7 @@
if (stripped_path == kDoodleScriptFilename) {
if (!logo_service_) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -936,9 +935,9 @@
GURL url = GURL(chrome::kChromeSearchLocalNtpUrl).Resolve(path);
if (net::GetValueForKeyInQuery(url, "v", &version_string) &&
base::StringToInt(version_string, &version)) {
- logo_observer_->GetFreshLogo(logo_service_, version, callback);
+ logo_observer_->GetFreshLogo(logo_service_, version, std::move(callback));
} else {
- logo_observer_->GetCachedLogo(logo_service_, callback);
+ logo_observer_->GetCachedLogo(logo_service_, std::move(callback));
}
return;
}
@@ -1049,7 +1048,7 @@
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
base::StringPiece html = bundle.GetRawDataResource(IDR_LOCAL_NTP_HTML);
std::string replaced = ui::ReplaceTemplateExpressions(html, replacements);
- callback.Run(base::RefCountedString::TakeString(&replaced));
+ std::move(callback).Run(base::RefCountedString::TakeString(&replaced));
return;
}
@@ -1064,11 +1063,11 @@
scoped_refptr<base::RefCountedMemory> response(
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
kResources[i].identifier, scale_factor));
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
return;
}
}
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
}
std::string LocalNtpSource::GetMimeType(const std::string& path) {
@@ -1149,8 +1148,8 @@
result = base::RefCountedString::TakeString(&js);
base::TimeTicks now = base::TimeTicks::Now();
- for (const auto& request : ntp_background_collections_requests_) {
- request.callback.Run(result);
+ for (auto& request : ntp_background_collections_requests_) {
+ std::move(request.callback).Run(result);
base::TimeDelta delta = now - request.start_time;
UMA_HISTOGRAM_MEDIUM_TIMES(
"NewTabPage.BackgroundService.Collections.RequestLatency", delta);
@@ -1187,8 +1186,8 @@
result = base::RefCountedString::TakeString(&js);
base::TimeTicks now = base::TimeTicks::Now();
- for (const auto& request : ntp_background_image_info_requests_) {
- request.callback.Run(result);
+ for (auto& request : ntp_background_image_info_requests_) {
+ std::move(request.callback).Run(result);
base::TimeDelta delta = now - request.start_time;
UMA_HISTOGRAM_MEDIUM_TIMES(
"NewTabPage.BackgroundService.Images.RequestLatency", delta);
@@ -1292,7 +1291,7 @@
}
void LocalNtpSource::ServeSearchSuggestionsIfAvailable(
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
base::Optional<SearchSuggestData> data =
search_suggest_service_->search_suggest_data();
@@ -1305,7 +1304,7 @@
base::JSONWriter::Write(*ConvertSearchSuggestDataToDict(data), &js);
js = "var searchSuggestions = " + js + ";";
result = base::RefCountedString::TakeString(&js);
- callback.Run(result);
+ std::move(callback).Run(result);
}
void LocalNtpSource::ServeOneGoogleBar(
@@ -1331,22 +1330,22 @@
UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.OneGoogleBar.RequestLatency.Failure",
delta);
}
- for (const auto& callback : one_google_bar_callbacks_) {
- callback.Run(result);
+ for (auto& callback : one_google_bar_callbacks_) {
+ std::move(callback).Run(result);
}
pending_one_google_bar_request_ = base::nullopt;
one_google_bar_callbacks_.clear();
}
void LocalNtpSource::ServeOneGoogleBarWhenAvailable(
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
base::Optional<OneGoogleBarData> data =
one_google_bar_service_->one_google_bar_data();
if (!pending_one_google_bar_request_.has_value()) {
- callback.Run(GetOGBString(data));
+ std::move(callback).Run(GetOGBString(data));
} else {
- one_google_bar_callbacks_.emplace_back(callback);
+ one_google_bar_callbacks_.push_back(std::move(callback));
}
}
@@ -1376,21 +1375,21 @@
UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.Promos.RequestLatency2.Failure",
delta);
}
- for (const auto& callback : promo_callbacks_) {
- callback.Run(result);
+ for (auto& callback : promo_callbacks_) {
+ std::move(callback).Run(result);
}
pending_promo_request_ = base::nullopt;
promo_callbacks_.clear();
}
void LocalNtpSource::ServePromoWhenAvailable(
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
base::Optional<PromoData> data = promo_service_->promo_data();
if (!pending_promo_request_.has_value()) {
- callback.Run(GetPromoString(data));
+ std::move(callback).Run(GetPromoString(data));
} else {
- promo_callbacks_.emplace_back(callback);
+ promo_callbacks_.push_back(std::move(callback));
}
}
@@ -1407,10 +1406,12 @@
LocalNtpSource::NtpBackgroundRequest::NtpBackgroundRequest(
base::TimeTicks start_time,
- const content::URLDataSource::GotDataCallback& callback)
- : start_time(start_time), callback(callback) {}
+ content::URLDataSource::GotDataCallback callback)
+ : start_time(start_time), callback(std::move(callback)) {}
LocalNtpSource::NtpBackgroundRequest::NtpBackgroundRequest(
- const NtpBackgroundRequest&) = default;
+ NtpBackgroundRequest&&) = default;
+LocalNtpSource::NtpBackgroundRequest& LocalNtpSource::NtpBackgroundRequest::
+operator=(NtpBackgroundRequest&&) = default;
LocalNtpSource::NtpBackgroundRequest::~NtpBackgroundRequest() = default;
diff --git a/chrome/browser/search/local_ntp_source.h b/chrome/browser/search/local_ntp_source.h
index 765e28a..0d299a5 100644
--- a/chrome/browser/search/local_ntp_source.h
+++ b/chrome/browser/search/local_ntp_source.h
@@ -59,10 +59,10 @@
class DesktopLogoObserver;
struct NtpBackgroundRequest {
- NtpBackgroundRequest(
- base::TimeTicks start_time,
- const content::URLDataSource::GotDataCallback& callback);
- NtpBackgroundRequest(const NtpBackgroundRequest&);
+ NtpBackgroundRequest(base::TimeTicks start_time,
+ content::URLDataSource::GotDataCallback callback);
+ NtpBackgroundRequest(NtpBackgroundRequest&&);
+ NtpBackgroundRequest& operator=(NtpBackgroundRequest&&);
~NtpBackgroundRequest();
base::TimeTicks start_time;
@@ -74,7 +74,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
bool AllowCaching() override;
bool ShouldServiceRequest(const GURL& url,
@@ -110,7 +110,7 @@
// is returned immediately, otherwise it is returned when it becomes available
// in ServeOneGoogleBar.
void ServeOneGoogleBarWhenAvailable(
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback callback);
// Called when the promo data is available and serves |data| to any pending
// requests from the NTP.
@@ -119,12 +119,12 @@
// is returned immediately, otherwise it is returned when it becomes
// available in ServePromo.
void ServePromoWhenAvailable(
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback callback);
// If suggestion data is available return it immediately, otherwise no search
// suggestions will be shown on this NTP load.
void ServeSearchSuggestionsIfAvailable(
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback callback);
// Start requests for the promo and OGB.
void InitiatePromoAndOGBRequests();
diff --git a/chrome/browser/search/most_visited_iframe_source.cc b/chrome/browser/search/most_visited_iframe_source.cc
index 4d4314e..45792f5 100644
--- a/chrome/browser/search/most_visited_iframe_source.cc
+++ b/chrome/browser/search/most_visited_iframe_source.cc
@@ -63,54 +63,55 @@
void MostVisitedIframeSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path(url.path());
if (path == kSingleHTMLPath) {
- SendResource(IDR_MOST_VISITED_SINGLE_HTML, callback);
+ SendResource(IDR_MOST_VISITED_SINGLE_HTML, std::move(callback));
} else if (path == kSingleCSSPath) {
- SendResource(IDR_MOST_VISITED_SINGLE_CSS, callback);
+ SendResource(IDR_MOST_VISITED_SINGLE_CSS, std::move(callback));
} else if (path == kSingleJSPath) {
- SendJSWithOrigin(IDR_MOST_VISITED_SINGLE_JS, wc_getter, callback);
+ SendJSWithOrigin(IDR_MOST_VISITED_SINGLE_JS, wc_getter,
+ std::move(callback));
} else if (path == kTitleHTMLPath) {
- SendResource(IDR_MOST_VISITED_TITLE_HTML, callback);
+ SendResource(IDR_MOST_VISITED_TITLE_HTML, std::move(callback));
} else if (path == kTitleCSSPath) {
- SendResource(IDR_MOST_VISITED_TITLE_CSS, callback);
+ SendResource(IDR_MOST_VISITED_TITLE_CSS, std::move(callback));
} else if (path == kTitleJSPath) {
- SendResource(IDR_MOST_VISITED_TITLE_JS, callback);
+ SendResource(IDR_MOST_VISITED_TITLE_JS, std::move(callback));
} else if (path == kUtilJSPath) {
- SendJSWithOrigin(IDR_MOST_VISITED_UTIL_JS, wc_getter, callback);
+ SendJSWithOrigin(IDR_MOST_VISITED_UTIL_JS, wc_getter, std::move(callback));
} else if (path == kCommonCSSPath) {
- SendResource(IDR_MOST_VISITED_IFRAME_CSS, callback);
+ SendResource(IDR_MOST_VISITED_IFRAME_CSS, std::move(callback));
} else if (path == kDontShowPngPath) {
- SendResource(IDR_MOST_VISITED_DONT_SHOW_PNG, callback);
+ SendResource(IDR_MOST_VISITED_DONT_SHOW_PNG, std::move(callback));
} else if (path == kDontShow2XPngPath) {
- SendResource(IDR_MOST_VISITED_DONT_SHOW_2X_PNG, callback);
+ SendResource(IDR_MOST_VISITED_DONT_SHOW_2X_PNG, std::move(callback));
} else if (path == kEditHTMLPath) {
- SendResource(IDR_CUSTOM_LINKS_EDIT_HTML, callback);
+ SendResource(IDR_CUSTOM_LINKS_EDIT_HTML, std::move(callback));
} else if (path == kEditCSSPath) {
- SendResource(IDR_CUSTOM_LINKS_EDIT_CSS, callback);
+ SendResource(IDR_CUSTOM_LINKS_EDIT_CSS, std::move(callback));
} else if (path == kEditJSPath) {
- SendJSWithOrigin(IDR_CUSTOM_LINKS_EDIT_JS, wc_getter, callback);
+ SendJSWithOrigin(IDR_CUSTOM_LINKS_EDIT_JS, wc_getter, std::move(callback));
} else if (path == kAddSvgPath) {
- SendResource(IDR_CUSTOM_LINKS_ADD_SVG, callback);
+ SendResource(IDR_CUSTOM_LINKS_ADD_SVG, std::move(callback));
} else if (path == kAddWhiteSvgPath) {
- SendResource(IDR_CUSTOM_LINKS_ADD_WHITE_SVG, callback);
+ SendResource(IDR_CUSTOM_LINKS_ADD_WHITE_SVG, std::move(callback));
} else if (path == kEditMenuSvgPath) {
- SendResource(IDR_CUSTOM_LINKS_EDIT_MENU_SVG, callback);
+ SendResource(IDR_CUSTOM_LINKS_EDIT_MENU_SVG, std::move(callback));
} else if (path == kLocalNTPCommonCSSPath) {
- SendResource(IDR_LOCAL_NTP_COMMON_CSS, callback);
+ SendResource(IDR_LOCAL_NTP_COMMON_CSS, std::move(callback));
} else if (path == kAnimationsCSSPath) {
- SendResource(IDR_LOCAL_NTP_ANIMATIONS_CSS, callback);
+ SendResource(IDR_LOCAL_NTP_ANIMATIONS_CSS, std::move(callback));
} else if (path == kAnimationsJSPath) {
- SendResource(IDR_LOCAL_NTP_ANIMATIONS_JS, callback);
+ SendResource(IDR_LOCAL_NTP_ANIMATIONS_JS, std::move(callback));
} else if (path == kLocalNTPUtilsJSPath) {
- SendResource(IDR_LOCAL_NTP_UTILS_JS, callback);
+ SendResource(IDR_LOCAL_NTP_UTILS_JS, std::move(callback));
} else if (path == kAssertJsPath) {
- SendResource(IDR_WEBUI_JS_ASSERT, callback);
+ SendResource(IDR_WEBUI_JS_ASSERT, std::move(callback));
} else {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
}
}
@@ -163,18 +164,19 @@
void MostVisitedIframeSource::SendResource(
int resource_id,
- const content::URLDataSource::GotDataCallback& callback) {
- callback.Run(ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- resource_id));
+ content::URLDataSource::GotDataCallback callback) {
+ std::move(callback).Run(
+ ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+ resource_id));
}
void MostVisitedIframeSource::SendJSWithOrigin(
int resource_id,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
std::string origin;
if (!GetOrigin(wc_getter, &origin)) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -182,7 +184,7 @@
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
std::string response(template_js.as_string());
base::ReplaceFirstSubstringAfterOffset(&response, 0, "{{ORIGIN}}", origin);
- callback.Run(base::RefCountedString::TakeString(&response));
+ std::move(callback).Run(base::RefCountedString::TakeString(&response));
}
bool MostVisitedIframeSource::GetOrigin(
diff --git a/chrome/browser/search/most_visited_iframe_source.h b/chrome/browser/search/most_visited_iframe_source.h
index 6f97034..c0ecdacf 100644
--- a/chrome/browser/search/most_visited_iframe_source.h
+++ b/chrome/browser/search/most_visited_iframe_source.h
@@ -25,7 +25,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path_and_query) override;
bool AllowCaching() override;
bool ShouldDenyXFrameOptions() override;
@@ -39,13 +39,12 @@
// Sends unmodified resource bytes.
void SendResource(int resource_id,
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback callback);
// Sends Javascript with an expected postMessage origin interpolated.
- void SendJSWithOrigin(
- int resource_id,
- const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback);
+ void SendJSWithOrigin(int resource_id,
+ const content::WebContents::Getter& wc_getter,
+ content::URLDataSource::GotDataCallback callback);
// This is exposed for testing and should not be overridden.
// Sets |origin| to the URL of the WebContents identified by |wc_getter|.
diff --git a/chrome/browser/search/most_visited_iframe_source_unittest.cc b/chrome/browser/search/most_visited_iframe_source_unittest.cc
index 1b13b8d..f126ba0 100644
--- a/chrome/browser/search/most_visited_iframe_source_unittest.cc
+++ b/chrome/browser/search/most_visited_iframe_source_unittest.cc
@@ -48,7 +48,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override {}
+ content::URLDataSource::GotDataCallback callback) override {}
// RenderFrameHost is hard to mock in concert with everything else, so stub
// this method out for testing.
@@ -85,12 +85,16 @@
}
void SendResource(int resource_id) {
- source()->SendResource(resource_id, callback_);
+ source()->SendResource(
+ resource_id, base::BindOnce(&MostVisitedIframeSourceTest::SaveResponse,
+ base::Unretained(this)));
}
void SendJSWithOrigin(int resource_id) {
- source()->SendJSWithOrigin(resource_id, content::WebContents::Getter(),
- callback_);
+ source()->SendJSWithOrigin(
+ resource_id, content::WebContents::Getter(),
+ base::BindOnce(&MostVisitedIframeSourceTest::SaveResponse,
+ base::Unretained(this)));
}
bool ShouldService(const std::string& path, int process_id) {
@@ -101,8 +105,6 @@
private:
void SetUp() override {
source_ = std::make_unique<TestMostVisitedIframeSource>();
- callback_ = base::Bind(&MostVisitedIframeSourceTest::SaveResponse,
- base::Unretained(this));
instant_io_context_ = new InstantIOContext;
InstantIOContext::SetUserDataOnIO(&resource_context_, instant_io_context_);
source_->set_origin(kInstantOrigin);
@@ -122,7 +124,6 @@
net::TestURLRequestContext test_url_request_context_;
content::MockResourceContext resource_context_;
std::unique_ptr<TestMostVisitedIframeSource> source_;
- content::URLDataSource::GotDataCallback callback_;
scoped_refptr<InstantIOContext> instant_io_context_;
scoped_refptr<base::RefCountedMemory> response_;
};
diff --git a/chrome/browser/search/ntp_icon_source.cc b/chrome/browser/search/ntp_icon_source.cc
index e3aa430..00cc2415 100644
--- a/chrome/browser/search/ntp_icon_source.cc
+++ b/chrome/browser/search/ntp_icon_source.cc
@@ -226,17 +226,20 @@
} // namespace
struct NtpIconSource::NtpIconRequest {
- NtpIconRequest(const content::URLDataSource::GotDataCallback& cb,
+ NtpIconRequest(content::URLDataSource::GotDataCallback cb,
const GURL& path,
int icon_size_in_pixels,
float scale,
bool show_fallback_monogram)
- : callback(cb),
+ : callback(std::move(cb)),
path(path),
icon_size_in_pixels(icon_size_in_pixels),
device_scale_factor(scale),
show_fallback_monogram(show_fallback_monogram) {}
- NtpIconRequest(const NtpIconRequest& other) = default;
+
+ NtpIconRequest(NtpIconRequest&& other) = default;
+ NtpIconRequest& operator=(NtpIconRequest&& other) = default;
+
~NtpIconRequest() {}
content::URLDataSource::GotDataCallback callback;
@@ -262,7 +265,7 @@
void NtpIconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
favicon::FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS);
@@ -273,7 +276,7 @@
if (parsed.url.is_valid()) {
int icon_size_in_pixels =
std::ceil(parsed.size_in_dip * parsed.device_scale_factor);
- NtpIconRequest request(callback, parsed.url, icon_size_in_pixels,
+ NtpIconRequest request(std::move(callback), parsed.url, icon_size_in_pixels,
parsed.device_scale_factor,
parsed.show_fallback_monogram);
@@ -295,10 +298,10 @@
gfx::ImageSkiaOperations::CreateResizedImage(
image.AsImageSkia(), skia::ImageOperations::RESIZE_BEST,
target_size);
- ReturnRenderedIconForRequest(request,
+ ReturnRenderedIconForRequest(std::move(request),
gfx::Image(resized_image).AsBitmap());
} else {
- ReturnRenderedIconForRequest(request, image.AsBitmap());
+ ReturnRenderedIconForRequest(std::move(request), image.AsBitmap());
}
return;
}
@@ -311,11 +314,11 @@
favicon_service->GetRawFaviconForPageURL(
parsed.url, {favicon_base::IconType::kFavicon}, icon_size_in_pixels,
fallback_to_host,
- base::Bind(&NtpIconSource::OnLocalFaviconAvailable,
- weak_ptr_factory_.GetWeakPtr(), request),
+ base::BindOnce(&NtpIconSource::OnLocalFaviconAvailable,
+ weak_ptr_factory_.GetWeakPtr(), std::move(request)),
&cancelable_task_tracker_);
} else {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
}
}
@@ -338,7 +341,7 @@
}
void NtpIconSource::OnLocalFaviconAvailable(
- const NtpIconRequest& request,
+ NtpIconRequest request,
const favicon_base::FaviconRawBitmapResult& bitmap_result) {
if (bitmap_result.is_valid()) {
// A local favicon was found. Decode it to an SkBitmap so it can eventually
@@ -348,12 +351,12 @@
gfx::PNGCodec::Decode(bitmap_result.bitmap_data.get()->front(),
bitmap_result.bitmap_data.get()->size(), &bitmap);
DCHECK(result);
- ReturnRenderedIconForRequest(request, bitmap);
+ ReturnRenderedIconForRequest(std::move(request), bitmap);
} else {
// Since a local favicon was not found, attempt to fetch a server icon if
// the url is known to the server (this last check is important to avoid
// leaking private history to the server).
- RequestServerFavicon(request);
+ RequestServerFavicon(std::move(request));
}
}
@@ -374,14 +377,14 @@
return position != profile.suggestions().end();
}
-void NtpIconSource::RequestServerFavicon(const NtpIconRequest& request) {
+void NtpIconSource::RequestServerFavicon(NtpIconRequest request) {
// Only fetch a server icon if the page url is known to the server. This check
// is important to avoid leaking private history to the server.
const GURL server_favicon_url =
GURL(base::StringPrintf(kServerFaviconURL, request.path.spec().c_str()));
if (!server_favicon_url.is_valid() ||
!IsRequestedUrlInServerSuggestions(request.path)) {
- ReturnRenderedIconForRequest(request, SkBitmap());
+ ReturnRenderedIconForRequest(std::move(request), SkBitmap());
return;
}
@@ -412,13 +415,13 @@
gfx::Size(request.icon_size_in_pixels, request.icon_size_in_pixels));
image_fetcher_->FetchImage(
server_favicon_url,
- base::Bind(&NtpIconSource::OnServerFaviconAvailable,
- weak_ptr_factory_.GetWeakPtr(), request),
+ base::BindOnce(&NtpIconSource::OnServerFaviconAvailable,
+ weak_ptr_factory_.GetWeakPtr(), std::move(request)),
std::move(params));
}
void NtpIconSource::OnServerFaviconAvailable(
- const NtpIconRequest& request,
+ NtpIconRequest request,
const gfx::Image& fetched_image,
const image_fetcher::RequestMetadata& metadata) {
// If a server icon was not found, |fetched_bitmap| will be empty and a
@@ -432,10 +435,10 @@
request.icon_size_in_pixels, request.icon_size_in_pixels);
}
- ReturnRenderedIconForRequest(request, fetched_bitmap);
+ ReturnRenderedIconForRequest(std::move(request), fetched_bitmap);
}
-void NtpIconSource::ReturnRenderedIconForRequest(const NtpIconRequest& request,
+void NtpIconSource::ReturnRenderedIconForRequest(NtpIconRequest request,
const SkBitmap& favicon) {
// Only use even pixel sizes to avoid issues when centering the fallback
// monogram.
@@ -478,5 +481,6 @@
std::vector<unsigned char> bitmap_data;
bool result = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &bitmap_data);
DCHECK(result);
- request.callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data));
+ std::move(request.callback)
+ .Run(base::RefCountedBytes::TakeVector(&bitmap_data));
}
diff --git a/chrome/browser/search/ntp_icon_source.h b/chrome/browser/search/ntp_icon_source.h
index 314b757..ee59f15 100644
--- a/chrome/browser/search/ntp_icon_source.h
+++ b/chrome/browser/search/ntp_icon_source.h
@@ -39,7 +39,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
bool ShouldServiceRequest(const GURL& url,
content::ResourceContext* resource_context,
@@ -48,19 +48,19 @@
private:
struct NtpIconRequest;
void OnLocalFaviconAvailable(
- const NtpIconRequest& request,
+ NtpIconRequest request,
const favicon_base::FaviconRawBitmapResult& bitmap_result);
// Returns whether |url| is in the set of server suggestions.
bool IsRequestedUrlInServerSuggestions(const GURL& url);
- void RequestServerFavicon(const NtpIconRequest& request);
- void OnServerFaviconAvailable(const NtpIconRequest& request,
+ void RequestServerFavicon(NtpIconRequest request);
+ void OnServerFaviconAvailable(NtpIconRequest request,
const gfx::Image& fetched_image,
const image_fetcher::RequestMetadata& metadata);
// Will call |request.callback| with the rendered icon. |bitmap| can be empty,
// in which case the returned icon is a fallback circle with a letter drawn
// into it.
- void ReturnRenderedIconForRequest(const NtpIconRequest& request,
+ void ReturnRenderedIconForRequest(NtpIconRequest request,
const SkBitmap& bitmap);
base::CancelableTaskTracker cancelable_task_tracker_;
diff --git a/chrome/browser/search/suggestions/suggestions_ui.cc b/chrome/browser/search/suggestions/suggestions_ui.cc
index 524599df..f459d4e 100644
--- a/chrome/browser/search/suggestions/suggestions_ui.cc
+++ b/chrome/browser/search/suggestions/suggestions_ui.cc
@@ -29,7 +29,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
private:
@@ -52,9 +52,9 @@
void SuggestionsSourceWrapper::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
suggestions_source_.StartDataRequest(
- content::URLDataSource::URLToRequestPath(url), callback);
+ content::URLDataSource::URLToRequestPath(url), std::move(callback));
}
std::string SuggestionsSourceWrapper::GetMimeType(const std::string& path) {
diff --git a/chrome/browser/sharing/sharing_device_registration_unittest.cc b/chrome/browser/sharing/sharing_device_registration_unittest.cc
index 727e8301..9c6e7e34 100644
--- a/chrome/browser/sharing/sharing_device_registration_unittest.cc
+++ b/chrome/browser/sharing/sharing_device_registration_unittest.cc
@@ -85,7 +85,7 @@
void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override {
+ ValidateTokenCallback callback) override {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/sync/test/integration/sync_test.h b/chrome/browser/sync/test/integration/sync_test.h
index 068f7dcc..91cfa3c3 100644
--- a/chrome/browser/sync/test/integration/sync_test.h
+++ b/chrome/browser/sync/test/integration/sync_test.h
@@ -113,7 +113,7 @@
void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override {}
+ ValidateTokenCallback callback) override {}
void DeleteToken(const std::string& authorized_entity,
const std::string& scope,
diff --git a/chrome/browser/ui/web_applications/system_web_app_ui_utils.cc b/chrome/browser/ui/web_applications/system_web_app_ui_utils.cc
index 81055ab9..d19a0b89 100644
--- a/chrome/browser/ui/web_applications/system_web_app_ui_utils.cc
+++ b/chrome/browser/ui/web_applications/system_web_app_ui_utils.cc
@@ -184,9 +184,10 @@
[](const std::string& path) { return path == "manifest.json"; }),
base::BindRepeating(
[](const std::string& response, const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
+ content::WebUIDataSource::GotDataCallback callback) {
std::string response_copy = response;
- callback.Run(base::RefCountedString::TakeString(&response_copy));
+ std::move(callback).Run(
+ base::RefCountedString::TakeString(&response_copy));
},
std::move(response)));
}
diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc
index 53acc4d..948e173 100644
--- a/chrome/browser/ui/webui/about_ui.cc
+++ b/chrome/browser/ui/webui/about_ui.cc
@@ -181,9 +181,9 @@
: public base::RefCountedThreadSafe<ChromeOSTermsHandler> {
public:
static void Start(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
scoped_refptr<ChromeOSTermsHandler> handler(
- new ChromeOSTermsHandler(path, callback));
+ new ChromeOSTermsHandler(path, std::move(callback)));
handler->StartOnUIThread();
}
@@ -191,9 +191,9 @@
friend class base::RefCountedThreadSafe<ChromeOSTermsHandler>;
ChromeOSTermsHandler(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback)
+ content::URLDataSource::GotDataCallback callback)
: path_(path),
- callback_(callback),
+ callback_(std::move(callback)),
// Previously we were using "initial locale" http://crbug.com/145142
locale_(g_browser_process->GetApplicationLocale()) {}
@@ -343,7 +343,7 @@
// Do nothing if OEM EULA or Play Store ToS load failed.
if (contents_.empty() && path_.empty())
contents_ = l10n_util::GetStringUTF8(IDS_TERMS_HTML);
- callback_.Run(base::RefCountedString::TakeString(&contents_));
+ std::move(callback_).Run(base::RefCountedString::TakeString(&contents_));
}
// Path in the URL.
@@ -365,19 +365,18 @@
: public base::RefCountedThreadSafe<ChromeOSCreditsHandler> {
public:
static void Start(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
scoped_refptr<ChromeOSCreditsHandler> handler(
- new ChromeOSCreditsHandler(path, callback));
+ new ChromeOSCreditsHandler(path, std::move(callback)));
handler->StartOnUIThread();
}
private:
friend class base::RefCountedThreadSafe<ChromeOSCreditsHandler>;
- ChromeOSCreditsHandler(
- const std::string& path,
- const content::URLDataSource::GotDataCallback& callback)
- : path_(path), callback_(callback) {}
+ ChromeOSCreditsHandler(const std::string& path,
+ content::URLDataSource::GotDataCallback callback)
+ : path_(path), callback_(std::move(callback)) {}
virtual ~ChromeOSCreditsHandler() {}
@@ -415,7 +414,7 @@
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_OS_CREDITS_HTML);
}
- callback_.Run(base::RefCountedString::TakeString(&contents_));
+ std::move(callback_).Run(base::RefCountedString::TakeString(&contents_));
}
// Path in the URL.
@@ -434,9 +433,9 @@
: public base::RefCountedThreadSafe<LinuxCreditsHandler> {
public:
static void Start(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
scoped_refptr<LinuxCreditsHandler> handler(
- new LinuxCreditsHandler(path, callback));
+ new LinuxCreditsHandler(path, std::move(callback)));
handler->StartOnUIThread();
}
@@ -444,8 +443,8 @@
friend class base::RefCountedThreadSafe<LinuxCreditsHandler>;
LinuxCreditsHandler(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback)
- : path_(path), callback_(callback) {}
+ content::URLDataSource::GotDataCallback callback)
+ : path_(path), callback_(std::move(callback)) {}
virtual ~LinuxCreditsHandler() {}
@@ -485,7 +484,7 @@
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_OS_CREDITS_HTML);
}
- callback_.Run(base::RefCountedString::TakeString(&contents_));
+ std::move(callback_).Run(base::RefCountedString::TakeString(&contents_));
}
// Path in the URL.
@@ -597,7 +596,7 @@
void AboutUIHTMLSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
std::string response;
@@ -624,16 +623,16 @@
#endif
#if defined(OS_CHROMEOS)
} else if (source_name_ == chrome::kChromeUIOSCreditsHost) {
- ChromeOSCreditsHandler::Start(path, callback);
+ ChromeOSCreditsHandler::Start(path, std::move(callback));
return;
} else if (source_name_ == chrome::kChromeUILinuxCreditsHost) {
- LinuxCreditsHandler::Start(path, callback);
+ LinuxCreditsHandler::Start(path, std::move(callback));
return;
#endif
#if !defined(OS_ANDROID)
} else if (source_name_ == chrome::kChromeUITermsHost) {
#if defined(OS_CHROMEOS)
- ChromeOSTermsHandler::Start(path, callback);
+ ChromeOSTermsHandler::Start(path, std::move(callback));
return;
#else
response = l10n_util::GetStringUTF8(IDS_TERMS_HTML);
@@ -641,14 +640,14 @@
#endif
}
- FinishDataRequest(response, callback);
+ FinishDataRequest(response, std::move(callback));
}
void AboutUIHTMLSource::FinishDataRequest(
const std::string& html,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
std::string html_copy(html);
- callback.Run(base::RefCountedString::TakeString(&html_copy));
+ std::move(callback).Run(base::RefCountedString::TakeString(&html_copy));
}
std::string AboutUIHTMLSource::GetMimeType(const std::string& path) {
diff --git a/chrome/browser/ui/webui/about_ui.h b/chrome/browser/ui/webui/about_ui.h
index 485fa5b..8a77e03b 100644
--- a/chrome/browser/ui/webui/about_ui.h
+++ b/chrome/browser/ui/webui/about_ui.h
@@ -27,16 +27,15 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
bool ShouldAddContentSecurityPolicy() override;
std::string GetAccessControlAllowOriginForOrigin(
const std::string& origin) override;
// Send the response data.
- void FinishDataRequest(
- const std::string& html,
- const content::URLDataSource::GotDataCallback& callback);
+ void FinishDataRequest(const std::string& html,
+ content::URLDataSource::GotDataCallback callback);
Profile* profile() { return profile_; }
diff --git a/chrome/browser/ui/webui/app_launcher_page_ui.cc b/chrome/browser/ui/webui/app_launcher_page_ui.cc
index 553d3f2..f4d500f5 100644
--- a/chrome/browser/ui/webui/app_launcher_page_ui.cc
+++ b/chrome/browser/ui/webui/app_launcher_page_ui.cc
@@ -101,7 +101,7 @@
void AppLauncherPageUI::HTMLSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
NTPResourceCache* resource = AppResourceCacheFactory::GetForProfile(profile_);
@@ -114,7 +114,7 @@
scoped_refptr<base::RefCountedMemory> html_bytes(
resource->GetNewTabHTML(win_type));
- callback.Run(html_bytes.get());
+ std::move(callback).Run(html_bytes.get());
}
std::string AppLauncherPageUI::HTMLSource::GetMimeType(
diff --git a/chrome/browser/ui/webui/app_launcher_page_ui.h b/chrome/browser/ui/webui/app_launcher_page_ui.h
index 011f5579..280e6003 100644
--- a/chrome/browser/ui/webui/app_launcher_page_ui.h
+++ b/chrome/browser/ui/webui/app_launcher_page_ui.h
@@ -41,7 +41,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool ShouldReplaceExistingSource() override;
bool AllowCaching() override;
diff --git a/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
index 2d32689..9868804 100644
--- a/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
@@ -112,12 +112,11 @@
MobileActivator::ActivationError::kActivationFailed, carrier);
}
-void DataRequestFailed(
- const std::string& service_path,
- const content::URLDataSource::GotDataCallback& callback) {
+void DataRequestFailed(const std::string& service_path,
+ content::URLDataSource::GotDataCallback callback) {
NET_LOG(ERROR) << "Data Request Failed for Mobile Setup: " << service_path;
scoped_refptr<base::RefCountedBytes> html_bytes(new base::RefCountedBytes);
- callback.Run(html_bytes.get());
+ std::move(callback).Run(html_bytes.get());
}
// Keys for the dictionary that is set to activation UI and that contains the
@@ -179,7 +178,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override { return "text/html"; }
bool ShouldAddContentSecurityPolicy() override { return false; }
bool AllowCaching() override {
@@ -271,7 +270,7 @@
void MobileSetupUIHTMLSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
// Sanity checks that activation was requested for an appropriate network.
const NetworkState* network =
@@ -279,13 +278,13 @@
if (!network) {
NET_LOG(ERROR) << "Network for mobile setup not found: " << path;
- DataRequestFailed(path, callback);
+ DataRequestFailed(path, std::move(callback));
return;
}
if (!network->Matches(NetworkTypePattern::Cellular())) {
NET_LOG(ERROR) << "Mobile setup attempt for non cellular network: " << path;
- DataRequestFailed(path, callback);
+ DataRequestFailed(path, std::move(callback));
return;
}
@@ -294,7 +293,7 @@
NET_LOG(ERROR) << "Mobile setup network in unexpected state: " << path
<< " payment_url: " << network->payment_url()
<< " activation_state: " << network->activation_state();
- DataRequestFailed(path, callback);
+ DataRequestFailed(path, std::move(callback));
return;
}
@@ -304,7 +303,7 @@
if (!device) {
NET_LOG(ERROR) << "Network device for mobile setup not found: "
<< network->device_path();
- DataRequestFailed(path, callback);
+ DataRequestFailed(path, std::move(callback));
return;
}
@@ -354,7 +353,7 @@
full_html = webui::GetI18nTemplateHtml(html_for_non_activated, &strings);
}
- callback.Run(base::RefCountedString::TakeString(&full_html));
+ std::move(callback).Run(base::RefCountedString::TakeString(&full_html));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/webui/chromeos/image_source.cc b/chrome/browser/ui/webui/chromeos/image_source.cc
index 3110ff0..2ad02f4c 100644
--- a/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -29,13 +29,12 @@
const char* const kWhitelistedDirectories[] = {"regulatory_labels"};
// Callback for user_manager::UserImageLoader.
-void ImageLoaded(
- const content::URLDataSource::GotDataCallback& got_data_callback,
- std::unique_ptr<user_manager::UserImage> user_image) {
+void ImageLoaded(content::URLDataSource::GotDataCallback got_data_callback,
+ std::unique_ptr<user_manager::UserImage> user_image) {
if (user_image->has_image_bytes())
- got_data_callback.Run(user_image->image_bytes());
+ std::move(got_data_callback).Run(user_image->image_bytes());
else
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
}
} // namespace
@@ -56,10 +55,10 @@
void ImageSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& got_data_callback) {
+ content::URLDataSource::GotDataCallback got_data_callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
if (!IsWhitelisted(path)) {
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
return;
}
@@ -68,24 +67,23 @@
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::Bind(&base::PathExists, image_path),
- base::Bind(&ImageSource::StartDataRequestAfterPathExists,
- weak_factory_.GetWeakPtr(), image_path, got_data_callback));
+ base::BindOnce(&base::PathExists, image_path),
+ base::BindOnce(&ImageSource::StartDataRequestAfterPathExists,
+ weak_factory_.GetWeakPtr(), image_path,
+ std::move(got_data_callback)));
}
void ImageSource::StartDataRequestAfterPathExists(
const base::FilePath& image_path,
- const content::URLDataSource::GotDataCallback& got_data_callback,
+ content::URLDataSource::GotDataCallback got_data_callback,
bool path_exists) {
if (path_exists) {
user_image_loader::StartWithFilePath(
- task_runner_,
- image_path,
- ImageDecoder::DEFAULT_CODEC,
+ task_runner_, image_path, ImageDecoder::DEFAULT_CODEC,
0, // Do not crop.
- base::Bind(&ImageLoaded, got_data_callback));
+ base::BindOnce(&ImageLoaded, std::move(got_data_callback)));
} else {
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
}
}
diff --git a/chrome/browser/ui/webui/chromeos/image_source.h b/chrome/browser/ui/webui/chromeos/image_source.h
index 6848d0a..a36c544 100644
--- a/chrome/browser/ui/webui/chromeos/image_source.h
+++ b/chrome/browser/ui/webui/chromeos/image_source.h
@@ -27,10 +27,10 @@
// content::URLDataSource implementation.
std::string GetSource() override;
- void StartDataRequest(const GURL& url,
- const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback&
- got_data_callback) override;
+ void StartDataRequest(
+ const GURL& url,
+ const content::WebContents::Getter& wc_getter,
+ content::URLDataSource::GotDataCallback got_data_callback) override;
std::string GetMimeType(const std::string& path) override;
@@ -38,7 +38,7 @@
// Continuation from StartDataRequest().
void StartDataRequestAfterPathExists(
const base::FilePath& image_path,
- const content::URLDataSource::GotDataCallback& got_data_callback,
+ content::URLDataSource::GotDataCallback got_data_callback,
bool path_exists);
// Checks whether we have allowed the image to be loaded.
diff --git a/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc b/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
index 2d4544f..19b15236 100644
--- a/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
+++ b/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
@@ -36,9 +36,9 @@
void ScreenlockIconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
if (!icon_provider_) {
- callback.Run(GetDefaultIcon().As1xPNGBytes().get());
+ std::move(callback).Run(GetDefaultIcon().As1xPNGBytes().get());
return;
}
@@ -49,11 +49,11 @@
gfx::Image image = icon_provider_->GetIcon(username);
if (image.IsEmpty()) {
- callback.Run(GetDefaultIcon().As1xPNGBytes().get());
+ std::move(callback).Run(GetDefaultIcon().As1xPNGBytes().get());
return;
}
- callback.Run(image.As1xPNGBytes().get());
+ std::move(callback).Run(image.As1xPNGBytes().get());
}
std::string ScreenlockIconSource::GetMimeType(const std::string&) const {
diff --git a/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h b/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h
index 0293300..b0a8d43 100644
--- a/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h
+++ b/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h
@@ -25,7 +25,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) const override;
diff --git a/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc b/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
index 0919e411..96c237d 100644
--- a/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
@@ -35,7 +35,7 @@
void SlowTraceSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
int trace_id = 0;
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
@@ -44,13 +44,12 @@
if (!manager ||
pos == std::string::npos ||
!base::StringToInt(path.substr(pos + 1), &trace_id)) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
- manager->GetTraceData(trace_id,
- base::Bind(&SlowTraceSource::OnGetTraceData,
- base::Unretained(this),
- callback));
+ manager->GetTraceData(
+ trace_id, base::BindOnce(&SlowTraceSource::OnGetTraceData,
+ base::Unretained(this), std::move(callback)));
}
std::string SlowTraceSource::GetMimeType(const std::string& path) {
@@ -60,9 +59,9 @@
SlowTraceSource::~SlowTraceSource() {}
void SlowTraceSource::OnGetTraceData(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
scoped_refptr<base::RefCountedString> trace_data) {
- callback.Run(trace_data.get());
+ std::move(callback).Run(trace_data.get());
}
bool SlowTraceSource::AllowCaching() {
diff --git a/chrome/browser/ui/webui/chromeos/slow_trace_ui.h b/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
index 78ebae81..aa719c2f 100644
--- a/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
+++ b/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
@@ -33,12 +33,12 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
bool AllowCaching() override;
private:
- void OnGetTraceData(const content::URLDataSource::GotDataCallback& callback,
+ void OnGetTraceData(content::URLDataSource::GotDataCallback callback,
scoped_refptr<base::RefCountedString> trace_data);
DISALLOW_COPY_AND_ASSIGN(SlowTraceSource);
diff --git a/chrome/browser/ui/webui/chromeos/terminal/terminal_source.cc b/chrome/browser/ui/webui/chromeos/terminal/terminal_source.cc
index c63f034..a89867c 100644
--- a/chrome/browser/ui/webui/chromeos/terminal/terminal_source.cc
+++ b/chrome/browser/ui/webui/chromeos/terminal/terminal_source.cc
@@ -25,7 +25,7 @@
constexpr char kDefaultMime[] = "text/html";
void ReadFile(const base::FilePath& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
std::string content;
// First look for uncompressed resource, then try for gzipped file.
bool result = base::ReadFileToString(path, &content);
@@ -43,7 +43,7 @@
<< path;
scoped_refptr<base::RefCountedString> response =
base::RefCountedString::TakeString(&content);
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
} // namespace
@@ -60,7 +60,7 @@
void TerminalSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
// Reparse path to strip any query or fragment, skip first '/' in path.
@@ -72,7 +72,7 @@
base::PostTask(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING},
- base::BindOnce(&ReadFile, file_path, callback));
+ base::BindOnce(&ReadFile, file_path, std::move(callback)));
}
std::string TerminalSource::GetMimeType(const std::string& path) {
diff --git a/chrome/browser/ui/webui/chromeos/terminal/terminal_source.h b/chrome/browser/ui/webui/chromeos/terminal/terminal_source.h
index 10f3d0d5..119ca1b 100644
--- a/chrome/browser/ui/webui/chromeos/terminal/terminal_source.h
+++ b/chrome/browser/ui/webui/chromeos/terminal/terminal_source.h
@@ -27,7 +27,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
diff --git a/chrome/browser/ui/webui/chromeos/user_image_source.cc b/chrome/browser/ui/webui/chromeos/user_image_source.cc
index 50d6e7a..18aaf98 100644
--- a/chrome/browser/ui/webui/chromeos/user_image_source.cc
+++ b/chrome/browser/ui/webui/chromeos/user_image_source.cc
@@ -180,7 +180,7 @@
void UserImageSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Make sure |url| matches
// |chrome::kChromeUIUserImageURL| now that |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
@@ -188,7 +188,7 @@
int frame = -1;
ParseRequest(url, &email, &frame);
const AccountId account_id(AccountId::FromUserEmail(email));
- callback.Run(GetUserImageInternal(account_id, frame));
+ std::move(callback).Run(GetUserImageInternal(account_id, frame));
}
std::string UserImageSource::GetMimeType(const std::string& path) {
diff --git a/chrome/browser/ui/webui/chromeos/user_image_source.h b/chrome/browser/ui/webui/chromeos/user_image_source.h
index 85c68ad..4e6374d 100644
--- a/chrome/browser/ui/webui/chromeos/user_image_source.h
+++ b/chrome/browser/ui/webui/chromeos/user_image_source.h
@@ -34,7 +34,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
// Returns PNG encoded image for user with specified |account_id|. If there's
diff --git a/chrome/browser/ui/webui/chromeos/video_source.cc b/chrome/browser/ui/webui/chromeos/video_source.cc
index e8d5262..f3b5379a 100644
--- a/chrome/browser/ui/webui/chromeos/video_source.cc
+++ b/chrome/browser/ui/webui/chromeos/video_source.cc
@@ -39,16 +39,16 @@
}
// Callback for user_manager::UserImageLoader.
-void VideoLoaded(
- const content::URLDataSource::GotDataCallback& got_data_callback,
- std::unique_ptr<std::string> video_data,
- bool did_load_file) {
+void VideoLoaded(content::URLDataSource::GotDataCallback got_data_callback,
+ std::unique_ptr<std::string> video_data,
+ bool did_load_file) {
if (video_data->size() && did_load_file) {
- got_data_callback.Run(new base::RefCountedBytes(
- reinterpret_cast<const unsigned char*>(video_data->data()),
- video_data->size()));
+ std::move(got_data_callback)
+ .Run(new base::RefCountedBytes(
+ reinterpret_cast<const unsigned char*>(video_data->data()),
+ video_data->size()));
} else {
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
}
}
@@ -69,10 +69,10 @@
void VideoSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& got_data_callback) {
+ content::URLDataSource::GotDataCallback got_data_callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
if (!IsWhitelisted(path)) {
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
return;
}
@@ -84,7 +84,7 @@
base::BindOnce(&base::PathExists, video_path),
base::BindOnce(&VideoSource::StartDataRequestAfterPathExists,
weak_factory_.GetWeakPtr(), video_path,
- got_data_callback));
+ std::move(got_data_callback)));
}
std::string VideoSource::GetMimeType(const std::string& path) {
@@ -97,7 +97,7 @@
void VideoSource::StartDataRequestAfterPathExists(
const base::FilePath& video_path,
- const content::URLDataSource::GotDataCallback& got_data_callback,
+ content::URLDataSource::GotDataCallback got_data_callback,
bool path_exists) {
if (path_exists) {
auto video_data = std::make_unique<std::string>();
@@ -105,10 +105,11 @@
base::PostTaskAndReplyWithResult(
task_runner_.get(), FROM_HERE,
base::BindOnce(&base::ReadFileToString, video_path, data),
- base::BindOnce(&VideoLoaded, got_data_callback, std::move(video_data)));
+ base::BindOnce(&VideoLoaded, std::move(got_data_callback),
+ std::move(video_data)));
} else {
- got_data_callback.Run(nullptr);
+ std::move(got_data_callback).Run(nullptr);
}
}
diff --git a/chrome/browser/ui/webui/chromeos/video_source.h b/chrome/browser/ui/webui/chromeos/video_source.h
index e113f3f..5ac0abd7 100644
--- a/chrome/browser/ui/webui/chromeos/video_source.h
+++ b/chrome/browser/ui/webui/chromeos/video_source.h
@@ -29,17 +29,17 @@
// content::URLDataSource:
std::string GetSource() override;
- void StartDataRequest(const GURL& url,
- const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback&
- got_data_callback) override;
+ void StartDataRequest(
+ const GURL& url,
+ const content::WebContents::Getter& wc_getter,
+ content::URLDataSource::GotDataCallback got_data_callback) override;
std::string GetMimeType(const std::string& path) override;
private:
// Continuation from StartDataRequest().
void StartDataRequestAfterPathExists(
const base::FilePath& video_path,
- const content::URLDataSource::GotDataCallback& got_data_callback,
+ content::URLDataSource::GotDataCallback got_data_callback,
bool path_exists);
// The background task runner on which file I/O is performed.
diff --git a/chrome/browser/ui/webui/devtools_ui_data_source.cc b/chrome/browser/ui/webui/devtools_ui_data_source.cc
index da69f1a..d718f14 100644
--- a/chrome/browser/ui/webui/devtools_ui_data_source.cc
+++ b/chrome/browser/ui/webui/devtools_ui_data_source.cc
@@ -97,7 +97,7 @@
void DevToolsDataSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const GotDataCallback& callback) {
+ GotDataCallback callback) {
// Serve request to devtools://bundled/ from local bundle.
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
@@ -114,12 +114,12 @@
#if !BUILDFLAG(DEBUG_DEVTOOLS)
if (!GetCustomDevToolsFrontendURL().SchemeIsFile()) {
// Fetch from packaged resources.
- StartBundledDataRequest(path_under_bundled, callback);
+ StartBundledDataRequest(path_under_bundled, std::move(callback));
return;
}
#endif
// Fetch from file system.
- StartFileRequest(path_under_bundled, callback);
+ StartFileRequest(path_under_bundled, std::move(callback));
return;
}
@@ -127,7 +127,7 @@
std::string empty_path_prefix(chrome::kChromeUIDevToolsBlankPath);
if (base::StartsWith(path, empty_path_prefix,
base::CompareCase::INSENSITIVE_ASCII)) {
- callback.Run(new base::RefCountedStaticMemory());
+ std::move(callback).Run(new base::RefCountedStaticMemory());
return;
}
@@ -140,10 +140,10 @@
CHECK_EQ(url.host(), kRemoteFrontendDomain);
if (url.is_valid() && DevToolsUIBindings::IsValidRemoteFrontendURL(url)) {
- StartRemoteDataRequest(url, callback);
+ StartRemoteDataRequest(url, std::move(callback));
} else {
DLOG(ERROR) << "Refusing to load invalid remote front-end URL";
- callback.Run(CreateNotFoundResponse());
+ std::move(callback).Run(CreateNotFoundResponse());
}
return;
}
@@ -158,12 +158,12 @@
GURL url = GURL(custom_devtools_frontend.spec() +
path.substr(custom_path_prefix.length()));
DCHECK(url.is_valid());
- StartCustomDataRequest(url, callback);
+ StartCustomDataRequest(url, std::move(callback));
return;
}
}
- callback.Run(CreateNotFoundResponse());
+ std::move(callback).Run(CreateNotFoundResponse());
}
std::string DevToolsDataSource::GetMimeType(const std::string& path) {
@@ -184,7 +184,7 @@
void DevToolsDataSource::StartBundledDataRequest(
const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
scoped_refptr<base::RefCountedMemory> bytes =
content::DevToolsFrontendHost::GetFrontendResourceBytes(path);
@@ -192,12 +192,12 @@
<< "Unable to find dev tool resource: " << path
<< ". If you compiled with debug_devtools=1, try running with "
"--debug-devtools.";
- callback.Run(bytes);
+ std::move(callback).Run(bytes);
}
void DevToolsDataSource::StartRemoteDataRequest(
const GURL& url,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
CHECK(url.is_valid());
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("devtools_hard_coded_data_source",
@@ -224,14 +224,15 @@
}
})");
- StartNetworkRequest(url, traffic_annotation, net::LOAD_NORMAL, callback);
+ StartNetworkRequest(url, traffic_annotation, net::LOAD_NORMAL,
+ std::move(callback));
}
void DevToolsDataSource::StartCustomDataRequest(
const GURL& url,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
if (!url.is_valid()) {
- callback.Run(CreateNotFoundResponse());
+ std::move(callback).Run(CreateNotFoundResponse());
return;
}
net::NetworkTrafficAnnotationTag traffic_annotation =
@@ -264,20 +265,20 @@
})");
StartNetworkRequest(url, traffic_annotation, net::LOAD_DISABLE_CACHE,
- callback);
+ std::move(callback));
}
void DevToolsDataSource::StartNetworkRequest(
const GURL& url,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
int load_flags,
- const GotDataCallback& callback) {
+ GotDataCallback callback) {
auto request = std::make_unique<network::ResourceRequest>();
request->url = url;
request->load_flags = load_flags;
auto request_iter = pending_requests_.emplace(pending_requests_.begin());
- request_iter->callback = callback;
+ request_iter->callback = std::move(callback);
request_iter->loader =
network::SimpleURLLoader::Create(std::move(request), traffic_annotation);
request_iter->loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
@@ -297,7 +298,7 @@
}
void DevToolsDataSource::StartFileRequest(const std::string& path,
- const GotDataCallback& callback) {
+ GotDataCallback callback) {
base::FilePath base_path;
GURL custom_devtools_frontend = GetCustomDevToolsFrontendURL();
if (custom_devtools_frontend.SchemeIsFile()) {
@@ -306,7 +307,7 @@
#if BUILDFLAG(DEBUG_DEVTOOLS)
// Use default path for unbundled files when debug_devtools=true
if (!base::PathService::Get(chrome::DIR_INSPECTOR_DEBUG, &base_path)) {
- callback.Run(CreateNotFoundResponse());
+ std::move(callback).Run(CreateNotFoundResponse());
return;
}
#else
@@ -322,10 +323,8 @@
{base::MayBlock(), base::ThreadPool(),
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
base::TaskPriority::USER_VISIBLE},
- // The usage of BindRepeating below is only because the type of
- // task callback needs to match that of response callback, which
- // is currently a repeating callback.
- base::BindRepeating(ReadFileForDevTools, std::move(full_path)), callback);
+ base::BindOnce(ReadFileForDevTools, std::move(full_path)),
+ std::move(callback));
}
void DevToolsDataSource::OnLoadComplete(
@@ -345,5 +344,5 @@
DevToolsDataSource::PendingRequest::~PendingRequest() {
if (callback)
- callback.Run(CreateNotFoundResponse());
+ std::move(callback).Run(CreateNotFoundResponse());
}
diff --git a/chrome/browser/ui/webui/devtools_ui_data_source.h b/chrome/browser/ui/webui/devtools_ui_data_source.h
index 04a5c00d..a713ac1 100644
--- a/chrome/browser/ui/webui/devtools_ui_data_source.h
+++ b/chrome/browser/ui/webui/devtools_ui_data_source.h
@@ -41,7 +41,7 @@
void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
- const GotDataCallback& callback) override;
+ GotDataCallback callback) override;
private:
friend class DevToolsUIDataSourceTest;
@@ -59,23 +59,23 @@
// Serves bundled DevTools frontend from ResourceBundle.
void StartBundledDataRequest(const std::string& path,
- const GotDataCallback& callback);
+ GotDataCallback callback);
// Serves remote DevTools frontend from hard-coded App Engine domain.
- void StartRemoteDataRequest(const GURL& url, const GotDataCallback& callback);
+ void StartRemoteDataRequest(const GURL& url, GotDataCallback callback);
// Serves remote DevTools frontend from any endpoint, passed through
// command-line flag.
- void StartCustomDataRequest(const GURL& url, const GotDataCallback& callback);
+ void StartCustomDataRequest(const GURL& url, GotDataCallback callback);
virtual void StartNetworkRequest(
const GURL& url,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
int load_flags,
- const GotDataCallback& callback);
+ GotDataCallback callback);
virtual void StartFileRequest(const std::string& path,
- const GotDataCallback& callback);
+ GotDataCallback callback);
struct PendingRequest {
PendingRequest();
diff --git a/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc b/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
index 07ccf1d0..64171abd1 100644
--- a/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
+++ b/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
@@ -49,15 +49,15 @@
const GURL& url,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
int load_flags,
- const GotDataCallback& callback) override {
+ GotDataCallback callback) override {
std::string result = "url: " + url.spec();
- callback.Run(base::RefCountedString::TakeString(&result));
+ std::move(callback).Run(base::RefCountedString::TakeString(&result));
}
void StartFileRequest(const std::string& path,
- const GotDataCallback& callback) override {
+ GotDataCallback callback) override {
std::string result = "file: " + path;
- callback.Run(base::RefCountedString::TakeString(&result));
+ std::move(callback).Run(base::RefCountedString::TakeString(&result));
}
};
diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc
index ee1b12dd..9d56d83 100644
--- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc
+++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc
@@ -115,17 +115,17 @@
void ExtensionIconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
// This is where everything gets started. First, parse the request and make
// the request data available for later.
static int next_id = 0;
- if (!ParseData(path, ++next_id, callback)) {
+ if (!ParseData(path, ++next_id, &callback)) {
// If the request data cannot be parsed, request parameters will not be
// added to |request_map_|.
// Send back the default application icon (not resized or desaturated) as
// the default response.
- callback.Run(BitmapToMemory(GetDefaultAppImage()).get());
+ std::move(callback).Run(BitmapToMemory(GetDefaultAppImage()).get());
return;
}
@@ -174,7 +174,7 @@
else
bitmap = *image;
- request->callback.Run(BitmapToMemory(&bitmap).get());
+ std::move(request->callback).Run(BitmapToMemory(&bitmap).get());
ClearData(request_id);
}
@@ -243,7 +243,7 @@
if (!request->grayscale) {
// If we don't need a grayscale image, then we can bypass FinalizeImage
// to avoid unnecessary conversions.
- request->callback.Run(bitmap_result.bitmap_data.get());
+ std::move(request->callback).Run(bitmap_result.bitmap_data.get());
ClearData(request_id);
} else {
FinalizeImage(ToBitmap(bitmap_result.bitmap_data->front(),
@@ -273,7 +273,7 @@
bool ExtensionIconSource::ParseData(
const std::string& path,
int request_id,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback* callback) {
// Extract the parameters from the path by lower casing and splitting.
std::string path_lower = base::ToLowerASCII(path);
std::vector<std::string> path_parts = base::SplitString(
@@ -309,21 +309,22 @@
bool grayscale = path_lower.find("grayscale=true") != std::string::npos;
- SetData(request_id, callback, extension, grayscale, size, match_type);
+ SetData(request_id, std::move(*callback), extension, grayscale, size,
+ match_type);
return true;
}
void ExtensionIconSource::SetData(
int request_id,
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
const Extension* extension,
bool grayscale,
int size,
ExtensionIconSet::MatchType match) {
std::unique_ptr<ExtensionIconRequest> request =
std::make_unique<ExtensionIconRequest>();
- request->callback = callback;
+ request->callback = std::move(callback);
request->extension = extension;
request->grayscale = grayscale;
request->size = size;
diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.h b/chrome/browser/ui/webui/extensions/extension_icon_source.h
index c3e1d66..324b27fd 100644
--- a/chrome/browser/ui/webui/extensions/extension_icon_source.h
+++ b/chrome/browser/ui/webui/extensions/extension_icon_source.h
@@ -73,7 +73,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
bool AllowCaching() override;
private:
@@ -120,15 +120,15 @@
void LoadIconFailed(int request_id);
// Parses and saves an ExtensionIconRequest for the URL |path| for the
- // specified |request_id|.
+ // specified |request_id|. Takes the |callback| if it returns true.
bool ParseData(const std::string& path,
int request_id,
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback* callback);
// Stores the parameters associated with the |request_id|, making them
// as an ExtensionIconRequest via GetData.
void SetData(int request_id,
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
const Extension* extension,
bool grayscale,
int size,
diff --git a/chrome/browser/ui/webui/extensions/extensions_internals_source.cc b/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
index d957a3e..c60227d 100644
--- a/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
+++ b/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
@@ -436,9 +436,9 @@
void ExtensionsInternalsSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
std::string json = WriteToString();
- callback.Run(base::RefCountedString::TakeString(&json));
+ std::move(callback).Run(base::RefCountedString::TakeString(&json));
}
std::string ExtensionsInternalsSource::WriteToString() const {
diff --git a/chrome/browser/ui/webui/extensions/extensions_internals_source.h b/chrome/browser/ui/webui/extensions/extensions_internals_source.h
index ca3121c..31e4952 100644
--- a/chrome/browser/ui/webui/extensions/extensions_internals_source.h
+++ b/chrome/browser/ui/webui/extensions/extensions_internals_source.h
@@ -23,7 +23,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
// Simpler interface to generate string output, without needing to
// call StartDataRequest.
diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc
index d62e7ae..f53b02a6 100644
--- a/chrome/browser/ui/webui/favicon_source.cc
+++ b/chrome/browser/ui/webui/favicon_source.cc
@@ -77,27 +77,27 @@
void FaviconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
favicon::FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS);
if (!favicon_service) {
- SendDefaultResponse(callback);
+ SendDefaultResponse(std::move(callback));
return;
}
chrome::ParsedFaviconPath parsed;
bool success = chrome::ParseFaviconPath(path, url_format_, &parsed);
if (!success) {
- SendDefaultResponse(callback);
+ SendDefaultResponse(std::move(callback));
return;
}
GURL page_url(parsed.page_url);
GURL icon_url(parsed.icon_url);
if (!page_url.is_valid() && !icon_url.is_valid()) {
- SendDefaultResponse(callback);
+ SendDefaultResponse(std::move(callback));
return;
}
@@ -111,9 +111,9 @@
// IconType.
favicon_service->GetRawFavicon(
icon_url, favicon_base::IconType::kFavicon, desired_size_in_pixel,
- base::BindRepeating(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this), callback,
- parsed.size_in_dip, parsed.device_scale_factor),
+ base::BindOnce(&FaviconSource::OnFaviconDataAvailable,
+ base::Unretained(this), std::move(callback),
+ parsed.size_in_dip, parsed.device_scale_factor),
&cancelable_task_tracker_);
} else {
// Intercept requests for prepopulated pages if TopSites exists.
@@ -124,7 +124,7 @@
if (page_url == prepopulated_page.most_visited.url) {
ui::ScaleFactor resource_scale_factor =
ui::GetSupportedScaleFactor(parsed.device_scale_factor);
- callback.Run(
+ std::move(callback).Run(
ui::ResourceBundle::GetSharedInstance()
.LoadDataResourceBytesForScale(prepopulated_page.favicon_id,
resource_scale_factor));
@@ -144,9 +144,9 @@
favicon_service->GetRawFaviconForPageURL(
page_url, {favicon_base::IconType::kFavicon}, desired_size_in_pixel,
fallback_to_host,
- base::Bind(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this), callback, parsed.size_in_dip,
- parsed.device_scale_factor),
+ base::BindOnce(&FaviconSource::OnFaviconDataAvailable,
+ base::Unretained(this), std::move(callback),
+ parsed.size_in_dip, parsed.device_scale_factor),
&cancelable_task_tracker_);
return;
}
@@ -158,14 +158,14 @@
HistoryUiFaviconRequestHandlerFactory::GetForBrowserContext(
profile_);
if (!history_ui_favicon_request_handler) {
- SendDefaultResponse(callback);
+ SendDefaultResponse(std::move(callback));
return;
}
history_ui_favicon_request_handler->GetRawFaviconForPageURL(
page_url, desired_size_in_pixel,
base::BindOnce(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this), callback, parsed.size_in_dip,
- parsed.device_scale_factor),
+ base::Unretained(this), std::move(callback),
+ parsed.size_in_dip, parsed.device_scale_factor),
favicon::FaviconRequestPlatform::kDesktop, parsed_history_ui_origin,
/*icon_url_for_uma=*/
GURL(parsed.icon_url), &cancelable_task_tracker_);
@@ -205,25 +205,25 @@
}
void FaviconSource::OnFaviconDataAvailable(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
int size_in_dip,
float scale_factor,
const favicon_base::FaviconRawBitmapResult& bitmap_result) {
if (bitmap_result.is_valid()) {
// Forward the data along to the networking system.
- callback.Run(bitmap_result.bitmap_data.get());
+ std::move(callback).Run(bitmap_result.bitmap_data.get());
} else {
- SendDefaultResponse(callback, size_in_dip, scale_factor);
+ SendDefaultResponse(std::move(callback), size_in_dip, scale_factor);
}
}
void FaviconSource::SendDefaultResponse(
- const content::URLDataSource::GotDataCallback& callback) {
- SendDefaultResponse(callback, 16, 1.0f);
+ content::URLDataSource::GotDataCallback callback) {
+ SendDefaultResponse(std::move(callback), 16, 1.0f);
}
void FaviconSource::SendDefaultResponse(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
int size_in_dip,
float scale_factor) {
const bool dark = GetNativeTheme()->ShouldUseDarkColors();
@@ -239,7 +239,7 @@
resource_id = dark ? IDR_DEFAULT_FAVICON_DARK : IDR_DEFAULT_FAVICON;
break;
}
- callback.Run(LoadIconBytes(scale_factor, resource_id));
+ std::move(callback).Run(LoadIconBytes(scale_factor, resource_id));
}
base::RefCountedMemory* FaviconSource::LoadIconBytes(float scale_factor,
diff --git a/chrome/browser/ui/webui/favicon_source.h b/chrome/browser/ui/webui/favicon_source.h
index 5e419abf..7b21b8a 100644
--- a/chrome/browser/ui/webui/favicon_source.h
+++ b/chrome/browser/ui/webui/favicon_source.h
@@ -46,7 +46,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool AllowCaching() override;
bool ShouldReplaceExistingSource() override;
@@ -75,20 +75,18 @@
// |bitmap_result| is valid, returns it to caller using |callback|. Otherwise
// will send appropriate default icon for |size_in_dip| and |scale_factor|.
void OnFaviconDataAvailable(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
int size_in_dip,
float scale_factor,
const favicon_base::FaviconRawBitmapResult& bitmap_result);
// Sends the 16x16 DIP 1x default favicon.
- void SendDefaultResponse(
- const content::URLDataSource::GotDataCallback& callback);
+ void SendDefaultResponse(content::URLDataSource::GotDataCallback callback);
// Sends the default favicon.
- void SendDefaultResponse(
- const content::URLDataSource::GotDataCallback& callback,
- int size_in_dip,
- float scale_factor);
+ void SendDefaultResponse(content::URLDataSource::GotDataCallback callback,
+ int size_in_dip,
+ float scale_factor);
chrome::FaviconUrlFormat url_format_;
diff --git a/chrome/browser/ui/webui/fileicon_source.cc b/chrome/browser/ui/webui/fileicon_source.cc
index f6ddc145..5a0a51e 100644
--- a/chrome/browser/ui/webui/fileicon_source.cc
+++ b/chrome/browser/ui/webui/fileicon_source.cc
@@ -65,24 +65,21 @@
} // namespace
-FileIconSource::IconRequestDetails::IconRequestDetails() : scale_factor(1.0f) {
-}
-
+FileIconSource::IconRequestDetails::IconRequestDetails() = default;
FileIconSource::IconRequestDetails::IconRequestDetails(
- const IconRequestDetails& other) = default;
+ IconRequestDetails&& other) = default;
+FileIconSource::IconRequestDetails& FileIconSource::IconRequestDetails::
+operator=(IconRequestDetails&& other) = default;
+FileIconSource::IconRequestDetails::~IconRequestDetails() = default;
-FileIconSource::IconRequestDetails::~IconRequestDetails() {
-}
-
-FileIconSource::FileIconSource() {}
-
-FileIconSource::~FileIconSource() {}
+FileIconSource::FileIconSource() = default;
+FileIconSource::~FileIconSource() = default;
void FileIconSource::FetchFileIcon(
const base::FilePath& path,
float scale_factor,
IconLoader::IconSize icon_size,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
IconManager* im = g_browser_process->icon_manager();
gfx::Image* icon = im->LookupIconFromFilepath(path, icon_size);
@@ -92,18 +89,17 @@
icon->ToImageSkia()->GetRepresentation(scale_factor).GetBitmap(), false,
&icon_data->data());
- callback.Run(icon_data.get());
+ std::move(callback).Run(icon_data.get());
} else {
// Attach the ChromeURLDataManager request ID to the history request.
IconRequestDetails details;
- details.callback = callback;
+ details.callback = std::move(callback);
details.scale_factor = scale_factor;
// Icon was not in cache, go fetch it slowly.
- im->LoadIcon(path,
- icon_size,
- base::Bind(&FileIconSource::OnFileIconDataAvailable,
- base::Unretained(this), details),
+ im->LoadIcon(path, icon_size,
+ base::BindOnce(&FileIconSource::OnFileIconDataAvailable,
+ base::Unretained(this), std::move(details)),
&cancelable_task_tracker_);
}
}
@@ -115,14 +111,14 @@
void FileIconSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
base::FilePath file_path;
IconLoader::IconSize icon_size = IconLoader::NORMAL;
float scale_factor = 1.0f;
// TODO(crbug/1009127): Make ParseQueryParams take GURL.
ParseQueryParams(path, &file_path, &scale_factor, &icon_size);
- FetchFileIcon(file_path, scale_factor, icon_size, callback);
+ FetchFileIcon(file_path, scale_factor, icon_size, std::move(callback));
}
std::string FileIconSource::GetMimeType(const std::string&) {
@@ -134,7 +130,7 @@
return false;
}
-void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details,
+void FileIconSource::OnFileIconDataAvailable(IconRequestDetails details,
gfx::Image icon) {
if (!icon.IsEmpty()) {
scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes);
@@ -142,9 +138,9 @@
icon.ToImageSkia()->GetRepresentation(details.scale_factor).GetBitmap(),
false, &icon_data->data());
- details.callback.Run(icon_data.get());
+ std::move(details.callback).Run(icon_data.get());
} else {
// TODO(glen): send a dummy icon.
- details.callback.Run(nullptr);
+ std::move(details.callback).Run(nullptr);
}
}
diff --git a/chrome/browser/ui/webui/fileicon_source.h b/chrome/browser/ui/webui/fileicon_source.h
index c7599d7..89cc0d1 100644
--- a/chrome/browser/ui/webui/fileicon_source.h
+++ b/chrome/browser/ui/webui/fileicon_source.h
@@ -29,7 +29,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool AllowCaching() override;
@@ -37,29 +37,30 @@
// Once the |path| and |icon_size| has been determined from the request, this
// function is called to perform the actual fetch. Declared as virtual for
// testing.
- virtual void FetchFileIcon(
- const base::FilePath& path,
- float scale_factor,
- IconLoader::IconSize icon_size,
- const content::URLDataSource::GotDataCallback& callback);
+ virtual void FetchFileIcon(const base::FilePath& path,
+ float scale_factor,
+ IconLoader::IconSize icon_size,
+ content::URLDataSource::GotDataCallback callback);
private:
// Contains the necessary information for completing an icon fetch request.
struct IconRequestDetails {
IconRequestDetails();
- IconRequestDetails(const IconRequestDetails& other);
+
+ IconRequestDetails(IconRequestDetails&& other);
+ IconRequestDetails& operator=(IconRequestDetails&& other);
+
~IconRequestDetails();
// The callback to run with the response.
content::URLDataSource::GotDataCallback callback;
// The requested scale factor to respond with.
- float scale_factor;
+ float scale_factor = 1;
};
// Called when favicon data is available from the history backend.
- void OnFileIconDataAvailable(const IconRequestDetails& details,
- gfx::Image icon);
+ void OnFileIconDataAvailable(IconRequestDetails details, gfx::Image icon);
// Tracks tasks requesting file icons.
base::CancelableTaskTracker cancelable_task_tracker_;
diff --git a/chrome/browser/ui/webui/fileicon_source_unittest.cc b/chrome/browser/ui/webui/fileicon_source_unittest.cc
index f56d2b6..c2b59c0 100644
--- a/chrome/browser/ui/webui/fileicon_source_unittest.cc
+++ b/chrome/browser/ui/webui/fileicon_source_unittest.cc
@@ -22,11 +22,18 @@
public:
TestFileIconSource() {}
- MOCK_METHOD4(FetchFileIcon,
+ void FetchFileIcon(
+ const base::FilePath& path,
+ float scale_factor,
+ IconLoader::IconSize icon_size,
+ content::URLDataSource::GotDataCallback callback) override {
+ FetchFileIcon_(path, scale_factor, icon_size, callback);
+ }
+ MOCK_METHOD4(FetchFileIcon_,
void(const base::FilePath& path,
float scale_factor,
IconLoader::IconSize icon_size,
- const content::URLDataSource::GotDataCallback& callback));
+ content::URLDataSource::GotDataCallback& callback));
~TestFileIconSource() override {}
};
@@ -115,14 +122,14 @@
for (unsigned i = 0; i < base::size(kBasicExpectations); i++) {
auto source = std::make_unique<TestFileIconSource>();
content::URLDataSource::GotDataCallback callback;
- EXPECT_CALL(*source.get(),
- FetchFileIcon(
- base::FilePath(kBasicExpectations[i].unescaped_path),
- kBasicExpectations[i].scale_factor,
- kBasicExpectations[i].size, CallbackIsNull()));
+ EXPECT_CALL(
+ *source.get(),
+ FetchFileIcon_(base::FilePath(kBasicExpectations[i].unescaped_path),
+ kBasicExpectations[i].scale_factor,
+ kBasicExpectations[i].size, CallbackIsNull()));
source->StartDataRequest(
GURL(base::StrCat(
{"chrome://any-host/", kBasicExpectations[i].request_path})),
- content::WebContents::Getter(), callback);
+ content::WebContents::Getter(), std::move(callback));
}
}
diff --git a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index caafe22..0535200 100644
--- a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -97,7 +97,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
private:
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
@@ -479,7 +479,7 @@
void InterstitialHTMLSource::StartDataRequest(
const GURL& request_url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Simplify usages of |path| since |request_url| is
// available.
const std::string path =
@@ -536,7 +536,7 @@
}
scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
html_bytes->data().assign(html.begin(), html.end());
- callback.Run(html_bytes.get());
+ std::move(callback).Run(html_bytes.get());
}
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index aaa9615..f979ed1 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -154,7 +154,7 @@
void NewTabUI::NewTabHTMLSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
@@ -162,7 +162,7 @@
// A path under new-tab was requested; it's likely a bad relative
// URL from the new tab page, but in any case it's an error.
NOTREACHED() << path << " should not have been requested on the NTP";
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -175,7 +175,7 @@
NTPResourceCacheFactory::GetForProfile(profile_)->
GetNewTabHTML(win_type));
- callback.Run(html_bytes.get());
+ std::move(callback).Run(html_bytes.get());
}
std::string NewTabUI::NewTabHTMLSource::GetMimeType(
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chrome/browser/ui/webui/ntp/new_tab_ui.h
index 66f6c4d..acaf5cc2 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.h
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -58,7 +58,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string&) override;
bool ShouldReplaceExistingSource() override;
std::string GetContentSecurityPolicyScriptSrc() override;
diff --git a/chrome/browser/ui/webui/prefs_internals_source.cc b/chrome/browser/ui/webui/prefs_internals_source.cc
index d4ba24aa..2885476 100644
--- a/chrome/browser/ui/webui/prefs_internals_source.cc
+++ b/chrome/browser/ui/webui/prefs_internals_source.cc
@@ -30,7 +30,7 @@
void PrefsInternalsSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::string json;
std::unique_ptr<base::DictionaryValue> prefs =
@@ -38,5 +38,5 @@
DCHECK(prefs);
CHECK(base::JSONWriter::WriteWithOptions(
*prefs, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json));
- callback.Run(base::RefCountedString::TakeString(&json));
+ std::move(callback).Run(base::RefCountedString::TakeString(&json));
}
diff --git a/chrome/browser/ui/webui/prefs_internals_source.h b/chrome/browser/ui/webui/prefs_internals_source.h
index 8aad42fa..5fc4058 100644
--- a/chrome/browser/ui/webui/prefs_internals_source.h
+++ b/chrome/browser/ui/webui/prefs_internals_source.h
@@ -22,7 +22,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
private:
Profile* profile_;
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
index fa158a29..e3cf8ccb 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -146,9 +146,8 @@
}
// Get markup or other resources for the print preview page.
-void HandleRequestCallback(
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
+void HandleRequestCallback(const std::string& path,
+ content::WebUIDataSource::GotDataCallback callback) {
// ChromeWebUIDataSource handles most requests except for the print preview
// data.
int preview_ui_id;
@@ -159,12 +158,12 @@
PrintPreviewDataService::GetInstance()->GetDataEntry(preview_ui_id,
page_index, &data);
if (data.get()) {
- callback.Run(data.get());
+ std::move(callback).Run(data.get());
return;
}
// Invalid request.
auto empty_bytes = base::MakeRefCounted<base::RefCountedBytes>();
- callback.Run(empty_bytes.get());
+ std::move(callback).Run(empty_bytes.get());
}
void AddPrintPreviewStrings(content::WebUIDataSource* source) {
diff --git a/chrome/browser/ui/webui/test_data_source.cc b/chrome/browser/ui/webui/test_data_source.cc
index 06a22e5d..aa03e09 100644
--- a/chrome/browser/ui/webui/test_data_source.cc
+++ b/chrome/browser/ui/webui/test_data_source.cc
@@ -45,13 +45,13 @@
void TestDataSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
const std::string path = content::URLDataSource::URLToRequestPath(url);
base::PostTask(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_BLOCKING},
base::BindOnce(&TestDataSource::ReadFile, base::Unretained(this), path,
- callback));
+ std::move(callback)));
}
std::string TestDataSource::GetMimeType(const std::string& path) {
@@ -87,7 +87,7 @@
void TestDataSource::ReadFile(
const std::string& path,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
std::string content;
GURL url = GetURLForPath(path);
@@ -125,5 +125,5 @@
scoped_refptr<base::RefCountedString> response =
base::RefCountedString::TakeString(&content);
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
diff --git a/chrome/browser/ui/webui/test_data_source.h b/chrome/browser/ui/webui/test_data_source.h
index b34e8808..f65809d 100644
--- a/chrome/browser/ui/webui/test_data_source.h
+++ b/chrome/browser/ui/webui/test_data_source.h
@@ -22,7 +22,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
@@ -37,7 +37,7 @@
GURL GetURLForPath(const std::string& path);
void ReadFile(const std::string& path,
- const content::URLDataSource::GotDataCallback& callback);
+ content::URLDataSource::GotDataCallback callback);
base::FilePath src_root_;
base::FilePath gen_root_;
diff --git a/chrome/browser/ui/webui/test_files_request_filter.cc b/chrome/browser/ui/webui/test_files_request_filter.cc
index 8255db50..7b971f56 100644
--- a/chrome/browser/ui/webui/test_files_request_filter.cc
+++ b/chrome/browser/ui/webui/test_files_request_filter.cc
@@ -29,7 +29,7 @@
void HandleTestFileRequestCallback(
const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
+ content::WebUIDataSource::GotDataCallback callback) {
DCHECK(ShouldHandleTestFileRequestCallback(path));
base::ScopedAllowBlockingForTesting allow_blocking;
@@ -44,7 +44,7 @@
base::RefCountedString* ref_contents = new base::RefCountedString();
ref_contents->data() = contents;
- callback.Run(ref_contents);
+ std::move(callback).Run(ref_contents);
}
} // namespace
diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc
index 31b07bc..536f075 100644
--- a/chrome/browser/ui/webui/theme_source.cc
+++ b/chrome/browser/ui/webui/theme_source.cc
@@ -84,7 +84,7 @@
void ThemeSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): Simplify usages of |path| since |url| is available.
const std::string path = content::URLDataSource::URLToRequestPath(url);
// Default scale factor if not specified.
@@ -99,7 +99,7 @@
NTPResourceCache::WindowType type =
NTPResourceCache::GetWindowType(profile_, /*render_host=*/nullptr);
NTPResourceCache* cache = NTPResourceCacheFactory::GetForProfile(profile_);
- callback.Run(cache->GetNewTabCSS(type));
+ std::move(callback).Run(cache->GetNewTabCSS(type));
return;
}
@@ -150,16 +150,16 @@
// URLs are only used by WebUI pages and component extensions. However, the
// user can also enter these into the omnibox, so we need to fail
// gracefully.
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
} else if ((GetMimeType(path) == "image/png") &&
((scale > max_scale) || (frame != -1))) {
// This will extract and scale frame 0 of animated images.
// TODO(reveman): Support scaling of animated images and avoid scaling and
// re-encode when specific frame is specified (crbug.com/750064).
DCHECK_LE(frame, 0);
- SendThemeImage(callback, resource_id, scale);
+ SendThemeImage(std::move(callback), resource_id, scale);
} else {
- SendThemeBitmap(callback, resource_id, scale);
+ SendThemeBitmap(std::move(callback), resource_id, scale);
}
}
@@ -206,7 +206,7 @@
// ThemeSource, private:
void ThemeSource::SendThemeBitmap(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
int resource_id,
float scale) {
ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale);
@@ -215,16 +215,17 @@
scoped_refptr<base::RefCountedMemory> image_data(
ThemeService::GetThemeProviderForProfile(profile_->GetOriginalProfile())
.GetRawData(resource_id, scale_factor));
- callback.Run(image_data.get());
+ std::move(callback).Run(image_data.get());
} else {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
const ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- callback.Run(rb.LoadDataResourceBytesForScale(resource_id, scale_factor));
+ std::move(callback).Run(
+ rb.LoadDataResourceBytesForScale(resource_id, scale_factor));
}
}
void ThemeSource::SendThemeImage(
- const content::URLDataSource::GotDataCallback& callback,
+ content::URLDataSource::GotDataCallback callback,
int resource_id,
float scale) {
scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes());
@@ -233,7 +234,7 @@
const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile(
profile_->GetOriginalProfile());
ProcessImageOnUiThread(*tp.GetImageSkiaNamed(resource_id), scale, data);
- callback.Run(data.get());
+ std::move(callback).Run(data.get());
} else {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// Fetching image data in ResourceBundle should happen on the UI thread. See
@@ -241,7 +242,7 @@
base::PostTaskAndReply(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&ProcessResourceOnUiThread, resource_id, scale, data),
- base::BindOnce(callback, data));
+ base::BindOnce(std::move(callback), data));
}
}
diff --git a/chrome/browser/ui/webui/theme_source.h b/chrome/browser/ui/webui/theme_source.h
index b862455..33849c5 100644
--- a/chrome/browser/ui/webui/theme_source.h
+++ b/chrome/browser/ui/webui/theme_source.h
@@ -25,7 +25,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForRequestPath(
const std::string& path) override;
@@ -38,14 +38,14 @@
private:
// Fetches and sends the theme bitmap.
- void SendThemeBitmap(const content::URLDataSource::GotDataCallback& callback,
+ void SendThemeBitmap(content::URLDataSource::GotDataCallback callback,
int resource_id,
float scale);
// Used in place of SendThemeBitmap when the desired scale is larger than
// what the resource bundle supports. This can rescale the provided bitmap up
// to the desired size.
- void SendThemeImage(const content::URLDataSource::GotDataCallback& callback,
+ void SendThemeImage(content::URLDataSource::GotDataCallback callback,
int resource_id,
float scale);
diff --git a/chrome/browser/ui/webui/theme_source_unittest.cc b/chrome/browser/ui/webui/theme_source_unittest.cc
index 489540a1..d4cc3e8e 100644
--- a/chrome/browser/ui/webui/theme_source_unittest.cc
+++ b/chrome/browser/ui/webui/theme_source_unittest.cc
@@ -28,7 +28,9 @@
theme_source()->StartDataRequest(
GURL(base::StrCat({content::kChromeUIScheme, "://",
chrome::kChromeUIThemeHost, "/", source})),
- content::WebContents::Getter(), callback_);
+ content::WebContents::Getter(),
+ base::BindOnce(&WebUISourcesTest::SendResponse,
+ base::Unretained(this)));
}
size_t result_data_size_;
@@ -37,8 +39,6 @@
void SetUp() override {
profile_ = std::make_unique<TestingProfile>();
theme_source_ = std::make_unique<ThemeSource>(profile_.get());
- callback_ = base::Bind(&WebUISourcesTest::SendResponse,
- base::Unretained(this));
}
void TearDown() override {
@@ -50,8 +50,6 @@
result_data_size_ = data ? data->size() : 0;
}
- content::URLDataSource::GotDataCallback callback_;
-
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<TestingProfile> profile_;
diff --git a/chrome/browser/ui/webui/welcome/ntp_background_fetcher.cc b/chrome/browser/ui/webui/welcome/ntp_background_fetcher.cc
index 9a5026c..8715328 100644
--- a/chrome/browser/ui/webui/welcome/ntp_background_fetcher.cc
+++ b/chrome/browser/ui/webui/welcome/ntp_background_fetcher.cc
@@ -21,9 +21,9 @@
NtpBackgroundFetcher::NtpBackgroundFetcher(
size_t index,
- const content::WebUIDataSource::GotDataCallback& callback)
- : index_(index), callback_(callback) {
- DCHECK(callback_ && !callback_.is_null());
+ content::WebUIDataSource::GotDataCallback callback)
+ : index_(index), callback_(std::move(callback)) {
+ DCHECK(callback_);
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("nux_ntp_background_preview", R"(
semantics {
@@ -74,9 +74,10 @@
void NtpBackgroundFetcher::OnFetchCompleted(
std::unique_ptr<std::string> response_body) {
if (response_body) {
- callback_.Run(base::RefCountedString::TakeString(response_body.release()));
+ std::move(callback_).Run(
+ base::RefCountedString::TakeString(response_body.release()));
} else {
- callback_.Run(base::MakeRefCounted<base::RefCountedBytes>());
+ std::move(callback_).Run(base::MakeRefCounted<base::RefCountedBytes>());
}
}
diff --git a/chrome/browser/ui/webui/welcome/ntp_background_fetcher.h b/chrome/browser/ui/webui/welcome/ntp_background_fetcher.h
index bfd25a3..f7ec424 100644
--- a/chrome/browser/ui/webui/welcome/ntp_background_fetcher.h
+++ b/chrome/browser/ui/webui/welcome/ntp_background_fetcher.h
@@ -20,9 +20,8 @@
class NtpBackgroundFetcher {
public:
- NtpBackgroundFetcher(
- size_t index,
- const content::WebUIDataSource::GotDataCallback& callback);
+ NtpBackgroundFetcher(size_t index,
+ content::WebUIDataSource::GotDataCallback callback);
~NtpBackgroundFetcher();
private:
diff --git a/chrome/browser/ui/webui/welcome/welcome_ui.cc b/chrome/browser/ui/webui/welcome/welcome_ui.cc
index bff9f47a..a6209d2e 100644
--- a/chrome/browser/ui/webui/welcome/welcome_ui.cc
+++ b/chrome/browser/ui/webui/welcome/welcome_ui.cc
@@ -54,10 +54,9 @@
return !!weak_ptr;
}
-void HandleRequestCallback(
- base::WeakPtr<WelcomeUI> weak_ptr,
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
+void HandleRequestCallback(base::WeakPtr<WelcomeUI> weak_ptr,
+ const std::string& path,
+ content::WebUIDataSource::GotDataCallback callback) {
DCHECK(ShouldHandleRequestCallback(weak_ptr, path));
std::string index_param = path.substr(path.find_first_of("?") + 1);
@@ -66,7 +65,7 @@
background_index < 0);
DCHECK(weak_ptr);
- weak_ptr->CreateBackgroundFetcher(background_index, callback);
+ weak_ptr->CreateBackgroundFetcher(background_index, std::move(callback));
}
void AddStrings(content::WebUIDataSource* html_source) {
@@ -204,9 +203,9 @@
void WelcomeUI::CreateBackgroundFetcher(
size_t background_index,
- const content::WebUIDataSource::GotDataCallback& callback) {
+ content::WebUIDataSource::GotDataCallback callback) {
background_fetcher_ = std::make_unique<welcome::NtpBackgroundFetcher>(
- background_index, callback);
+ background_index, std::move(callback));
}
void WelcomeUI::StorePageSeen(Profile* profile) {
diff --git a/chrome/browser/ui/webui/welcome/welcome_ui.h b/chrome/browser/ui/webui/welcome/welcome_ui.h
index 3f0be1a..4b51947 100644
--- a/chrome/browser/ui/webui/welcome/welcome_ui.h
+++ b/chrome/browser/ui/webui/welcome/welcome_ui.h
@@ -26,7 +26,7 @@
void CreateBackgroundFetcher(
size_t background_index,
- const content::WebUIDataSource::GotDataCallback& callback);
+ content::WebUIDataSource::GotDataCallback callback);
protected:
// Visible for testing.
diff --git a/chrome/browser/web_applications/extensions/system_web_app_manager_browsertest.cc b/chrome/browser/web_applications/extensions/system_web_app_manager_browsertest.cc
index f8399a6..fce490a 100644
--- a/chrome/browser/web_applications/extensions/system_web_app_manager_browsertest.cc
+++ b/chrome/browser/web_applications/extensions/system_web_app_manager_browsertest.cc
@@ -82,7 +82,7 @@
}),
base::BindRepeating(
[](const std::string& id,
- const content::WebUIDataSource::GotDataCallback& callback) {
+ content::WebUIDataSource::GotDataCallback callback) {
scoped_refptr<base::RefCountedString> ref_contents(
new base::RefCountedString);
if (id == "manifest.json")
@@ -92,7 +92,7 @@
else
NOTREACHED();
- callback.Run(ref_contents);
+ std::move(callback).Run(ref_contents);
}));
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
data_source);
diff --git a/chrome/test/base/web_ui_browser_test.cc b/chrome/test/base/web_ui_browser_test.cc
index e404704..0341a0d 100644
--- a/chrome/test/base/web_ui_browser_test.cc
+++ b/chrome/test/base/web_ui_browser_test.cc
@@ -347,9 +347,6 @@
#endif
}
-const std::string BaseWebUIBrowserTest::kDummyURL =
- content::GetWebUIURLString("DummyURL");
-
BaseWebUIBrowserTest::BaseWebUIBrowserTest()
: libraries_preloaded_(false), override_selected_web_ui_(nullptr) {}
@@ -369,6 +366,11 @@
namespace {
+const GURL& DummyUrl() {
+ static GURL url(content::GetWebUIURLString("DummyURL"));
+ return url;
+}
+
// DataSource for the dummy URL. If no data source is provided then an error
// page is shown. While this doesn't matter for most tests, without it,
// navigation to different anchors cannot be listened to (via the hashchange
@@ -384,11 +386,11 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override {
+ content::URLDataSource::GotDataCallback callback) override {
std::string dummy_html = "<html><body>Dummy</body></html>";
scoped_refptr<base::RefCountedString> response =
base::RefCountedString::TakeString(&dummy_html);
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
std::string GetMimeType(const std::string& path) override {
@@ -450,7 +452,7 @@
content::WebUIControllerFactory::RegisterFactory(test_factory_.get());
- test_factory_->AddFactoryOverride(GURL(kDummyURL).host(),
+ test_factory_->AddFactoryOverride(DummyUrl().host(),
mock_provider_.Pointer());
test_factory_->AddFactoryOverride(content::kChromeUIResourcesHost,
mock_provider_.Pointer());
@@ -459,7 +461,7 @@
void BaseWebUIBrowserTest::TearDownOnMainThread() {
logging::SetLogMessageHandler(nullptr);
- test_factory_->RemoveFactoryOverride(GURL(kDummyURL).host());
+ test_factory_->RemoveFactoryOverride(DummyUrl().host());
content::WebUIControllerFactory::UnregisterFactoryForTesting(
test_factory_.get());
diff --git a/chrome/test/base/web_ui_browser_test_browsertest.cc b/chrome/test/base/web_ui_browser_test_browsertest.cc
index dcbcfc10..b1a7abf 100644
--- a/chrome/test/base/web_ui_browser_test_browsertest.cc
+++ b/chrome/test/base/web_ui_browser_test_browsertest.cc
@@ -21,6 +21,13 @@
using content::WebUIMessageHandler;
+namespace {
+const GURL& DummyUrl() {
+ static GURL url(content::GetWebUIURLString("DummyURL"));
+ return url;
+}
+} // namespace
+
// According to the interface for EXPECT_FATAL_FAILURE
// (https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#catching-failures)
// the statement must be statically available. Therefore, we make a static
@@ -79,7 +86,7 @@
IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest,
MAYBE_TestRuntimeErrorFailsFast) {
AddLibrary(base::FilePath(FILE_PATH_LITERAL("runtime_error.js")));
- ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL));
+ ui_test_utils::NavigateToURL(browser(), DummyUrl());
EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("TestRuntimeErrorFailsFast"),
"GetAsBoolean(&run_test_succeeded_)");
}
@@ -170,11 +177,11 @@
return &message_handler_;
}
- // Set up and browse to kDummyURL for all tests.
+ // Set up and browse to DummyUrl() for all tests.
void SetUpOnMainThread() override {
WebUIBrowserTest::SetUpOnMainThread();
AddLibrary(base::FilePath(FILE_PATH_LITERAL("async.js")));
- ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL));
+ ui_test_utils::NavigateToURL(browser(), DummyUrl());
}
DISALLOW_COPY_AND_ASSIGN(WebUIBrowserAsyncTest);
diff --git a/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc b/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
index 6f57f7b4..f82ccdb 100644
--- a/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
+++ b/components/dom_distiller/content/browser/dom_distiller_viewer_source.cc
@@ -206,7 +206,7 @@
void DomDistillerViewerSource::StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
+ content::URLDataSource::GotDataCallback callback) {
// TODO(crbug/1009127): simplify path matching.
const std::string path = URLDataSource::URLToRequestPath(url);
content::WebContents* web_contents = wc_getter.Run();
@@ -214,12 +214,12 @@
return;
if (kViewerCssPath == path) {
std::string css = viewer::GetCss();
- callback.Run(base::RefCountedString::TakeString(&css));
+ std::move(callback).Run(base::RefCountedString::TakeString(&css));
return;
}
if (kViewerLoadingImagePath == path) {
std::string image = viewer::GetLoadingImage();
- callback.Run(base::RefCountedString::TakeString(&image));
+ std::move(callback).Run(base::RefCountedString::TakeString(&image));
return;
}
if (base::StartsWith(path, kViewerSaveFontScalingPath,
@@ -267,7 +267,8 @@
}
// Place template on the page.
- callback.Run(base::RefCountedString::TakeString(&unsafe_page_html));
+ std::move(callback).Run(
+ base::RefCountedString::TakeString(&unsafe_page_html));
}
std::string DomDistillerViewerSource::GetMimeType(const std::string& path) {
diff --git a/components/dom_distiller/content/browser/dom_distiller_viewer_source.h b/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
index f011c182..0e1e660 100644
--- a/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
+++ b/components/dom_distiller/content/browser/dom_distiller_viewer_source.h
@@ -32,7 +32,7 @@
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
+ content::URLDataSource::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) override;
bool ShouldServiceRequest(const GURL& url,
content::ResourceContext* resource_context,
diff --git a/components/feedback/tracing_manager.cc b/components/feedback/tracing_manager.cc
index d440735..eb5fba1 100644
--- a/components/feedback/tracing_manager.cc
+++ b/components/feedback/tracing_manager.cc
@@ -48,13 +48,13 @@
return current_trace_id_;
}
-bool TracingManager::GetTraceData(int id, const TraceDataCallback& callback) {
+bool TracingManager::GetTraceData(int id, TraceDataCallback callback) {
// If a trace is being collected currently, send it via callback when
// complete.
if (current_trace_id_) {
// Only allow one trace data request at a time.
- if (trace_callback_.is_null()) {
- trace_callback_ = callback;
+ if (!trace_callback_) {
+ trace_callback_ = std::move(callback);
return true;
} else {
return false;
@@ -66,7 +66,7 @@
// Always return the data asychronously, so the behavior is consistant.
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(callback, data->second));
+ FROM_HERE, base::BindOnce(std::move(callback), data->second));
return true;
}
}
@@ -79,10 +79,8 @@
current_trace_id_ = 0;
// If the trace has already been requested, provide an empty string.
- if (!trace_callback_.is_null()) {
- trace_callback_.Run(scoped_refptr<base::RefCountedString>());
- trace_callback_.Reset();
- }
+ if (trace_callback_)
+ std::move(trace_callback_).Run(scoped_refptr<base::RefCountedString>());
}
}
@@ -106,10 +104,8 @@
trace_data_[current_trace_id_] = output;
- if (!trace_callback_.is_null()) {
- trace_callback_.Run(output);
- trace_callback_.Reset();
- }
+ if (trace_callback_)
+ std::move(trace_callback_).Run(output);
current_trace_id_ = 0;
diff --git a/components/feedback/tracing_manager.h b/components/feedback/tracing_manager.h
index 10d9f41..8238fc4 100644
--- a/components/feedback/tracing_manager.h
+++ b/components/feedback/tracing_manager.h
@@ -20,8 +20,8 @@
}
// Callback used for getting the output of a trace.
-typedef base::Callback<void(scoped_refptr<base::RefCountedString> trace_data)>
- TraceDataCallback;
+using TraceDataCallback =
+ base::OnceCallback<void(scoped_refptr<base::RefCountedString> trace_data)>;
// This class is used to manage performance metrics that can be attached to
// feedback reports. This class is a Singleton that is owned by the preference
@@ -49,7 +49,7 @@
// Get the trace data for |id|. On success, true is returned, and the data is
// returned via |callback|. Returns false on failure.
- bool GetTraceData(int id, const TraceDataCallback& callback);
+ bool GetTraceData(int id, TraceDataCallback callback);
// Discard the data for trace |id|.
void DiscardTraceData(int id);
diff --git a/components/gcm_driver/fake_gcm_driver.cc b/components/gcm_driver/fake_gcm_driver.cc
index a05cf96d..eab1b9f 100644
--- a/components/gcm_driver/fake_gcm_driver.cc
+++ b/components/gcm_driver/fake_gcm_driver.cc
@@ -34,9 +34,9 @@
const std::string& app_id,
const std::vector<std::string>& sender_ids,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback) {
+ ValidateRegistrationCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(callback, true /* is_valid */));
+ FROM_HERE, base::BindOnce(std::move(callback), true /* is_valid */));
}
void FakeGCMDriver::OnSignedIn() {
diff --git a/components/gcm_driver/fake_gcm_driver.h b/components/gcm_driver/fake_gcm_driver.h
index cc1a9d90..e0108c10 100644
--- a/components/gcm_driver/fake_gcm_driver.h
+++ b/components/gcm_driver/fake_gcm_driver.h
@@ -26,11 +26,10 @@
~FakeGCMDriver() override;
// GCMDriver overrides:
- void ValidateRegistration(
- const std::string& app_id,
- const std::vector<std::string>& sender_ids,
- const std::string& registration_id,
- const ValidateRegistrationCallback& callback) override;
+ void ValidateRegistration(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const std::string& registration_id,
+ ValidateRegistrationCallback callback) override;
void OnSignedIn() override;
void OnSignedOut() override;
void AddConnectionObserver(GCMConnectionObserver* observer) override;
diff --git a/components/gcm_driver/gcm_driver.h b/components/gcm_driver/gcm_driver.h
index d924670..8189cc1 100644
--- a/components/gcm_driver/gcm_driver.h
+++ b/components/gcm_driver/gcm_driver.h
@@ -44,7 +44,7 @@
public:
using GetTokenCallback = base::OnceCallback<void(const std::string& token,
GCMClient::Result result)>;
- using ValidateTokenCallback = base::Callback<void(bool is_valid)>;
+ using ValidateTokenCallback = base::OnceCallback<void(bool is_valid)>;
using DeleteTokenCallback =
base::OnceCallback<void(GCMClient::Result result)>;
using GetInstanceIDDataCallback =
@@ -64,7 +64,7 @@
const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) = 0;
+ ValidateTokenCallback callback) = 0;
virtual void DeleteToken(const std::string& app_id,
const std::string& authorized_entity,
const std::string& scope,
@@ -95,7 +95,7 @@
using RegisterCallback =
base::OnceCallback<void(const std::string& registration_id,
GCMClient::Result result)>;
- using ValidateRegistrationCallback = base::Callback<void(bool is_valid)>;
+ using ValidateRegistrationCallback = base::OnceCallback<void(bool is_valid)>;
using UnregisterCallback = base::OnceCallback<void(GCMClient::Result result)>;
using SendCallback = base::Callback<void(const std::string& message_id,
GCMClient::Result result)>;
@@ -131,11 +131,10 @@
// Checks that the provided |sender_ids| and |registration_id| matches the
// stored registration info for |app_id|.
- virtual void ValidateRegistration(
- const std::string& app_id,
- const std::vector<std::string>& sender_ids,
- const std::string& registration_id,
- const ValidateRegistrationCallback& callback) = 0;
+ virtual void ValidateRegistration(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const std::string& registration_id,
+ ValidateRegistrationCallback callback) = 0;
// Unregisters all sender_ids for an app. Only works on non-Android. Will also
// remove any encryption keys associated with the |app_id|.
diff --git a/components/gcm_driver/gcm_driver_android.cc b/components/gcm_driver/gcm_driver_android.cc
index 9738d1c9..bdf23058 100644
--- a/components/gcm_driver/gcm_driver_android.cc
+++ b/components/gcm_driver/gcm_driver_android.cc
@@ -119,10 +119,10 @@
const std::string& app_id,
const std::vector<std::string>& sender_ids,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback) {
+ ValidateRegistrationCallback callback) {
// gcm_driver doesn't store registration IDs on Android, so assume it's valid.
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(callback, true /* is_valid */));
+ FROM_HERE, base::BindOnce(std::move(callback), true /* is_valid */));
}
void GCMDriverAndroid::OnSignedIn() {
diff --git a/components/gcm_driver/gcm_driver_android.h b/components/gcm_driver/gcm_driver_android.h
index 99176b8..b52baed 100644
--- a/components/gcm_driver/gcm_driver_android.h
+++ b/components/gcm_driver/gcm_driver_android.h
@@ -58,11 +58,10 @@
const base::android::JavaParamRef<jobjectArray>& data_keys_and_values);
// GCMDriver implementation:
- void ValidateRegistration(
- const std::string& app_id,
- const std::vector<std::string>& sender_ids,
- const std::string& registration_id,
- const ValidateRegistrationCallback& callback) override;
+ void ValidateRegistration(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const std::string& registration_id,
+ ValidateRegistrationCallback callback) override;
void OnSignedIn() override;
void OnSignedOut() override;
void Enable() override;
diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc
index 6061918..f674e07 100644
--- a/components/gcm_driver/gcm_driver_desktop.cc
+++ b/components/gcm_driver/gcm_driver_desktop.cc
@@ -563,7 +563,7 @@
const std::string& app_id,
const std::vector<std::string>& sender_ids,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback) {
+ ValidateRegistrationCallback callback) {
DCHECK(!app_id.empty());
DCHECK(!sender_ids.empty() && sender_ids.size() <= kMaxSenders);
DCHECK(!registration_id.empty());
@@ -586,25 +586,27 @@
std::sort(gcm_info->sender_ids.begin(), gcm_info->sender_ids.end());
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
- delayed_task_controller_->AddTask(base::Bind(
- &GCMDriverDesktop::DoValidateRegistration,
- weak_ptr_factory_.GetWeakPtr(), gcm_info, registration_id, callback));
+ delayed_task_controller_->AddTask(
+ base::BindOnce(&GCMDriverDesktop::DoValidateRegistration,
+ weak_ptr_factory_.GetWeakPtr(), gcm_info,
+ registration_id, std::move(callback)));
return;
}
- DoValidateRegistration(std::move(gcm_info), registration_id, callback);
+ DoValidateRegistration(std::move(gcm_info), registration_id,
+ std::move(callback));
}
void GCMDriverDesktop::DoValidateRegistration(
scoped_refptr<RegistrationInfo> registration_info,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback) {
+ ValidateRegistrationCallback callback) {
base::PostTaskAndReplyWithResult(
io_thread_.get(), FROM_HERE,
- base::Bind(&GCMDriverDesktop::IOWorker::ValidateRegistration,
- base::Unretained(io_worker_.get()),
- std::move(registration_info), registration_id),
- callback);
+ base::BindOnce(&GCMDriverDesktop::IOWorker::ValidateRegistration,
+ base::Unretained(io_worker_.get()),
+ std::move(registration_info), registration_id),
+ std::move(callback));
}
void GCMDriverDesktop::Shutdown() {
@@ -928,12 +930,12 @@
const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) {
+ ValidateTokenCallback callback) {
DCHECK(!app_id.empty());
DCHECK(!authorized_entity.empty());
DCHECK(!scope.empty());
DCHECK(!token.empty());
- DCHECK(!callback.is_null());
+ DCHECK(callback);
DCHECK(ui_thread_->RunsTasksInCurrentSequence());
GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START);
@@ -953,13 +955,15 @@
instance_id_info->scope = scope;
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
- delayed_task_controller_->AddTask(base::Bind(
- &GCMDriverDesktop::DoValidateRegistration,
- weak_ptr_factory_.GetWeakPtr(), instance_id_info, token, callback));
+ delayed_task_controller_->AddTask(
+ base::BindOnce(&GCMDriverDesktop::DoValidateRegistration,
+ weak_ptr_factory_.GetWeakPtr(), instance_id_info, token,
+ std::move(callback)));
return;
}
- DoValidateRegistration(std::move(instance_id_info), token, callback);
+ DoValidateRegistration(std::move(instance_id_info), token,
+ std::move(callback));
}
void GCMDriverDesktop::DeleteToken(const std::string& app_id,
@@ -993,12 +997,9 @@
// Delay the DeleteToken operation until GCMClient is ready.
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
- delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::DoDeleteToken,
- weak_ptr_factory_.GetWeakPtr(),
- app_id,
- authorized_entity,
- scope));
+ delayed_task_controller_->AddTask(base::BindOnce(
+ &GCMDriverDesktop::DoDeleteToken, weak_ptr_factory_.GetWeakPtr(),
+ app_id, authorized_entity, scope));
return;
}
@@ -1031,12 +1032,9 @@
// Delay the operation until GCMClient is ready.
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
- delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::DoAddInstanceIDData,
- weak_ptr_factory_.GetWeakPtr(),
- app_id,
- instance_id,
- extra_data));
+ delayed_task_controller_->AddTask(base::BindOnce(
+ &GCMDriverDesktop::DoAddInstanceIDData, weak_ptr_factory_.GetWeakPtr(),
+ app_id, instance_id, extra_data));
return;
}
@@ -1066,9 +1064,8 @@
// Delay the operation until GCMClient is ready.
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::DoRemoveInstanceIDData,
- weak_ptr_factory_.GetWeakPtr(),
- app_id));
+ base::BindOnce(&GCMDriverDesktop::DoRemoveInstanceIDData,
+ weak_ptr_factory_.GetWeakPtr(), app_id));
return;
}
@@ -1110,9 +1107,8 @@
// Delay the operation until GCMClient is ready.
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::DoGetInstanceIDData,
- weak_ptr_factory_.GetWeakPtr(),
- app_id));
+ base::BindOnce(&GCMDriverDesktop::DoGetInstanceIDData,
+ weak_ptr_factory_.GetWeakPtr(), app_id));
return;
}
@@ -1178,10 +1174,9 @@
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
// The GCM service was initialized but has not started yet.
- delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::WakeFromSuspendForHeartbeat,
- weak_ptr_factory_.GetWeakPtr(),
- wake_from_suspend_enabled_));
+ delayed_task_controller_->AddTask(base::BindOnce(
+ &GCMDriverDesktop::WakeFromSuspendForHeartbeat,
+ weak_ptr_factory_.GetWeakPtr(), wake_from_suspend_enabled_));
return;
}
@@ -1205,8 +1200,8 @@
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
// The GCM service was initialized but has not started yet.
delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::AddHeartbeatInterval,
- weak_ptr_factory_.GetWeakPtr(), scope, interval_ms));
+ base::BindOnce(&GCMDriverDesktop::AddHeartbeatInterval,
+ weak_ptr_factory_.GetWeakPtr(), scope, interval_ms));
return;
}
@@ -1226,8 +1221,8 @@
if (!delayed_task_controller_->CanRunTaskWithoutDelay()) {
// The GCM service was initialized but has not started yet.
delayed_task_controller_->AddTask(
- base::Bind(&GCMDriverDesktop::RemoveHeartbeatInterval,
- weak_ptr_factory_.GetWeakPtr(), scope));
+ base::BindOnce(&GCMDriverDesktop::RemoveHeartbeatInterval,
+ weak_ptr_factory_.GetWeakPtr(), scope));
return;
}
diff --git a/components/gcm_driver/gcm_driver_desktop.h b/components/gcm_driver/gcm_driver_desktop.h
index ce3e46c69..6b8d681 100644
--- a/components/gcm_driver/gcm_driver_desktop.h
+++ b/components/gcm_driver/gcm_driver_desktop.h
@@ -67,11 +67,10 @@
~GCMDriverDesktop() override;
// GCMDriver implementation:
- void ValidateRegistration(
- const std::string& app_id,
- const std::vector<std::string>& sender_ids,
- const std::string& registration_id,
- const ValidateRegistrationCallback& callback) override;
+ void ValidateRegistration(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const std::string& registration_id,
+ ValidateRegistrationCallback callback) override;
void Shutdown() override;
void OnSignedIn() override;
void OnSignedOut() override;
@@ -128,7 +127,7 @@
const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override;
+ ValidateTokenCallback callback) override;
void DeleteToken(const std::string& app_id,
const std::string& authorized_entity,
const std::string& scope,
@@ -150,7 +149,7 @@
void DoValidateRegistration(scoped_refptr<RegistrationInfo> registration_info,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback);
+ ValidateRegistrationCallback callback);
// Stops the GCM service. It can be restarted by calling EnsureStarted again.
void Stop();
diff --git a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
index f704b3e..84fd234 100644
--- a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
+++ b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
@@ -85,9 +85,9 @@
const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) {
+ ValidateTokenCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(callback, true /* is_valid */));
+ FROM_HERE, base::BindOnce(std::move(callback), true /* is_valid */));
}
void FakeGCMDriverForInstanceID::DeleteToken(
diff --git a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h
index ff428511..c9eb421 100644
--- a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h
+++ b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h
@@ -51,7 +51,7 @@
const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override;
+ ValidateTokenCallback callback) override;
void DeleteToken(const std::string& app_id,
const std::string& authorized_entity,
const std::string& scope,
diff --git a/components/gcm_driver/instance_id/instance_id.h b/components/gcm_driver/instance_id/instance_id.h
index e9e3be48..628fe9e 100644
--- a/components/gcm_driver/instance_id/instance_id.h
+++ b/components/gcm_driver/instance_id/instance_id.h
@@ -71,7 +71,7 @@
base::Callback<void(const base::Time& creation_time)>;
using GetTokenCallback =
base::OnceCallback<void(const std::string& token, Result result)>;
- using ValidateTokenCallback = base::Callback<void(bool is_valid)>;
+ using ValidateTokenCallback = base::OnceCallback<void(bool is_valid)>;
using GetEncryptionInfoCallback =
base::OnceCallback<void(std::string p256dh, std::string auth_secret)>;
using DeleteTokenCallback = base::OnceCallback<void(Result result)>;
@@ -121,7 +121,7 @@
virtual void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) = 0;
+ ValidateTokenCallback callback) = 0;
// Get the public encryption key and authentication secret associated with a
// GCM-scoped token. If encryption info is not yet associated, it will be
diff --git a/components/gcm_driver/instance_id/instance_id_android.cc b/components/gcm_driver/instance_id/instance_id_android.cc
index 065aa4f..ee25207 100644
--- a/components/gcm_driver/instance_id/instance_id_android.cc
+++ b/components/gcm_driver/instance_id/instance_id_android.cc
@@ -125,10 +125,10 @@
void InstanceIDAndroid::ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) {
+ ValidateTokenCallback callback) {
// gcm_driver doesn't store tokens on Android, so assume it's valid.
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(callback, true /* is_valid */));
+ FROM_HERE, base::BindOnce(std::move(callback), true /* is_valid */));
}
void InstanceIDAndroid::DeleteTokenImpl(const std::string& authorized_entity,
diff --git a/components/gcm_driver/instance_id/instance_id_android.h b/components/gcm_driver/instance_id/instance_id_android.h
index ede64fd..89d8a189 100644
--- a/components/gcm_driver/instance_id/instance_id_android.h
+++ b/components/gcm_driver/instance_id/instance_id_android.h
@@ -51,7 +51,7 @@
void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override;
+ ValidateTokenCallback callback) override;
void DeleteTokenImpl(const std::string& audience,
const std::string& scope,
DeleteTokenCallback callback) override;
diff --git a/components/gcm_driver/instance_id/instance_id_impl.cc b/components/gcm_driver/instance_id/instance_id_impl.cc
index 6723fb0..b7f7e27 100644
--- a/components/gcm_driver/instance_id/instance_id_impl.cc
+++ b/components/gcm_driver/instance_id/instance_id_impl.cc
@@ -118,26 +118,27 @@
void InstanceIDImpl::ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) {
+ ValidateTokenCallback callback) {
DCHECK(!authorized_entity.empty());
DCHECK(!scope.empty());
DCHECK(!token.empty());
RunWhenReady(base::BindOnce(&InstanceIDImpl::DoValidateToken,
weak_ptr_factory_.GetWeakPtr(), authorized_entity,
- scope, token, callback));
+ scope, token, std::move(callback)));
}
void InstanceIDImpl::DoValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) {
+ ValidateTokenCallback callback) {
if (id_.empty()) {
- callback.Run(false /* is_valid */);
+ std::move(callback).Run(false /* is_valid */);
return;
}
- Handler()->ValidateToken(app_id(), authorized_entity, scope, token, callback);
+ Handler()->ValidateToken(app_id(), authorized_entity, scope, token,
+ std::move(callback));
}
void InstanceIDImpl::DeleteTokenImpl(const std::string& authorized_entity,
diff --git a/components/gcm_driver/instance_id/instance_id_impl.h b/components/gcm_driver/instance_id/instance_id_impl.h
index 5698718..580d3a7 100644
--- a/components/gcm_driver/instance_id/instance_id_impl.h
+++ b/components/gcm_driver/instance_id/instance_id_impl.h
@@ -41,7 +41,7 @@
void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback) override;
+ ValidateTokenCallback callback) override;
void DeleteTokenImpl(const std::string& authorized_entity,
const std::string& scope,
DeleteTokenCallback callback) override;
@@ -69,7 +69,7 @@
void DoValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback);
+ ValidateTokenCallback callback);
void DoDeleteToken(const std::string& authorized_entity,
const std::string& scope,
DeleteTokenCallback callback);
diff --git a/components/invalidation/impl/fcm_invalidation_service_unittest.cc b/components/invalidation/impl/fcm_invalidation_service_unittest.cc
index 8d69b328f..f8047c0 100644
--- a/components/invalidation/impl/fcm_invalidation_service_unittest.cc
+++ b/components/invalidation/impl/fcm_invalidation_service_unittest.cc
@@ -103,11 +103,17 @@
const std::map<std::string, std::string>& options,
std::set<Flags> flags,
GetTokenCallback& callback));
- MOCK_METHOD4(ValidateToken,
+ void ValidateToken(const std::string& authorized_entity,
+ const std::string& scope,
+ const std::string& token,
+ ValidateTokenCallback callback) override {
+ ValidateToken_(authorized_entity, scope, token, callback);
+ }
+ MOCK_METHOD4(ValidateToken_,
void(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback));
+ ValidateTokenCallback& callback));
protected:
void DeleteTokenImpl(const std::string& authorized_entity,
diff --git a/components/invalidation/impl/fcm_network_handler_unittests.cc b/components/invalidation/impl/fcm_network_handler_unittests.cc
index bcdb759..78458092 100644
--- a/components/invalidation/impl/fcm_network_handler_unittests.cc
+++ b/components/invalidation/impl/fcm_network_handler_unittests.cc
@@ -77,11 +77,17 @@
const std::map<std::string, std::string>& options,
std::set<Flags> flags,
GetTokenCallback& callback));
- MOCK_METHOD4(ValidateToken,
+ void ValidateToken(const std::string& authorized_entity,
+ const std::string& scope,
+ const std::string& token,
+ ValidateTokenCallback callback) override {
+ ValidateToken_(authorized_entity, scope, token, callback);
+ }
+ MOCK_METHOD4(ValidateToken_,
void(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
- const ValidateTokenCallback& callback));
+ ValidateTokenCallback& callback));
protected:
void DeleteTokenImpl(const std::string& authorized_entity,
@@ -112,11 +118,17 @@
&test_url_loader_factory_)) {}
~MockGCMDriver() override = default;
- MOCK_METHOD4(ValidateRegistration,
+ void ValidateRegistration(const std::string& app_id,
+ const std::vector<std::string>& sender_ids,
+ const std::string& registration_id,
+ ValidateRegistrationCallback callback) override {
+ ValidateRegistration_(app_id, sender_ids, registration_id, callback);
+ }
+ MOCK_METHOD4(ValidateRegistration_,
void(const std::string& app_id,
const std::vector<std::string>& sender_ids,
const std::string& registration_id,
- const ValidateRegistrationCallback& callback));
+ ValidateRegistrationCallback& callback));
MOCK_METHOD0(OnSignedIn, void());
MOCK_METHOD0(OnSignedOut, void());
MOCK_METHOD1(AddConnectionObserver,
@@ -438,7 +450,7 @@
EXPECT_CALL(*mock_instance_id(), GetToken_(_, _, _, _, _))
.WillOnce(
InvokeCallbackArgument<4>("token", InstanceID::Result::SUCCESS));
- EXPECT_CALL(*mock_instance_id(), ValidateToken(_, _, _, _)).Times(0);
+ EXPECT_CALL(*mock_instance_id(), ValidateToken_(_, _, _, _)).Times(0);
EXPECT_CALL(mock_on_token_callback, Run("token")).Times(1);
handler->StartListening();
testing::Mock::VerifyAndClearExpectations(mock_instance_id());
@@ -469,7 +481,7 @@
EXPECT_CALL(*mock_instance_id(), GetToken_(_, _, _, _, _))
.WillOnce(
InvokeCallbackArgument<4>("token", InstanceID::Result::SUCCESS));
- EXPECT_CALL(*mock_instance_id(), ValidateToken(_, _, _, _)).Times(0);
+ EXPECT_CALL(*mock_instance_id(), ValidateToken_(_, _, _, _)).Times(0);
EXPECT_CALL(mock_on_token_callback, Run("token")).Times(1);
handler->StartListening();
testing::Mock::VerifyAndClearExpectations(mock_instance_id());
diff --git a/content/browser/indexed_db/indexed_db_blob_info.cc b/content/browser/indexed_db/indexed_db_blob_info.cc
index 64d6ccb..d96dd372 100644
--- a/content/browser/indexed_db/indexed_db_blob_info.cc
+++ b/content/browser/indexed_db/indexed_db_blob_info.cc
@@ -105,15 +105,15 @@
}
void IndexedDBBlobInfo::set_mark_used_callback(
- const base::Closure& mark_used_callback) {
- DCHECK(mark_used_callback_.is_null());
- mark_used_callback_ = mark_used_callback;
+ base::RepeatingClosure mark_used_callback) {
+ DCHECK(!mark_used_callback_);
+ mark_used_callback_ = std::move(mark_used_callback);
}
void IndexedDBBlobInfo::set_release_callback(
- const base::RepeatingClosure& release_callback) {
- DCHECK(release_callback_.is_null());
- release_callback_ = release_callback;
+ base::RepeatingClosure release_callback) {
+ DCHECK(!release_callback_);
+ release_callback_ = std::move(release_callback);
}
} // namespace content
diff --git a/content/browser/indexed_db/indexed_db_blob_info.h b/content/browser/indexed_db/indexed_db_blob_info.h
index 126c1d5..64be7db 100644
--- a/content/browser/indexed_db/indexed_db_blob_info.h
+++ b/content/browser/indexed_db/indexed_db_blob_info.h
@@ -68,8 +68,8 @@
void set_file_path(const base::FilePath& file_path);
void set_last_modified(const base::Time& time);
void set_key(int64_t key);
- void set_mark_used_callback(const base::RepeatingClosure& mark_used_callback);
- void set_release_callback(const base::RepeatingClosure& release_callback);
+ void set_mark_used_callback(base::RepeatingClosure mark_used_callback);
+ void set_release_callback(base::RepeatingClosure release_callback);
private:
bool is_file_;
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host_unittest.cc b/content/browser/indexed_db/indexed_db_dispatcher_host_unittest.cc
index c255a684..674e2f8 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host_unittest.cc
@@ -14,6 +14,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
+#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread.h"
@@ -43,6 +44,7 @@
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
#include "url/origin.h"
+using base::test::RunClosure;
using blink::IndexedDBDatabaseMetadata;
using blink::IndexedDBIndexKeys;
using blink::IndexedDBKey;
@@ -65,10 +67,6 @@
*out = std::move(*::testing::get<k>(args));
}
-ACTION_P(RunClosure, closure) {
- closure.Run();
-}
-
ACTION_P(QuitLoop, run_loop) {
run_loop->Quit();
}
@@ -84,8 +82,6 @@
return arg.Equals(key);
}
-typedef void (base::Closure::*ClosureRunFcn)() const &;
-
static const char kDatabaseName[] = "db";
static const char kOrigin[] = "https://www.example.com";
static const int kFakeProcessId = 2;
@@ -141,11 +137,11 @@
DISALLOW_COPY_AND_ASSIGN(TestDatabaseConnection);
};
-void StatusCallback(const base::Closure& callback,
+void StatusCallback(base::OnceClosure callback,
blink::mojom::IDBStatus* status_out,
blink::mojom::IDBStatus status) {
*status_out = status;
- callback.Run();
+ std::move(callback).Run();
}
class TestIndexedDBObserver : public IndexedDBContextImpl::Observer {
@@ -1051,7 +1047,8 @@
{
::testing::InSequence dummy;
base::RunLoop loop;
- base::Closure quit_closure = base::BarrierClosure(2, loop.QuitClosure());
+ base::RepeatingClosure quit_closure =
+ base::BarrierClosure(2, loop.QuitClosure());
EXPECT_CALL(*connection1.connection_callbacks, Complete(kTransactionId1))
.Times(1)
@@ -1107,7 +1104,8 @@
{
::testing::InSequence dummy;
base::RunLoop loop;
- base::Closure quit_closure = base::BarrierClosure(2, loop.QuitClosure());
+ base::RepeatingClosure quit_closure =
+ base::BarrierClosure(2, loop.QuitClosure());
EXPECT_CALL(*connection2.connection_callbacks, Complete(kTransactionId2))
.Times(1)
@@ -1159,7 +1157,8 @@
{
::testing::InSequence dummy;
base::RunLoop loop;
- base::Closure quit_closure = base::BarrierClosure(2, loop.QuitClosure());
+ base::RepeatingClosure quit_closure =
+ base::BarrierClosure(2, loop.QuitClosure());
EXPECT_CALL(*connection3.connection_callbacks, Complete(kTransactionId3))
.Times(1)
diff --git a/content/browser/loader/loader_browsertest.cc b/content/browser/loader/loader_browsertest.cc
index 363ce80..39e4516 100644
--- a/content/browser/loader/loader_browsertest.cc
+++ b/content/browser/loader/loader_browsertest.cc
@@ -755,12 +755,12 @@
base::AutoLock auto_lock(requests_lock_);
requests_.push_back(data);
if (requests_closure_)
- requests_closure_.Run();
+ std::move(requests_closure_).Run();
}
base::Lock requests_lock_;
std::vector<RequestData> requests_;
- base::Closure requests_closure_;
+ base::OnceClosure requests_closure_;
std::unique_ptr<URLLoaderInterceptor> interceptor_;
};
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc
index f71df26..3f50c7b 100644
--- a/content/browser/loader/navigation_url_loader_impl.cc
+++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -1137,7 +1137,7 @@
GlobalRequestID global_request_id_;
net::RedirectInfo redirect_info_;
int redirect_limit_ = net::URLRequest::kMaxRedirects;
- base::Callback<WebContents*()> web_contents_getter_;
+ base::RepeatingCallback<WebContents*()> web_contents_getter_;
std::unique_ptr<NavigationUIData> navigation_ui_data_;
scoped_refptr<network::SharedURLLoaderFactory> network_loader_factory_;
diff --git a/content/browser/net/network_errors_listing_ui.cc b/content/browser/net/network_errors_listing_ui.cc
index df437d5..9f731d8 100644
--- a/content/browser/net/network_errors_listing_ui.cc
+++ b/content/browser/net/network_errors_listing_ui.cc
@@ -61,17 +61,16 @@
return path == kNetworkErrorDataFile;
}
-void HandleWebUIRequestCallback(
- BrowserContext* current_context,
- const std::string& path,
- const WebUIDataSource::GotDataCallback& callback) {
+void HandleWebUIRequestCallback(BrowserContext* current_context,
+ const std::string& path,
+ WebUIDataSource::GotDataCallback callback) {
DCHECK(ShouldHandleWebUIRequestCallback(path));
base::DictionaryValue data;
data.Set(kErrorCodesDataName, GetNetworkErrorData());
std::string json_string;
base::JSONWriter::Write(data, &json_string);
- callback.Run(base::RefCountedString::TakeString(&json_string));
+ std::move(callback).Run(base::RefCountedString::TakeString(&json_string));
}
} // namespace
diff --git a/content/browser/network_service_browsertest.cc b/content/browser/network_service_browsertest.cc
index dddc660..edded212 100644
--- a/content/browser/network_service_browsertest.cc
+++ b/content/browser/network_service_browsertest.cc
@@ -79,14 +79,13 @@
std::string GetSource() override { return "webui"; }
- void StartDataRequest(
- const GURL& url,
- const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback) override {
+ void StartDataRequest(const GURL& url,
+ const WebContents::Getter& wc_getter,
+ URLDataSource::GotDataCallback callback) override {
std::string dummy_html = "<html><body>Foo</body></html>";
scoped_refptr<base::RefCountedString> response =
base::RefCountedString::TakeString(&dummy_html);
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
std::string GetMimeType(const std::string& path) override {
diff --git a/content/browser/notifications/notification_storage_unittest.cc b/content/browser/notifications/notification_storage_unittest.cc
index 6f3c14e..2bdf7bd 100644
--- a/content/browser/notifications/notification_storage_unittest.cc
+++ b/content/browser/notifications/notification_storage_unittest.cc
@@ -118,7 +118,7 @@
void WriteNotificationDataSynchronous(const NotificationDatabaseData& data) {
base::RunLoop run_loop;
storage_->WriteNotificationData(
- data, base::Bind(
+ data, base::BindOnce(
&NotificationStorageTest::DidWriteNotificationDataSynchronous,
base::Unretained(this), run_loop.QuitClosure()));
run_loop.Run();
@@ -140,9 +140,10 @@
base::RunLoop run_loop;
storage_->ReadNotificationDataAndRecordInteraction(
service_worker_registration_id, notification_id, interaction,
- base::Bind(&NotificationStorageTest::
- DidReadNotificationDataAndRecordInteractionSynchronous,
- base::Unretained(this), run_loop.QuitClosure()));
+ base::BindOnce(
+ &NotificationStorageTest::
+ DidReadNotificationDataAndRecordInteractionSynchronous,
+ base::Unretained(this), run_loop.QuitClosure()));
run_loop.Run();
return out_data_;
}
diff --git a/content/browser/payments/payment_app_browsertest.cc b/content/browser/payments/payment_app_browsertest.cc
index 1b9c703f..d0c7e45 100644
--- a/content/browser/payments/payment_app_browsertest.cc
+++ b/content/browser/payments/payment_app_browsertest.cc
@@ -34,25 +34,25 @@
using ::payments::mojom::PaymentRequestEventData;
using ::payments::mojom::PaymentRequestEventDataPtr;
-void GetAllPaymentAppsCallback(const base::Closure& done_callback,
+void GetAllPaymentAppsCallback(base::OnceClosure done_callback,
PaymentAppProvider::PaymentApps* out_apps,
PaymentAppProvider::PaymentApps apps) {
*out_apps = std::move(apps);
- done_callback.Run();
+ std::move(done_callback).Run();
}
-void PaymentEventResultCallback(const base::Closure& done_callback,
+void PaymentEventResultCallback(base::OnceClosure done_callback,
bool* out_payment_event_result,
bool payment_event_result) {
*out_payment_event_result = payment_event_result;
- done_callback.Run();
+ std::move(done_callback).Run();
}
-void InvokePaymentAppCallback(const base::Closure& done_callback,
+void InvokePaymentAppCallback(base::OnceClosure done_callback,
PaymentHandlerResponsePtr* out_response,
PaymentHandlerResponsePtr response) {
*out_response = std::move(response);
- done_callback.Run();
+ std::move(done_callback).Run();
}
} // namespace
diff --git a/content/browser/payments/payment_app_installer.cc b/content/browser/payments/payment_app_installer.cc
index 7d5827e..0e4d4941 100644
--- a/content/browser/payments/payment_app_installer.cc
+++ b/content/browser/payments/payment_app_installer.cc
@@ -64,9 +64,11 @@
->GetServiceWorkerContext());
service_worker_watcher_ = new ServiceWorkerContextWatcher(
service_worker_context,
- base::Bind(&SelfDeleteInstaller::onServiceWorkerRegistration, this),
- base::Bind(&SelfDeleteInstaller::onServiceWorkerVersionUpdate, this),
- base::Bind(&SelfDeleteInstaller::onServiceWorkerError, this));
+ base::BindRepeating(&SelfDeleteInstaller::OnServiceWorkerRegistration,
+ this),
+ base::BindRepeating(&SelfDeleteInstaller::OnServiceWorkerVersionUpdate,
+ this),
+ base::BindRepeating(&SelfDeleteInstaller::OnServiceWorkerError, this));
service_worker_watcher_->Start();
blink::mojom::ServiceWorkerRegistrationOptions option;
@@ -81,7 +83,7 @@
this));
}
- void onServiceWorkerRegistration(
+ void OnServiceWorkerRegistration(
const std::vector<ServiceWorkerRegistrationInfo>& info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -91,7 +93,7 @@
}
}
- void onServiceWorkerVersionUpdate(
+ void OnServiceWorkerVersionUpdate(
const std::vector<ServiceWorkerVersionInfo>& info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -104,7 +106,7 @@
}
}
- void onServiceWorkerError(
+ void OnServiceWorkerError(
int64_t registration_id,
int64_t version_id,
const ServiceWorkerContextCoreObserver::ErrorInfo& error_info) {
diff --git a/content/browser/permissions/permission_controller_impl_unittest.cc b/content/browser/permissions/permission_controller_impl_unittest.cc
index 2685e749..571e4d8 100644
--- a/content/browser/permissions/permission_controller_impl_unittest.cc
+++ b/content/browser/permissions/permission_controller_impl_unittest.cc
@@ -300,7 +300,7 @@
TEST_F(PermissionControllerImplTest,
NotifyChangedSubscriptionsCallsOnChangeOnly) {
using PermissionStatusCallback =
- base::Callback<void(blink::mojom::PermissionStatus)>;
+ base::RepeatingCallback<void(blink::mojom::PermissionStatus)>;
GURL kUrl = GURL(kTestUrl);
url::Origin kTestOrigin = url::Origin::Create(kUrl);
diff --git a/content/browser/presentation/presentation_service_impl.cc b/content/browser/presentation/presentation_service_impl.cc
index bb1200c3..f8ffc4c 100644
--- a/content/browser/presentation/presentation_service_impl.cc
+++ b/content/browser/presentation/presentation_service_impl.cc
@@ -165,8 +165,9 @@
presentation_receiver_remote_.set_disconnect_handler(base::BindOnce(
&PresentationServiceImpl::OnConnectionError, base::Unretained(this)));
receiver_delegate_->RegisterReceiverConnectionAvailableCallback(
- base::Bind(&PresentationServiceImpl::OnReceiverConnectionAvailable,
- weak_factory_.GetWeakPtr()));
+ base::BindRepeating(
+ &PresentationServiceImpl::OnReceiverConnectionAvailable,
+ weak_factory_.GetWeakPtr()));
}
void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) {
@@ -292,8 +293,8 @@
if (controller_delegate_) {
controller_delegate_->ListenForConnectionStateChange(
render_process_id_, render_frame_id_, connection,
- base::Bind(&PresentationServiceImpl::OnConnectionStateChanged,
- weak_factory_.GetWeakPtr(), connection));
+ base::BindRepeating(&PresentationServiceImpl::OnConnectionStateChanged,
+ weak_factory_.GetWeakPtr(), connection));
}
}
@@ -373,9 +374,9 @@
presentation_urls,
render_frame_host_->GetLastCommittedOrigin());
controller_delegate_->SetDefaultPresentationUrls(
- request,
- base::Bind(&PresentationServiceImpl::OnDefaultPresentationStarted,
- weak_factory_.GetWeakPtr()));
+ request, base::BindRepeating(
+ &PresentationServiceImpl::OnDefaultPresentationStarted,
+ weak_factory_.GetWeakPtr()));
}
void PresentationServiceImpl::CloseConnection(
diff --git a/content/browser/push_messaging/push_messaging_manager.cc b/content/browser/push_messaging/push_messaging_manager.cc
index 6e63b19c..2be315a 100644
--- a/content/browser/push_messaging/push_messaging_manager.cc
+++ b/content/browser/push_messaging/push_messaging_manager.cc
@@ -462,10 +462,10 @@
->RequestPermission(
PermissionType::NOTIFICATIONS, render_frame_host,
data.requesting_origin, data.user_gesture,
- base::Bind(&PushMessagingManager::Core::
- DidRequestPermissionInIncognito,
- weak_factory_ui_to_ui_.GetWeakPtr(),
- base::Passed(&data)));
+ base::BindOnce(&PushMessagingManager::Core::
+ DidRequestPermissionInIncognito,
+ weak_factory_ui_to_ui_.GetWeakPtr(),
+ base::Passed(&data)));
}
}
}
@@ -480,13 +480,13 @@
push_service->SubscribeFromDocument(
requesting_origin, registration_id, render_process_id_,
render_frame_id_, std::move(options), data.user_gesture,
- base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
- base::Passed(&data)));
+ base::BindOnce(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
+ base::Passed(&data)));
} else {
push_service->SubscribeFromWorker(
requesting_origin, registration_id, std::move(options),
- base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
- base::Passed(&data)));
+ base::BindOnce(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
+ base::Passed(&data)));
}
}
@@ -681,9 +681,9 @@
push_service->Unsubscribe(
blink::mojom::PushUnregistrationReason::JAVASCRIPT_API, requesting_origin,
service_worker_registration_id, sender_id,
- base::Bind(&Core::DidUnregisterFromService,
- weak_factory_ui_to_ui_.GetWeakPtr(), base::Passed(&callback),
- service_worker_registration_id));
+ base::BindOnce(&Core::DidUnregisterFromService,
+ weak_factory_ui_to_ui_.GetWeakPtr(),
+ base::Passed(&callback), service_worker_registration_id));
}
void PushMessagingManager::Core::DidUnregisterFromService(
@@ -787,14 +787,14 @@
RunOrPostTaskOnThread(
FROM_HERE, BrowserThread::UI,
- base::BindOnce(&Core::GetSubscriptionInfoOnUI,
- base::Unretained(ui_core_.get()), origin,
- service_worker_registration_id, application_server_key,
- push_subscription_id,
- base::Bind(&Core::GetSubscriptionDidGetInfoOnUI,
- ui_core_weak_ptr_, base::Passed(&callback),
- origin, service_worker_registration_id,
- application_server_key)));
+ base::BindOnce(
+ &Core::GetSubscriptionInfoOnUI, base::Unretained(ui_core_.get()),
+ origin, service_worker_registration_id, application_server_key,
+ push_subscription_id,
+ base::BindOnce(&Core::GetSubscriptionDidGetInfoOnUI,
+ ui_core_weak_ptr_, base::Passed(&callback), origin,
+ service_worker_registration_id,
+ application_server_key)));
return;
}
@@ -888,13 +888,13 @@
blink::mojom::PushGetRegistrationStatus status =
blink::mojom::PushGetRegistrationStatus::STORAGE_CORRUPT;
- push_service->Unsubscribe(blink::mojom::PushUnregistrationReason::
- GET_SUBSCRIPTION_STORAGE_CORRUPT,
- origin, service_worker_registration_id,
- application_server_key,
- base::Bind(&Core::GetSubscriptionDidUnsubscribe,
- weak_factory_ui_to_ui_.GetWeakPtr(),
- base::Passed(&callback), status));
+ push_service->Unsubscribe(
+ blink::mojom::PushUnregistrationReason::
+ GET_SUBSCRIPTION_STORAGE_CORRUPT,
+ origin, service_worker_registration_id, application_server_key,
+ base::BindOnce(&Core::GetSubscriptionDidUnsubscribe,
+ weak_factory_ui_to_ui_.GetWeakPtr(),
+ base::Passed(&callback), status));
RecordGetRegistrationStatus(status);
}
diff --git a/content/browser/push_messaging/push_messaging_router.cc b/content/browser/push_messaging/push_messaging_router.cc
index d77cf06..bb29237 100644
--- a/content/browser/push_messaging/push_messaging_router.cc
+++ b/content/browser/push_messaging/push_messaging_router.cc
@@ -25,13 +25,14 @@
namespace {
void RunDeliverCallback(
- const PushMessagingRouter::DeliverMessageCallback& deliver_message_callback,
+ PushMessagingRouter::DeliverMessageCallback deliver_message_callback,
blink::mojom::PushDeliveryStatus delivery_status) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
// Use PostTask() instead of RunOrPostTaskOnThread() to ensure the callback
// is called asynchronously.
- base::PostTask(FROM_HERE, {BrowserThread::UI},
- base::BindOnce(deliver_message_callback, delivery_status));
+ base::PostTask(
+ FROM_HERE, {BrowserThread::UI},
+ base::BindOnce(std::move(deliver_message_callback), delivery_status));
}
} // namespace
@@ -43,7 +44,7 @@
int64_t service_worker_registration_id,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback) {
+ DeliverMessageCallback deliver_message_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
StoragePartition* partition =
BrowserContext::GetStoragePartitionForSite(browser_context, origin);
@@ -60,7 +61,7 @@
std::move(service_worker_context),
std::move(devtools_context), origin,
service_worker_registration_id, message_id,
- std::move(payload), deliver_message_callback));
+ std::move(payload), std::move(deliver_message_callback)));
}
// static
@@ -71,7 +72,7 @@
int64_t service_worker_registration_id,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback) {
+ DeliverMessageCallback deliver_message_callback) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
// Try to acquire the registration from storage. If it's already live we'll
// receive it right away. If not, it will be revived from storage.
@@ -80,7 +81,7 @@
base::BindOnce(
&PushMessagingRouter::FindServiceWorkerRegistrationCallback,
std::move(devtools_context), message_id, std::move(payload),
- deliver_message_callback));
+ std::move(deliver_message_callback)));
}
// static
@@ -88,19 +89,19 @@
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.FindServiceWorker",
service_worker_status);
if (service_worker_status == blink::ServiceWorkerStatusCode::kErrorNotFound) {
- RunDeliverCallback(deliver_message_callback,
+ RunDeliverCallback(std::move(deliver_message_callback),
blink::mojom::PushDeliveryStatus::NO_SERVICE_WORKER);
return;
}
if (service_worker_status != blink::ServiceWorkerStatusCode::kOk) {
- RunDeliverCallback(deliver_message_callback,
+ RunDeliverCallback(std::move(deliver_message_callback),
blink::mojom::PushDeliveryStatus::SERVICE_WORKER_ERROR);
return;
}
@@ -118,7 +119,7 @@
base::WrapRefCounted(version),
std::move(service_worker_registration),
std::move(devtools_context), message_id,
- std::move(payload), deliver_message_callback));
+ std::move(payload), std::move(deliver_message_callback)));
}
// static
@@ -128,14 +129,14 @@
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode start_worker_status) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
if (start_worker_status != blink::ServiceWorkerStatusCode::kOk) {
DeliverMessageEnd(std::move(service_worker),
std::move(service_worker_registration),
std::move(devtools_context), message_id,
- deliver_message_callback, start_worker_status);
+ std::move(deliver_message_callback), start_worker_status);
return;
}
@@ -143,7 +144,7 @@
ServiceWorkerMetrics::EventType::PUSH,
base::BindOnce(&PushMessagingRouter::DeliverMessageEnd, service_worker,
std::move(service_worker_registration), devtools_context,
- message_id, deliver_message_callback),
+ message_id, std::move(deliver_message_callback)),
base::TimeDelta::FromSeconds(blink::mojom::kPushEventTimeoutSeconds),
ServiceWorkerVersion::KILL_ON_TIMEOUT);
@@ -168,7 +169,7 @@
scoped_refptr<ServiceWorkerRegistration> service_worker_registration,
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus.ServiceWorkerEvent",
@@ -215,7 +216,7 @@
delivery_status = blink::mojom::PushDeliveryStatus::SERVICE_WORKER_ERROR;
break;
}
- RunDeliverCallback(deliver_message_callback, delivery_status);
+ RunDeliverCallback(std::move(deliver_message_callback), delivery_status);
if (devtools_context->IsRecording(
DevToolsBackgroundService::kPushMessaging) &&
diff --git a/content/browser/push_messaging/push_messaging_router.h b/content/browser/push_messaging/push_messaging_router.h
index 13b1f10..9b34fda 100644
--- a/content/browser/push_messaging/push_messaging_router.h
+++ b/content/browser/push_messaging/push_messaging_router.h
@@ -31,18 +31,17 @@
class PushMessagingRouter {
public:
using DeliverMessageCallback =
- base::Callback<void(blink::mojom::PushDeliveryStatus)>;
+ base::OnceCallback<void(blink::mojom::PushDeliveryStatus)>;
// Delivers a push message with |data| to the Service Worker identified by
// |origin| and |service_worker_registration_id|. Must be called on the UI
// thread.
- static void DeliverMessage(
- BrowserContext* browser_context,
- const GURL& origin,
- int64_t service_worker_registration_id,
- const std::string& message_id,
- base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback);
+ static void DeliverMessage(BrowserContext* browser_context,
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ const std::string& message_id,
+ base::Optional<std::string> payload,
+ DeliverMessageCallback deliver_message_callback);
private:
// Attempts to find a Service Worker registration so that a push event can be
@@ -54,7 +53,7 @@
int64_t service_worker_registration_id,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback);
+ DeliverMessageCallback deliver_message_callback);
// If a registration was successfully retrieved, dispatches a push event with
// |data| on the Service Worker identified by |service_worker_registration|.
@@ -63,7 +62,7 @@
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration);
@@ -75,7 +74,7 @@
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
base::Optional<std::string> payload,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode start_worker_status);
// Gets called asynchronously after the Service Worker has dispatched the push
@@ -85,7 +84,7 @@
scoped_refptr<ServiceWorkerRegistration> service_worker_registration,
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id,
- const DeliverMessageCallback& deliver_message_callback,
+ DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status);
DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc
index 3980614..5214880 100644
--- a/content/browser/tracing/tracing_ui.cc
+++ b/content/browser/tracing/tracing_ui.cc
@@ -43,7 +43,7 @@
namespace content {
namespace {
-void OnGotCategories(const WebUIDataSource::GotDataCallback& callback,
+void OnGotCategories(WebUIDataSource::GotDataCallback callback,
const std::set<std::string>& categorySet) {
base::ListValue category_list;
for (auto it = categorySet.begin(); it != categorySet.end(); it++) {
@@ -52,34 +52,35 @@
scoped_refptr<base::RefCountedString> res(new base::RefCountedString());
base::JSONWriter::Write(category_list, &res->data());
- callback.Run(res);
+ std::move(callback).Run(res);
}
-void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback);
+void OnRecordingEnabledAck(WebUIDataSource::GotDataCallback callback);
bool BeginRecording(const std::string& data64,
- const WebUIDataSource::GotDataCallback& callback) {
+ WebUIDataSource::GotDataCallback callback) {
base::trace_event::TraceConfig trace_config("", "");
if (!TracingUI::GetTracingOptions(data64, &trace_config))
return false;
return TracingController::GetInstance()->StartTracing(
- trace_config, base::BindOnce(&OnRecordingEnabledAck, callback));
+ trace_config,
+ base::BindOnce(&OnRecordingEnabledAck, std::move(callback)));
}
-void OnRecordingEnabledAck(const WebUIDataSource::GotDataCallback& callback) {
- callback.Run(
+void OnRecordingEnabledAck(WebUIDataSource::GotDataCallback callback) {
+ std::move(callback).Run(
scoped_refptr<base::RefCountedMemory>(new base::RefCountedString()));
}
-void OnTraceBufferUsageResult(const WebUIDataSource::GotDataCallback& callback,
+void OnTraceBufferUsageResult(WebUIDataSource::GotDataCallback callback,
float percent_full,
size_t approximate_event_count) {
std::string str = base::NumberToString(percent_full);
- callback.Run(base::RefCountedString::TakeString(&str));
+ std::move(callback).Run(base::RefCountedString::TakeString(&str));
}
-void OnTraceBufferStatusResult(const WebUIDataSource::GotDataCallback& callback,
+void OnTraceBufferStatusResult(WebUIDataSource::GotDataCallback callback,
float percent_full,
size_t approximate_event_count) {
base::DictionaryValue status;
@@ -91,45 +92,44 @@
base::RefCountedString* status_base64 = new base::RefCountedString();
base::Base64Encode(status_json, &status_base64->data());
- callback.Run(status_base64);
+ std::move(callback).Run(status_base64);
}
-void TracingCallbackWrapperBase64(
- const WebUIDataSource::GotDataCallback& callback,
- std::unique_ptr<std::string> data) {
+void TracingCallbackWrapperBase64(WebUIDataSource::GotDataCallback callback,
+ std::unique_ptr<std::string> data) {
base::RefCountedString* data_base64 = new base::RefCountedString();
base::Base64Encode(*data, &data_base64->data());
- callback.Run(data_base64);
+ std::move(callback).Run(data_base64);
}
bool OnBeginJSONRequest(const std::string& path,
- const WebUIDataSource::GotDataCallback& callback) {
+ WebUIDataSource::GotDataCallback* callback) {
if (path == "json/categories") {
return TracingController::GetInstance()->GetCategories(
- base::BindOnce(OnGotCategories, callback));
+ base::BindOnce(OnGotCategories, std::move(*callback)));
}
const char kBeginRecordingPath[] = "json/begin_recording?";
if (base::StartsWith(path, kBeginRecordingPath,
base::CompareCase::SENSITIVE)) {
std::string data = path.substr(strlen(kBeginRecordingPath));
- return BeginRecording(data, callback);
+ return BeginRecording(data, std::move(*callback));
}
if (path == "json/get_buffer_percent_full") {
return TracingController::GetInstance()->GetTraceBufferUsage(
- base::BindOnce(OnTraceBufferUsageResult, callback));
+ base::BindOnce(OnTraceBufferUsageResult, std::move(*callback)));
}
if (path == "json/get_buffer_status") {
return TracingController::GetInstance()->GetTraceBufferUsage(
- base::BindOnce(OnTraceBufferStatusResult, callback));
+ base::BindOnce(OnTraceBufferStatusResult, std::move(*callback)));
}
if (path == "json/end_recording_compressed") {
if (!TracingController::GetInstance()->IsTracing())
return false;
scoped_refptr<TracingController::TraceDataEndpoint> data_endpoint =
TracingControllerImpl::CreateCompressedStringEndpoint(
- TracingControllerImpl::CreateCallbackEndpoint(
- base::Bind(TracingCallbackWrapperBase64, callback)),
+ TracingControllerImpl::CreateCallbackEndpoint(base::BindOnce(
+ TracingCallbackWrapperBase64, std::move(*callback))),
false /* compress_with_background_priority */);
return TracingController::GetInstance()->StopTracing(data_endpoint);
}
@@ -143,11 +143,13 @@
}
void OnTracingRequest(const std::string& path,
- const WebUIDataSource::GotDataCallback& callback) {
+ WebUIDataSource::GotDataCallback callback) {
DCHECK(OnShouldHandleRequest(path));
- if (!OnBeginJSONRequest(path, callback)) {
+ if (!OnBeginJSONRequest(path, &callback)) {
+ // OnBeginJSONRequest only consumes |callback| if it returns true.
+ DCHECK(callback);
std::string error("##ERROR##");
- callback.Run(base::RefCountedString::TakeString(&error));
+ std::move(callback).Run(base::RefCountedString::TakeString(&error));
}
}
diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc
index c767ebf..e2754d8b 100644
--- a/content/browser/web_contents/web_contents_android.cc
+++ b/content/browser/web_contents/web_contents_android.cc
@@ -657,10 +657,10 @@
const uint32_t preferred_size = 0;
return web_contents_->DownloadImage(
url, is_fav_icon, preferred_size, max_bitmap_size, bypass_cache,
- base::Bind(&WebContentsAndroid::OnFinishDownloadImage,
- weak_factory_.GetWeakPtr(),
- ScopedJavaGlobalRef<jobject>(env, obj),
- ScopedJavaGlobalRef<jobject>(env, jcallback)));
+ base::BindOnce(&WebContentsAndroid::OnFinishDownloadImage,
+ weak_factory_.GetWeakPtr(),
+ ScopedJavaGlobalRef<jobject>(env, obj),
+ ScopedJavaGlobalRef<jobject>(env, jcallback)));
}
void WebContentsAndroid::SetHasPersistentVideo(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 6c06d0e..ff200c5 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -607,9 +607,8 @@
showing_context_menu_(false),
text_autosizer_page_info_({0, 0, 1.f}),
had_inner_webcontents_(false) {
- frame_tree_.SetFrameRemoveListener(
- base::Bind(&WebContentsImpl::OnFrameRemoved,
- base::Unretained(this)));
+ frame_tree_.SetFrameRemoveListener(base::BindRepeating(
+ &WebContentsImpl::OnFrameRemoved, base::Unretained(this)));
#if BUILDFLAG(ENABLE_PLUGINS)
pepper_playback_observer_.reset(new PepperPlaybackObserver(this));
#endif
@@ -1218,14 +1217,14 @@
}
#endif // !defined(OS_ANDROID)
-base::Closure WebContentsImpl::AddBindingSet(
+base::OnceClosure WebContentsImpl::AddBindingSet(
const std::string& interface_name,
WebContentsBindingSet* binding_set) {
auto result =
binding_sets_.insert(std::make_pair(interface_name, binding_set));
DCHECK(result.second);
- return base::Bind(&WebContentsImpl::RemoveBindingSet,
- weak_factory_.GetWeakPtr(), interface_name);
+ return base::BindOnce(&WebContentsImpl::RemoveBindingSet,
+ weak_factory_.GetWeakPtr(), interface_name);
}
WebContentsBindingSet* WebContentsImpl::GetBindingSet(
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 970ffc6a..4974e93 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -271,8 +271,8 @@
//
// |binding_set| is not owned and must either outlive this WebContents or be
// explicitly removed before being destroyed.
- base::Closure AddBindingSet(const std::string& interface_name,
- WebContentsBindingSet* binding_set);
+ base::OnceClosure AddBindingSet(const std::string& interface_name,
+ WebContentsBindingSet* binding_set);
// Accesses a WebContentsBindingSet for a specific interface on this
// WebContents. Returns null of there is no registered binder for the
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc
index 6494d60..6c39c9e 100644
--- a/content/browser/web_contents/web_contents_impl_browsertest.cc
+++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -2015,7 +2015,7 @@
void DidFirstVisuallyNonEmptyPaint() override {
did_fist_visually_non_empty_paint_ = true;
- on_did_first_visually_non_empty_paint_.Run();
+ std::move(on_did_first_visually_non_empty_paint_).Run();
}
void WaitForDidFirstVisuallyNonEmptyPaint() {
@@ -2026,7 +2026,7 @@
run_loop.Run();
}
- base::Closure on_did_first_visually_non_empty_paint_;
+ base::OnceClosure on_did_first_visually_non_empty_paint_;
bool did_fist_visually_non_empty_paint_;
};
@@ -2127,10 +2127,10 @@
private:
void GotPageScaleUpdate() {
got_page_scale_update_ = true;
- on_page_scale_update_.Run();
+ std::move(on_page_scale_update_).Run();
}
- base::Closure on_page_scale_update_;
+ base::OnceClosure on_page_scale_update_;
bool got_page_scale_update_;
};
@@ -2844,7 +2844,7 @@
loop_runner->Run();
}
-void ExpectNoValidImageCallback(const base::Closure& quit_closure,
+void ExpectNoValidImageCallback(base::OnceClosure quit_closure,
int id,
int status_code,
const GURL& image_url,
@@ -2853,7 +2853,7 @@
EXPECT_EQ(200, status_code);
EXPECT_TRUE(bitmap.empty());
EXPECT_TRUE(sizes.empty());
- quit_closure.Run();
+ std::move(quit_closure).Run();
}
void ExpectSingleValidImageCallback(base::OnceClosure quit_closure,
diff --git a/content/browser/web_package/mock_web_bundle_reader_factory.cc b/content/browser/web_package/mock_web_bundle_reader_factory.cc
index 2a9692f4..25f7add 100644
--- a/content/browser/web_package/mock_web_bundle_reader_factory.cc
+++ b/content/browser/web_package/mock_web_bundle_reader_factory.cc
@@ -184,7 +184,7 @@
base::RunLoop run_loop;
reader->ReadMetadata(base::BindOnce(
- [](base::Closure quit_closure,
+ [](base::OnceClosure quit_closure,
WebBundleReader::MetadataCallback callback,
data_decoder::mojom::BundleMetadataParseErrorPtr error) {
std::move(callback).Run(std::move(error));
@@ -207,7 +207,7 @@
base::RunLoop run_loop;
reader->ReadResponse(
url, base::BindOnce(
- [](base::Closure quit_closure,
+ [](base::OnceClosure quit_closure,
WebBundleReader::ResponseCallback callback,
data_decoder::mojom::BundleResponsePtr response,
data_decoder::mojom::BundleResponseParseErrorPtr error) {
diff --git a/content/browser/web_package/web_bundle_reader_unittest.cc b/content/browser/web_package/web_bundle_reader_unittest.cc
index 420f459..2d2f410 100644
--- a/content/browser/web_package/web_bundle_reader_unittest.cc
+++ b/content/browser/web_package/web_bundle_reader_unittest.cc
@@ -177,7 +177,7 @@
GetReader()->ReadResponseBody(
std::move(response), std::move(producer),
base::BindOnce(
- [](base::Closure quit_closure, net::Error* callback_result,
+ [](base::OnceClosure quit_closure, net::Error* callback_result,
net::Error result) {
*callback_result = result;
std::move(quit_closure).Run();
diff --git a/content/browser/web_package/web_bundle_url_loader_factory_unittest.cc b/content/browser/web_package/web_bundle_url_loader_factory_unittest.cc
index c6c5ae3..64f77f5 100644
--- a/content/browser/web_package/web_bundle_url_loader_factory_unittest.cc
+++ b/content/browser/web_package/web_bundle_url_loader_factory_unittest.cc
@@ -54,7 +54,7 @@
mock_factory_->ReadAndFullfillMetadata(
reader_, std::move(metadata),
base::BindOnce(
- [](base::Closure quit_closure,
+ [](base::OnceClosure quit_closure,
data_decoder::mojom::BundleMetadataParseErrorPtr error) {
std::move(quit_closure).Run();
},
diff --git a/content/browser/webui/shared_resources_data_source.cc b/content/browser/webui/shared_resources_data_source.cc
index b8e8f5b..4412ba6 100644
--- a/content/browser/webui/shared_resources_data_source.cc
+++ b/content/browser/webui/shared_resources_data_source.cc
@@ -294,7 +294,7 @@
void SharedResourcesDataSource::StartDataRequest(
const GURL& url,
const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback) {
+ URLDataSource::GotDataCallback callback) {
const std::string path = URLDataSource::URLToRequestPath(url);
std::string updated_path = path;
#if defined(OS_CHROMEOS)
@@ -321,7 +321,7 @@
bytes = GetContentClient()->GetDataResourceBytes(idr);
}
- callback.Run(std::move(bytes));
+ std::move(callback).Run(std::move(bytes));
}
bool SharedResourcesDataSource::AllowCaching() {
diff --git a/content/browser/webui/shared_resources_data_source.h b/content/browser/webui/shared_resources_data_source.h
index 07a4fed..8473cf7 100644
--- a/content/browser/webui/shared_resources_data_source.h
+++ b/content/browser/webui/shared_resources_data_source.h
@@ -21,10 +21,9 @@
// URLDataSource implementation.
std::string GetSource() override;
- void StartDataRequest(
- const GURL& url,
- const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback) override;
+ void StartDataRequest(const GURL& url,
+ const WebContents::Getter& wc_getter,
+ URLDataSource::GotDataCallback callback) override;
bool AllowCaching() override;
std::string GetMimeType(const std::string& path) override;
bool ShouldServeMimeTypeAsContentTypeHeader() override;
diff --git a/content/browser/webui/web_ui_browsertest_util.cc b/content/browser/webui/web_ui_browsertest_util.cc
index 27e6e4f5..0b2a161 100644
--- a/content/browser/webui/web_ui_browsertest_util.cc
+++ b/content/browser/webui/web_ui_browsertest_util.cc
@@ -30,11 +30,11 @@
namespace {
void GetResource(const std::string& id,
- const WebUIDataSource::GotDataCallback& callback) {
+ WebUIDataSource::GotDataCallback callback) {
base::ScopedAllowBlockingForTesting allow_blocking;
if (id == "error") {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -46,7 +46,7 @@
base::RefCountedString* ref_contents = new base::RefCountedString;
ref_contents->data() = contents;
- callback.Run(ref_contents);
+ std::move(callback).Run(ref_contents);
}
struct WebUIControllerConfig {
diff --git a/content/browser/webui/web_ui_data_source_impl.cc b/content/browser/webui/web_ui_data_source_impl.cc
index ca4eac89..ef62de6 100644
--- a/content/browser/webui/web_ui_data_source_impl.cc
+++ b/content/browser/webui/web_ui_data_source_impl.cc
@@ -67,11 +67,10 @@
std::string GetMimeType(const std::string& path) override {
return parent_->GetMimeType(path);
}
- void StartDataRequest(
- const GURL& url,
- const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback) override {
- return parent_->StartDataRequest(url, wc_getter, callback);
+ void StartDataRequest(const GURL& url,
+ const WebContents::Getter& wc_getter,
+ URLDataSource::GotDataCallback callback) override {
+ return parent_->StartDataRequest(url, wc_getter, std::move(callback));
}
bool ShouldReplaceExistingSource() override {
return parent_->replace_existing_source_;
@@ -275,11 +274,11 @@
void WebUIDataSourceImpl::StartDataRequest(
const GURL& url,
const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback) {
+ URLDataSource::GotDataCallback callback) {
const std::string path = URLDataSource::URLToRequestPath(url);
if (!should_handle_request_callback_.is_null() &&
should_handle_request_callback_.Run(path)) {
- filter_callback_.Run(path, callback);
+ filter_callback_.Run(path, std::move(callback));
return;
}
@@ -288,7 +287,7 @@
if (use_strings_js_) {
bool from_js_module = path == "strings.m.js";
if (from_js_module || path == "strings.js") {
- SendLocalizedStringsAsJSON(callback, from_js_module);
+ SendLocalizedStringsAsJSON(std::move(callback), from_js_module);
return;
}
}
@@ -297,15 +296,15 @@
DCHECK_NE(resource_id, -1) << " for " << path;
scoped_refptr<base::RefCountedMemory> response(
GetContentClient()->GetDataResourceBytes(resource_id));
- callback.Run(response.get());
+ std::move(callback).Run(response.get());
}
void WebUIDataSourceImpl::SendLocalizedStringsAsJSON(
- const URLDataSource::GotDataCallback& callback,
+ URLDataSource::GotDataCallback callback,
bool from_js_module) {
std::string template_data;
webui::AppendJsonJS(&localized_strings_, &template_data, from_js_module);
- callback.Run(base::RefCountedString::TakeString(&template_data));
+ std::move(callback).Run(base::RefCountedString::TakeString(&template_data));
}
const base::DictionaryValue* WebUIDataSourceImpl::GetLocalizedStrings() const {
diff --git a/content/browser/webui/web_ui_data_source_impl.h b/content/browser/webui/web_ui_data_source_impl.h
index f64f9e5..4e2cfa6 100644
--- a/content/browser/webui/web_ui_data_source_impl.h
+++ b/content/browser/webui/web_ui_data_source_impl.h
@@ -67,9 +67,8 @@
~WebUIDataSourceImpl() override;
// Completes a request by sending our dictionary of localized strings.
- void SendLocalizedStringsAsJSON(
- const URLDataSource::GotDataCallback& callback,
- bool from_js_module);
+ void SendLocalizedStringsAsJSON(URLDataSource::GotDataCallback callback,
+ bool from_js_module);
// Protected for testing.
virtual const base::DictionaryValue* GetLocalizedStrings() const;
@@ -85,7 +84,7 @@
std::string GetMimeType(const std::string& path) const;
void StartDataRequest(const GURL& url,
const WebContents::Getter& wc_getter,
- const URLDataSource::GotDataCallback& callback);
+ URLDataSource::GotDataCallback callback);
int PathToIdrOrDefault(const std::string& path) const;
diff --git a/content/browser/webui/web_ui_data_source_unittest.cc b/content/browser/webui/web_ui_data_source_unittest.cc
index d330d4e..795c73d 100644
--- a/content/browser/webui/web_ui_data_source_unittest.cc
+++ b/content/browser/webui/web_ui_data_source_unittest.cc
@@ -54,9 +54,9 @@
WebUIDataSourceImpl* source() { return source_.get(); }
void StartDataRequest(const std::string& path,
- const URLDataSource::GotDataCallback& callback) {
+ URLDataSource::GotDataCallback callback) {
source_->StartDataRequest(GURL("https://any-host/" + path),
- WebContents::Getter(), callback);
+ WebContents::Getter(), std::move(callback));
}
std::string GetMimeType(const std::string& path) const {
@@ -64,7 +64,7 @@
}
void HandleRequest(const std::string& path,
- const WebUIDataSourceImpl::GotDataCallback&) {
+ WebUIDataSourceImpl::GotDataCallback) {
request_path_ = path;
}
@@ -100,12 +100,12 @@
TEST_F(WebUIDataSourceTest, EmptyStrings) {
source()->UseStringsJs();
- StartDataRequest("strings.js", base::Bind(&EmptyStringsCallback, false));
+ StartDataRequest("strings.js", base::BindOnce(&EmptyStringsCallback, false));
}
TEST_F(WebUIDataSourceTest, EmptyModuleStrings) {
source()->UseStringsJs();
- StartDataRequest("strings.m.js", base::Bind(&EmptyStringsCallback, true));
+ StartDataRequest("strings.m.js", base::BindOnce(&EmptyStringsCallback, true));
}
void SomeValuesCallback(scoped_refptr<base::RefCountedMemory> data) {
@@ -124,7 +124,7 @@
source()->AddInteger("debt", -456);
source()->AddString("planet", base::ASCIIToUTF16("pluto"));
source()->AddLocalizedString("button", kDummyStringId);
- StartDataRequest("strings.js", base::Bind(&SomeValuesCallback));
+ StartDataRequest("strings.js", base::BindOnce(&SomeValuesCallback));
}
void DefaultResourceFoobarCallback(scoped_refptr<base::RefCountedMemory> data) {
@@ -140,8 +140,9 @@
TEST_F(WebUIDataSourceTest, DefaultResource) {
source()->SetDefaultResource(kDummyDefaultResourceId);
- StartDataRequest("foobar", base::Bind(&DefaultResourceFoobarCallback));
- StartDataRequest("strings.js", base::Bind(&DefaultResourceStringsCallback));
+ StartDataRequest("foobar", base::BindOnce(&DefaultResourceFoobarCallback));
+ StartDataRequest("strings.js",
+ base::BindOnce(&DefaultResourceStringsCallback));
}
void NamedResourceFoobarCallback(scoped_refptr<base::RefCountedMemory> data) {
@@ -157,8 +158,8 @@
TEST_F(WebUIDataSourceTest, NamedResource) {
source()->SetDefaultResource(kDummyDefaultResourceId);
source()->AddResourcePath("foobar", kDummyResourceId);
- StartDataRequest("foobar", base::Bind(&NamedResourceFoobarCallback));
- StartDataRequest("strings.js", base::Bind(&NamedResourceStringsCallback));
+ StartDataRequest("foobar", base::BindOnce(&NamedResourceFoobarCallback));
+ StartDataRequest("strings.js", base::BindOnce(&NamedResourceStringsCallback));
}
void NamedResourceWithQueryStringCallback(
@@ -171,7 +172,7 @@
source()->SetDefaultResource(kDummyDefaultResourceId);
source()->AddResourcePath("foobar", kDummyResourceId);
StartDataRequest("foobar?query?string",
- base::Bind(&NamedResourceWithQueryStringCallback));
+ base::BindOnce(&NamedResourceWithQueryStringCallback));
}
void WebUIDataSourceTest::RequestFilterQueryStringCallback(
@@ -192,8 +193,8 @@
source()->AddResourcePath("foobar", kDummyResourceId);
StartDataRequest(
"foobar?query?string",
- base::Bind(&WebUIDataSourceTest::RequestFilterQueryStringCallback,
- base::Unretained(this)));
+ base::BindOnce(&WebUIDataSourceTest::RequestFilterQueryStringCallback,
+ base::Unretained(this)));
}
TEST_F(WebUIDataSourceTest, MimeType) {
diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc
index 74a4aeca..d86c13c 100644
--- a/content/browser/webui/web_ui_mojo_browsertest.cc
+++ b/content/browser/webui/web_ui_mojo_browsertest.cc
@@ -62,7 +62,7 @@
// The bindings for the page are generated from a .mojom file. This code looks
// up the generated file from disk and returns it.
void GetResource(const std::string& id,
- const WebUIDataSource::GotDataCallback& callback) {
+ WebUIDataSource::GotDataCallback callback) {
base::ScopedAllowBlockingForTesting allow_blocking;
std::string contents;
@@ -78,7 +78,7 @@
base::RefCountedString* ref_contents = new base::RefCountedString;
ref_contents->data() = contents;
- callback.Run(ref_contents);
+ std::move(callback).Run(ref_contents);
}
class BrowserTargetImpl : public mojom::BrowserTarget {
@@ -124,11 +124,10 @@
WebUIDataSource* data_source = WebUIDataSource::Create("dummy-web-ui");
data_source->SetRequestFilter(
base::BindRepeating([](const std::string& path) { return true; }),
- base::BindRepeating(
- [](const std::string& id,
- const WebUIDataSource::GotDataCallback& callback) {
- callback.Run(new base::RefCountedString);
- }));
+ base::BindRepeating([](const std::string& id,
+ WebUIDataSource::GotDataCallback callback) {
+ std::move(callback).Run(new base::RefCountedString);
+ }));
WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
data_source);
}
diff --git a/content/browser/webui/web_ui_url_loader_factory.cc b/content/browser/webui/web_ui_url_loader_factory.cc
index 2f67766..42a6c932 100644
--- a/content/browser/webui/web_ui_url_loader_factory.cc
+++ b/content/browser/webui/web_ui_url_loader_factory.cc
@@ -184,7 +184,7 @@
// request_start response_start
WebContents::Getter wc_getter =
- base::Bind(WebContents::FromFrameTreeNodeId, frame_tree_node_id);
+ base::BindRepeating(WebContents::FromFrameTreeNodeId, frame_tree_node_id);
bool replace_in_js =
source->source()->ShouldReplaceI18nInJS() &&
@@ -197,9 +197,9 @@
// To keep the same behavior as the old WebUI code, we call the source to get
// the value for |replacements| on the IO thread. Since |replacements| is
// owned by |source| keep a reference to it in the callback.
- auto data_available_callback =
- base::Bind(DataAvailable, resource_response, replacements, replace_in_js,
- base::RetainedRef(source), base::Passed(&client_remote));
+ URLDataSource::GotDataCallback data_available_callback = base::BindOnce(
+ DataAvailable, resource_response, replacements, replace_in_js,
+ base::RetainedRef(source), base::Passed(&client_remote));
// TODO(jam): once we only have this code path for WebUI, and not the
// URLLRequestJob one, then we should switch data sources to run on the UI
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index 06b8121..a9e1fd36 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -899,7 +899,7 @@
bool ContentBrowserClient::HandleExternalProtocol(
const GURL& url,
- WebContents::Getter web_contents_getter,
+ WebContents::OnceGetter web_contents_getter,
int child_id,
NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 958c5145..bc4e6588 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -1570,7 +1570,7 @@
// decisions about whether to allow an external application to launch.
virtual bool HandleExternalProtocol(
const GURL& url,
- base::Callback<WebContents*(void)> web_contents_getter,
+ base::OnceCallback<WebContents*()> web_contents_getter,
int child_id,
NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/content/public/browser/push_messaging_service.h b/content/public/browser/push_messaging_service.h
index 74efe74..8a7586c6 100644
--- a/content/public/browser/push_messaging_service.h
+++ b/content/public/browser/push_messaging_service.h
@@ -40,10 +40,10 @@
using UnregisterCallback =
base::OnceCallback<void(blink::mojom::PushUnregistrationStatus)>;
using SubscriptionInfoCallback =
- base::Callback<void(bool is_valid,
- const GURL& endpoint,
- const std::vector<uint8_t>& p256dh,
- const std::vector<uint8_t>& auth)>;
+ base::OnceCallback<void(bool is_valid,
+ const GURL& endpoint,
+ const std::vector<uint8_t>& p256dh,
+ const std::vector<uint8_t>& auth)>;
using StringCallback = base::OnceCallback<
void(const std::string& data, bool success, bool not_found)>;
@@ -80,12 +80,11 @@
// information to the callback. |sender_id| is also required since an
// InstanceID might have multiple tokens associated with different senders,
// though in practice Push doesn't yet use that.
- virtual void GetSubscriptionInfo(
- const GURL& origin,
- int64_t service_worker_registration_id,
- const std::string& sender_id,
- const std::string& subscription_id,
- const SubscriptionInfoCallback& callback) = 0;
+ virtual void GetSubscriptionInfo(const GURL& origin,
+ int64_t service_worker_registration_id,
+ const std::string& sender_id,
+ const std::string& subscription_id,
+ SubscriptionInfoCallback callback) = 0;
// Unsubscribe the given |sender_id| from the push messaging service. Locally
// deactivates the subscription, then runs |callback|, then asynchronously
diff --git a/content/public/browser/url_data_source.h b/content/public/browser/url_data_source.h
index 9e9d150..9c40fc82 100644
--- a/content/public/browser/url_data_source.h
+++ b/content/public/browser/url_data_source.h
@@ -61,8 +61,8 @@
// Used by StartDataRequest so that the child class can return the data when
// it's available.
- typedef base::Callback<void(scoped_refptr<base::RefCountedMemory>)>
- GotDataCallback;
+ using GotDataCallback =
+ base::OnceCallback<void(scoped_refptr<base::RefCountedMemory>)>;
// Must be called on the task runner specified by TaskRunnerForRequestPath,
// or the IO thread if TaskRunnerForRequestPath returns nullptr.
@@ -76,7 +76,7 @@
// null.
virtual void StartDataRequest(const GURL& url,
const WebContents::Getter& wc_getter,
- const GotDataCallback& callback) = 0;
+ GotDataCallback callback) = 0;
// The following methods are all called on the IO thread.
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 01e2904..ecee31b 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -264,7 +264,10 @@
// nullptr will be returned instead.
// The callback should only run on the UI thread and it should always be
// non-null.
- using Getter = base::Callback<WebContents*(void)>;
+ using Getter = base::RepeatingCallback<WebContents*(void)>;
+ // Use this variant for instances that will only run the callback a single
+ // time.
+ using OnceGetter = base::OnceCallback<WebContents*(void)>;
// Sets delegate for platform specific screen orientation functionality.
CONTENT_EXPORT static void SetScreenOrientationDelegate(
diff --git a/content/public/browser/web_contents_binding_set.cc b/content/public/browser/web_contents_binding_set.cc
index 455a5fe..dca3028 100644
--- a/content/public/browser/web_contents_binding_set.cc
+++ b/content/public/browser/web_contents_binding_set.cc
@@ -27,7 +27,7 @@
->AddBindingSet(interface_name, this)) {}
WebContentsBindingSet::~WebContentsBindingSet() {
- remove_callback_.Run();
+ std::move(remove_callback_).Run();
}
// static
diff --git a/content/public/browser/web_contents_binding_set.h b/content/public/browser/web_contents_binding_set.h
index bfe6fce..5a269244 100644
--- a/content/public/browser/web_contents_binding_set.h
+++ b/content/public/browser/web_contents_binding_set.h
@@ -60,7 +60,7 @@
void OnRequestForFrame(RenderFrameHost* render_frame_host,
mojo::ScopedInterfaceEndpointHandle handle);
- const base::Closure remove_callback_;
+ base::OnceClosure remove_callback_;
Binder* binder_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WebContentsBindingSet);
diff --git a/content/public/browser/web_ui_data_source.h b/content/public/browser/web_ui_data_source.h
index d1058746..a8b6147b 100644
--- a/content/public/browser/web_ui_data_source.h
+++ b/content/public/browser/web_ui_data_source.h
@@ -80,8 +80,8 @@
// Used as a parameter to GotDataCallback. The caller has to run this callback
// with the result for the path that they filtered, passing ownership of the
// memory.
- typedef base::Callback<void(scoped_refptr<base::RefCountedMemory>)>
- GotDataCallback;
+ using GotDataCallback =
+ base::OnceCallback<void(scoped_refptr<base::RefCountedMemory>)>;
// Used by SetRequestFilter. The string parameter is the path of the request.
// The return value indicates if the callee wants to handle the request. Iff
@@ -94,9 +94,8 @@
// This callback is only called if a prior call to ShouldHandleRequestCallback
// returned true. GotDataCallback should be used to provide the response
// bytes.
- typedef base::RepeatingCallback<void(const std::string&,
- const GotDataCallback&)>
- HandleRequestCallback;
+ using HandleRequestCallback =
+ base::RepeatingCallback<void(const std::string&, GotDataCallback)>;
// Allows a caller to add a filter for URL requests.
virtual void SetRequestFilter(
diff --git a/content/shell/browser/web_test/web_test_push_messaging_service.cc b/content/shell/browser/web_test/web_test_push_messaging_service.cc
index b33e05a..762c0f9 100644
--- a/content/shell/browser/web_test/web_test_push_messaging_service.cc
+++ b/content/shell/browser/web_test/web_test_push_messaging_service.cc
@@ -101,14 +101,14 @@
int64_t service_worker_registration_id,
const std::string& sender_id,
const std::string& subscription_id,
- const SubscriptionInfoCallback& callback) {
+ SubscriptionInfoCallback callback) {
std::vector<uint8_t> p256dh(kTestP256Key,
kTestP256Key + base::size(kTestP256Key));
std::vector<uint8_t> auth(kAuthentication,
kAuthentication + base::size(kAuthentication));
const GURL endpoint = CreateEndpoint(subscription_id);
- callback.Run(true /* is_valid */, endpoint, p256dh, auth);
+ std::move(callback).Run(true /* is_valid */, endpoint, p256dh, auth);
}
bool WebTestPushMessagingService::SupportNonVisibleMessages() {
diff --git a/content/shell/browser/web_test/web_test_push_messaging_service.h b/content/shell/browser/web_test/web_test_push_messaging_service.h
index 6988df08..32d3ab6 100644
--- a/content/shell/browser/web_test/web_test_push_messaging_service.h
+++ b/content/shell/browser/web_test/web_test_push_messaging_service.h
@@ -37,7 +37,7 @@
int64_t service_worker_registration_id,
const std::string& sender_id,
const std::string& subscription_id,
- const SubscriptionInfoCallback& callback) override;
+ SubscriptionInfoCallback callback) override;
bool SupportNonVisibleMessages() override;
void Unsubscribe(blink::mojom::PushUnregistrationReason reason,
const GURL& requesting_origin,
diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc
index 83299874..7096b01 100644
--- a/extensions/shell/browser/shell_content_browser_client.cc
+++ b/extensions/shell/browser/shell_content_browser_client.cc
@@ -335,7 +335,7 @@
bool ShellContentBrowserClient::HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/extensions/shell/browser/shell_content_browser_client.h b/extensions/shell/browser/shell_content_browser_client.h
index 4b8519b1..69f405f4 100644
--- a/extensions/shell/browser/shell_content_browser_client.h
+++ b/extensions/shell/browser/shell_content_browser_client.h
@@ -95,7 +95,7 @@
bool* bypass_redirect_checks) override;
bool HandleExternalProtocol(
const GURL& url,
- content::WebContents::Getter web_contents_getter,
+ content::WebContents::OnceGetter web_contents_getter,
int child_id,
content::NavigationUIData* navigation_data,
bool is_main_frame,
diff --git a/ios/chrome/browser/ui/webui/about_ui.cc b/ios/chrome/browser/ui/webui/about_ui.cc
index b1c4a93..9ea5fc3 100644
--- a/ios/chrome/browser/ui/webui/about_ui.cc
+++ b/ios/chrome/browser/ui/webui/about_ui.cc
@@ -38,14 +38,13 @@
std::string GetSource() const override;
void StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) override;
+ web::URLDataSourceIOS::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) const override;
bool ShouldDenyXFrameOptions() const override;
// Send the response data.
- void FinishDataRequest(
- const std::string& html,
- const web::URLDataSourceIOS::GotDataCallback& callback);
+ void FinishDataRequest(const std::string& html,
+ web::URLDataSourceIOS::GotDataCallback callback);
private:
~AboutUIHTMLSource() override;
@@ -112,7 +111,7 @@
void AboutUIHTMLSource::StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) {
+ web::URLDataSourceIOS::GotDataCallback callback) {
std::string response;
// Add your data source here, in alphabetical order.
if (source_name_ == kChromeUIChromeURLsHost) {
@@ -131,14 +130,14 @@
base::StatisticsRecorder::WriteHTMLGraph("", &response);
}
- FinishDataRequest(response, callback);
+ FinishDataRequest(response, std::move(callback));
}
void AboutUIHTMLSource::FinishDataRequest(
const std::string& html,
- const web::URLDataSourceIOS::GotDataCallback& callback) {
+ web::URLDataSourceIOS::GotDataCallback callback) {
std::string html_copy(html);
- callback.Run(base::RefCountedString::TakeString(&html_copy));
+ std::move(callback).Run(base::RefCountedString::TakeString(&html_copy));
}
std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const {
diff --git a/ios/chrome/browser/ui/webui/prefs_internals_ui.cc b/ios/chrome/browser/ui/webui/prefs_internals_ui.cc
index 052e861..fe65ffb 100644
--- a/ios/chrome/browser/ui/webui/prefs_internals_ui.cc
+++ b/ios/chrome/browser/ui/webui/prefs_internals_ui.cc
@@ -35,11 +35,11 @@
void StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) override {
+ web::URLDataSourceIOS::GotDataCallback callback) override {
// TODO(crbug.com/1006711): Properly disable this webui provider for
// incognito browser states.
if (browser_state_->IsOffTheRecord()) {
- callback.Run(nullptr);
+ std::move(callback).Run(nullptr);
return;
}
@@ -51,7 +51,7 @@
DCHECK(prefs);
CHECK(base::JSONWriter::WriteWithOptions(
*prefs, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json));
- callback.Run(base::RefCountedString::TakeString(&json));
+ std::move(callback).Run(base::RefCountedString::TakeString(&json));
}
private:
diff --git a/ios/chrome/browser/ui/webui/suggestions_ui.cc b/ios/chrome/browser/ui/webui/suggestions_ui.cc
index 16beb1bb..1c43c53 100644
--- a/ios/chrome/browser/ui/webui/suggestions_ui.cc
+++ b/ios/chrome/browser/ui/webui/suggestions_ui.cc
@@ -26,7 +26,7 @@
std::string GetSource() const override;
void StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) override;
+ web::URLDataSourceIOS::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) const override;
private:
@@ -49,8 +49,8 @@
void SuggestionsSourceWrapper::StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) {
- suggestions_source_.StartDataRequest(path, callback);
+ web::URLDataSourceIOS::GotDataCallback callback) {
+ suggestions_source_.StartDataRequest(path, std::move(callback));
}
std::string SuggestionsSourceWrapper::GetMimeType(
diff --git a/ios/chrome/browser/ui/webui/terms_ui.mm b/ios/chrome/browser/ui/webui/terms_ui.mm
index 8ff629b..7c360e27 100644
--- a/ios/chrome/browser/ui/webui/terms_ui.mm
+++ b/ios/chrome/browser/ui/webui/terms_ui.mm
@@ -29,14 +29,13 @@
std::string GetSource() const override;
void StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) override;
+ web::URLDataSourceIOS::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) const override;
bool ShouldDenyXFrameOptions() const override;
// Send the response data.
- void FinishDataRequest(
- const std::string& html,
- const web::URLDataSourceIOS::GotDataCallback& callback);
+ void FinishDataRequest(const std::string& html,
+ web::URLDataSourceIOS::GotDataCallback callback);
private:
~TermsUIHTMLSource() override;
@@ -59,7 +58,7 @@
void TermsUIHTMLSource::StartDataRequest(
const std::string& path,
- const web::URLDataSourceIOS::GotDataCallback& callback) {
+ web::URLDataSourceIOS::GotDataCallback callback) {
NSString* terms_of_service_path =
base::SysUTF8ToNSString(GetTermsOfServicePath());
NSString* bundle_path = [base::mac::FrameworkBundle() bundlePath];
@@ -72,14 +71,14 @@
encoding:NSUTF8StringEncoding
error:&error];
DCHECK(!error && [content length]);
- FinishDataRequest(base::SysNSStringToUTF8(content), callback);
+ FinishDataRequest(base::SysNSStringToUTF8(content), std::move(callback));
}
void TermsUIHTMLSource::FinishDataRequest(
const std::string& html,
- const web::URLDataSourceIOS::GotDataCallback& callback) {
+ web::URLDataSourceIOS::GotDataCallback callback) {
std::string html_copy(html);
- callback.Run(base::RefCountedString::TakeString(&html_copy));
+ std::move(callback).Run(base::RefCountedString::TakeString(&html_copy));
}
std::string TermsUIHTMLSource::GetMimeType(const std::string& path) const {
diff --git a/ios/web/public/webui/url_data_source_ios.h b/ios/web/public/webui/url_data_source_ios.h
index 43e49fb..28d70ed44 100644
--- a/ios/web/public/webui/url_data_source_ios.h
+++ b/ios/web/public/webui/url_data_source_ios.h
@@ -50,7 +50,7 @@
// data is available or if the request could not be satisfied. This can be
// called either in this callback or asynchronously with the response.
virtual void StartDataRequest(const std::string& path,
- const GotDataCallback& callback) = 0;
+ GotDataCallback callback) = 0;
// Return the mimetype that should be sent with this response, or empty
// string to specify no mime type.
diff --git a/ios/web/webui/shared_resources_data_source_ios.h b/ios/web/webui/shared_resources_data_source_ios.h
index 82bddd4..134ff81 100644
--- a/ios/web/webui/shared_resources_data_source_ios.h
+++ b/ios/web/webui/shared_resources_data_source_ios.h
@@ -18,9 +18,8 @@
// web::URLDataSourceIOS implementation.
std::string GetSource() const override;
- void StartDataRequest(
- const std::string& path,
- const URLDataSourceIOS::GotDataCallback& callback) override;
+ void StartDataRequest(const std::string& path,
+ URLDataSourceIOS::GotDataCallback callback) override;
std::string GetMimeType(const std::string& path) const override;
private:
diff --git a/ios/web/webui/shared_resources_data_source_ios.mm b/ios/web/webui/shared_resources_data_source_ios.mm
index 9578687..53484b6 100644
--- a/ios/web/webui/shared_resources_data_source_ios.mm
+++ b/ios/web/webui/shared_resources_data_source_ios.mm
@@ -49,7 +49,7 @@
void SharedResourcesDataSourceIOS::StartDataRequest(
const std::string& path,
- const URLDataSourceIOS::GotDataCallback& callback) {
+ URLDataSourceIOS::GotDataCallback callback) {
const GritResourceMap* resource = PathToResource(path);
DCHECK(resource) << " path: " << path;
scoped_refptr<base::RefCountedMemory> bytes;
@@ -64,7 +64,7 @@
bytes = web_client->GetDataResourceBytes(idr);
}
- callback.Run(bytes.get());
+ std::move(callback).Run(bytes.get());
}
std::string SharedResourcesDataSourceIOS::GetMimeType(
diff --git a/ios/web/webui/web_ui_ios_data_source_impl.h b/ios/web/webui/web_ui_ios_data_source_impl.h
index 9335e64..405b566c 100644
--- a/ios/web/webui/web_ui_ios_data_source_impl.h
+++ b/ios/web/webui/web_ui_ios_data_source_impl.h
@@ -40,9 +40,8 @@
~WebUIIOSDataSourceImpl() override;
// Completes a request by sending our dictionary of localized strings.
- void SendLocalizedStringsAsJSON(
- const URLDataSourceIOS::GotDataCallback& callback,
- bool from_js_module);
+ void SendLocalizedStringsAsJSON(URLDataSourceIOS::GotDataCallback callback,
+ bool from_js_module);
private:
class InternalDataSource;
@@ -60,7 +59,7 @@
std::string GetSource() const;
std::string GetMimeType(const std::string& path) const;
void StartDataRequest(const std::string& path,
- const URLDataSourceIOS::GotDataCallback& callback);
+ URLDataSourceIOS::GotDataCallback callback);
int PathToIdrOrDefault(const std::string& path) const;
diff --git a/ios/web/webui/web_ui_ios_data_source_impl.mm b/ios/web/webui/web_ui_ios_data_source_impl.mm
index ad48885..edd2f97 100644
--- a/ios/web/webui/web_ui_ios_data_source_impl.mm
+++ b/ios/web/webui/web_ui_ios_data_source_impl.mm
@@ -44,10 +44,9 @@
std::string GetMimeType(const std::string& path) const override {
return parent_->GetMimeType(path);
}
- void StartDataRequest(
- const std::string& path,
- const URLDataSourceIOS::GotDataCallback& callback) override {
- return parent_->StartDataRequest(path, callback);
+ void StartDataRequest(const std::string& path,
+ URLDataSourceIOS::GotDataCallback callback) override {
+ return parent_->StartDataRequest(path, std::move(callback));
}
bool ShouldReplaceExistingSource() const override {
return parent_->replace_existing_source_;
@@ -159,13 +158,13 @@
void WebUIIOSDataSourceImpl::StartDataRequest(
const std::string& path,
- const URLDataSourceIOS::GotDataCallback& callback) {
+ URLDataSourceIOS::GotDataCallback callback) {
EnsureLoadTimeDataDefaultsAdded();
if (use_strings_js_) {
bool from_js_module = path == "strings.m.js";
if (from_js_module || path == "strings.js") {
- SendLocalizedStringsAsJSON(callback, from_js_module);
+ SendLocalizedStringsAsJSON(std::move(callback), from_js_module);
return;
}
}
@@ -174,15 +173,15 @@
DCHECK_NE(resource_id, -1);
scoped_refptr<base::RefCountedMemory> response(
GetWebClient()->GetDataResourceBytes(resource_id));
- callback.Run(response);
+ std::move(callback).Run(response);
}
void WebUIIOSDataSourceImpl::SendLocalizedStringsAsJSON(
- const URLDataSourceIOS::GotDataCallback& callback,
+ URLDataSourceIOS::GotDataCallback callback,
bool from_js_module) {
std::string template_data;
webui::AppendJsonJS(&localized_strings_, &template_data, from_js_module);
- callback.Run(base::RefCountedString::TakeString(&template_data));
+ std::move(callback).Run(base::RefCountedString::TakeString(&template_data));
}
int WebUIIOSDataSourceImpl::PathToIdrOrDefault(const std::string& path) const {