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

Unified Diff: remoting/host/setup/daemon_controller.cc

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests. Created 5 years, 4 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: remoting/host/setup/daemon_controller.cc
diff --git a/remoting/host/setup/daemon_controller.cc b/remoting/host/setup/daemon_controller.cc
index dd413b4663aba176c78d352d4f934cf9fe9728fe..6ddb03ba3fbd0c62966a5e1ed5d113d71858fa56 100644
--- a/remoting/host/setup/daemon_controller.cc
+++ b/remoting/host/setup/daemon_controller.cc
@@ -50,36 +50,45 @@ void DaemonController::GetConfig(const GetConfigCallback& done) {
void DaemonController::SetConfigAndStart(
scoped_ptr<base::DictionaryValue> config,
bool consent,
- const CompletionCallback& done) {
+ const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
- DaemonController::CompletionCallback wrapped_done = base::Bind(
- &DaemonController::InvokeCompletionCallbackAndScheduleNext, this, done);
+ base::Closure wrapped_on_done = base::Bind(
+ &DaemonController::InvokeSuccessCallbackAndScheduleNext, this, on_done);
+ DaemonController::ErrorCallback wrapped_on_error = base::Bind(
+ &DaemonController::InvokeErrorCallbackAndScheduleNext, this, on_error);
Sergey Ulanov 2015/08/08 00:57:09 Do we need separate on_done and on_error cases? I
base::Closure request = base::Bind(
&DaemonController::DoSetConfigAndStart, this, base::Passed(&config),
- consent, wrapped_done);
+ consent, wrapped_on_done, wrapped_on_error);
ServiceOrQueueRequest(request);
}
void DaemonController::UpdateConfig(scoped_ptr<base::DictionaryValue> config,
- const CompletionCallback& done) {
+ const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
- DaemonController::CompletionCallback wrapped_done = base::Bind(
- &DaemonController::InvokeCompletionCallbackAndScheduleNext, this, done);
+ base::Closure wrapped_on_done = base::Bind(
+ &DaemonController::InvokeSuccessCallbackAndScheduleNext, this, on_done);
+ DaemonController::ErrorCallback wrapped_on_error = base::Bind(
+ &DaemonController::InvokeErrorCallbackAndScheduleNext, this, on_error);
base::Closure request = base::Bind(
&DaemonController::DoUpdateConfig, this, base::Passed(&config),
- wrapped_done);
+ wrapped_on_done, wrapped_on_error);
ServiceOrQueueRequest(request);
}
-void DaemonController::Stop(const CompletionCallback& done) {
+void DaemonController::Stop(const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
- DaemonController::CompletionCallback wrapped_done = base::Bind(
- &DaemonController::InvokeCompletionCallbackAndScheduleNext, this, done);
+ base::Closure wrapped_on_done = base::Bind(
+ &DaemonController::InvokeSuccessCallbackAndScheduleNext, this, on_done);
+ DaemonController::ErrorCallback wrapped_on_error = base::Bind(
+ &DaemonController::InvokeErrorCallbackAndScheduleNext, this, on_error);
base::Closure request = base::Bind(
- &DaemonController::DoStop, this, wrapped_done);
+ &DaemonController::DoStop, this, wrapped_on_done, wrapped_on_error);
ServiceOrQueueRequest(request);
}
@@ -114,24 +123,27 @@ void DaemonController::DoGetConfig(const GetConfigCallback& done) {
void DaemonController::DoSetConfigAndStart(
scoped_ptr<base::DictionaryValue> config,
bool consent,
- const CompletionCallback& done) {
+ const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(delegate_task_runner_->BelongsToCurrentThread());
- delegate_->SetConfigAndStart(config.Pass(), consent, done);
+ delegate_->SetConfigAndStart(config.Pass(), consent, on_done, on_error);
}
void DaemonController::DoUpdateConfig(
scoped_ptr<base::DictionaryValue> config,
- const CompletionCallback& done) {
+ const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(delegate_task_runner_->BelongsToCurrentThread());
- delegate_->UpdateConfig(config.Pass(), done);
+ delegate_->UpdateConfig(config.Pass(), on_done, on_error);
}
-void DaemonController::DoStop(const CompletionCallback& done) {
+void DaemonController::DoStop(const base::Closure& on_done,
+ const ErrorCallback& on_error) {
DCHECK(delegate_task_runner_->BelongsToCurrentThread());
- delegate_->Stop(done);
+ delegate_->Stop(on_done, on_error);
}
void DaemonController::DoGetUsageStatsConsent(
@@ -143,36 +155,51 @@ void DaemonController::DoGetUsageStatsConsent(
caller_task_runner_->PostTask(FROM_HERE, base::Bind(done, consent));
}
-void DaemonController::InvokeCompletionCallbackAndScheduleNext(
- const CompletionCallback& done,
- AsyncResult result) {
+void DaemonController::InvokeSuccessCallbackAndScheduleNext(
+ const base::Closure& callback) {
if (!caller_task_runner_->BelongsToCurrentThread()) {
caller_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&DaemonController::InvokeCompletionCallbackAndScheduleNext,
- this, done, result));
+ base::Bind(&DaemonController::InvokeSuccessCallbackAndScheduleNext,
+ this, callback));
return;
}
- done.Run(result);
+ callback.Run();
+ ScheduleNext();
+}
+
+void DaemonController::InvokeErrorCallbackAndScheduleNext(
+ const ErrorCallback& callback,
+ const std::string& error_message,
+ const tracked_objects::Location& location) {
+ if (!caller_task_runner_->BelongsToCurrentThread()) {
Sergey Ulanov 2015/08/08 00:57:09 Delegate interface definition says that the callba
+ caller_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DaemonController::InvokeErrorCallbackAndScheduleNext,
+ this, callback, error_message, location));
+ return;
+ }
+
+ callback.Run(error_message, location);
ScheduleNext();
}
void DaemonController::InvokeConfigCallbackAndScheduleNext(
- const GetConfigCallback& done,
+ const GetConfigCallback& callback,
scoped_ptr<base::DictionaryValue> config) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
- done.Run(config.Pass());
+ callback.Run(config.Pass());
ScheduleNext();
}
void DaemonController::InvokeConsentCallbackAndScheduleNext(
- const GetUsageStatsConsentCallback& done,
+ const GetUsageStatsConsentCallback& callback,
const UsageStatsConsent& consent) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
- done.Run(consent);
+ callback.Run(consent);
ScheduleNext();
}

Powered by Google App Engine
This is Rietveld 408576698