Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1518)

Unified Diff: chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc

Issue 2867713002: Use OnceCallback on Mojo interfaces in //chrome/common/media_router (Closed)
Patch Set: rebase. +#include Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc
diff --git a/chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc b/chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc
index bb2cccce1de02a5df207238e1a23702a2b3c0a02..3953b183484a789b652f7b1d90198216a4e94b62 100644
--- a/chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc
+++ b/chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.cc
@@ -6,6 +6,8 @@
#include <utility>
+#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
@@ -18,11 +20,12 @@ SafeDialDeviceDescriptionParser::~SafeDialDeviceDescriptionParser() {}
void SafeDialDeviceDescriptionParser::Start(
const std::string& xml_text,
- const DeviceDescriptionCallback& callback) {
+ DeviceDescriptionCallback callback) {
mark a. foltz 2017/05/09 22:28:44 Can this just be a base::RepeatingCallback instead
tzik 2017/05/11 09:00:30 So, the callback is not from Mojo-generated code?
zhaobin 2017/05/11 17:38:57 The callback is from mojo-generated code. using
tzik 2017/05/15 06:28:15 Right, the callback type was from Mojo. But, as th
DVLOG(2) << "Start parsing device description...";
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(callback);
+ auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
if (!utility_process_mojo_client_) {
DVLOG(2) << "Start utility process in background...";
@@ -33,7 +36,7 @@ void SafeDialDeviceDescriptionParser::Start(
IDS_UTILITY_PROCESS_DIAL_DEVICE_DESCRIPTION_PARSER_NAME));
utility_process_mojo_client_->set_error_callback(
- base::Bind(callback, nullptr));
+ base::Bind(copyable_callback, nullptr));
// This starts utility process in the background.
utility_process_mojo_client_->Start();
@@ -41,8 +44,8 @@ void SafeDialDeviceDescriptionParser::Start(
// This call is queued up until the Mojo message pipe has been established to
// the service running in the utility process.
- utility_process_mojo_client_->service()->ParseDialDeviceDescription(xml_text,
- callback);
+ utility_process_mojo_client_->service()->ParseDialDeviceDescription(
+ xml_text, copyable_callback);
}
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698