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

Side by Side Diff: remoting/host/setup/host_starter.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: Fix start_host. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/setup/host_starter.h" 5 #include "remoting/host/setup/host_starter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 config->SetString("host_owner", host_owner_); 164 config->SetString("host_owner", host_owner_);
165 } 165 }
166 config->SetString("xmpp_login", xmpp_login_); 166 config->SetString("xmpp_login", xmpp_login_);
167 config->SetString("oauth_refresh_token", refresh_token_); 167 config->SetString("oauth_refresh_token", refresh_token_);
168 config->SetString("host_id", host_id_); 168 config->SetString("host_id", host_id_);
169 config->SetString("host_name", host_name_); 169 config->SetString("host_name", host_name_);
170 config->SetString("private_key", key_pair_->ToString()); 170 config->SetString("private_key", key_pair_->ToString());
171 config->SetString("host_secret_hash", host_secret_hash); 171 config->SetString("host_secret_hash", host_secret_hash);
172 daemon_controller_->SetConfigAndStart( 172 daemon_controller_->SetConfigAndStart(
173 config.Pass(), consent_to_data_collection_, 173 config.Pass(), consent_to_data_collection_,
174 base::Bind(&HostStarter::OnHostStarted, base::Unretained(this))); 174 base::Bind(&HostStarter::OnStartHostSucceeded, base::Unretained(this)),
175 base::Bind(&HostStarter::OnStartHostFailed, base::Unretained(this)));
175 } 176 }
176 177
177 void HostStarter::OnHostStarted(DaemonController::AsyncResult result) { 178 void HostStarter::OnStartHostSucceeded() {
178 if (!main_task_runner_->BelongsToCurrentThread()) { 179 if (!main_task_runner_->BelongsToCurrentThread()) {
179 main_task_runner_->PostTask(FROM_HERE, base::Bind( 180 main_task_runner_->PostTask(FROM_HERE, base::Bind(
180 &HostStarter::OnHostStarted, weak_ptr_, result)); 181 &HostStarter::OnStartHostSucceeded, weak_ptr_));
181 return;
182 }
183 if (result != DaemonController::RESULT_OK) {
184 unregistering_host_ = true;
185 service_client_->UnregisterHost(host_id_, access_token_, this);
186 return; 182 return;
187 } 183 }
188 base::ResetAndReturn(&on_done_).Run(START_COMPLETE); 184 base::ResetAndReturn(&on_done_).Run(START_COMPLETE);
189 } 185 }
190 186
187 void HostStarter::OnStartHostFailed(const std::string& error_message,
188 const tracked_objects::Location& location) {
189 if (!main_task_runner_->BelongsToCurrentThread()) {
190 main_task_runner_->PostTask(FROM_HERE, base::Bind(
191 &HostStarter::OnStartHostFailed, weak_ptr_, error_message, location));
192 return;
193 }
194
195 // start_host is a command-line tool, so the error has already been reported.
196 unregistering_host_ = true;
197 service_client_->UnregisterHost(host_id_, access_token_, this);
198 }
199
191 void HostStarter::OnOAuthError() { 200 void HostStarter::OnOAuthError() {
192 if (!main_task_runner_->BelongsToCurrentThread()) { 201 if (!main_task_runner_->BelongsToCurrentThread()) {
193 main_task_runner_->PostTask(FROM_HERE, base::Bind( 202 main_task_runner_->PostTask(FROM_HERE, base::Bind(
194 &HostStarter::OnOAuthError, weak_ptr_)); 203 &HostStarter::OnOAuthError, weak_ptr_));
195 return; 204 return;
196 } 205 }
197 if (unregistering_host_) { 206 if (unregistering_host_) {
198 LOG(ERROR) << "OAuth error occurred when unregistering host."; 207 LOG(ERROR) << "OAuth error occurred when unregistering host.";
199 } 208 }
200 209
(...skipping 18 matching lines...) Expand all
219 void HostStarter::OnHostUnregistered() { 228 void HostStarter::OnHostUnregistered() {
220 if (!main_task_runner_->BelongsToCurrentThread()) { 229 if (!main_task_runner_->BelongsToCurrentThread()) {
221 main_task_runner_->PostTask(FROM_HERE, base::Bind( 230 main_task_runner_->PostTask(FROM_HERE, base::Bind(
222 &HostStarter::OnHostUnregistered, weak_ptr_)); 231 &HostStarter::OnHostUnregistered, weak_ptr_));
223 return; 232 return;
224 } 233 }
225 base::ResetAndReturn(&on_done_).Run(START_ERROR); 234 base::ResetAndReturn(&on_done_).Run(START_ERROR);
226 } 235 }
227 236
228 } // namespace remoting 237 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698