| OLD | NEW |
| 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/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "google_apis/google_api_keys.h" | 10 #include "google_apis/google_api_keys.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 void HostStarter::OnGetUserInfoResponse(const std::string& user_email) { | 100 void HostStarter::OnGetUserInfoResponse(const std::string& user_email) { |
| 101 if (!main_task_runner_->BelongsToCurrentThread()) { | 101 if (!main_task_runner_->BelongsToCurrentThread()) { |
| 102 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 102 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 103 &HostStarter::OnGetUserInfoResponse, weak_ptr_, user_email)); | 103 &HostStarter::OnGetUserInfoResponse, weak_ptr_, user_email)); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 user_email_ = user_email; | 106 user_email_ = user_email; |
| 107 // Register the host. | 107 // Register the host. |
| 108 host_id_ = base::GenerateGUID(); | 108 host_id_ = base::GenerateGUID(); |
| 109 key_pair_.Generate(); | 109 key_pair_ = RsaKeyPair::Generate(); |
| 110 service_client_->RegisterHost( | 110 service_client_->RegisterHost( |
| 111 host_id_, host_name_, key_pair_.GetPublicKey(), access_token_, this); | 111 host_id_, host_name_, key_pair_->GetPublicKey(), access_token_, this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void HostStarter::OnHostRegistered() { | 114 void HostStarter::OnHostRegistered() { |
| 115 if (!main_task_runner_->BelongsToCurrentThread()) { | 115 if (!main_task_runner_->BelongsToCurrentThread()) { |
| 116 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 116 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 117 &HostStarter::OnHostRegistered, weak_ptr_)); | 117 &HostStarter::OnHostRegistered, weak_ptr_)); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 // Start the host. | 120 // Start the host. |
| 121 std::string host_secret_hash = remoting::MakeHostPinHash(host_id_, host_pin_); | 121 std::string host_secret_hash = remoting::MakeHostPinHash(host_id_, host_pin_); |
| 122 scoped_ptr<base::DictionaryValue> config(new base::DictionaryValue()); | 122 scoped_ptr<base::DictionaryValue> config(new base::DictionaryValue()); |
| 123 config->SetString("xmpp_login", user_email_); | 123 config->SetString("xmpp_login", user_email_); |
| 124 config->SetString("oauth_refresh_token", refresh_token_); | 124 config->SetString("oauth_refresh_token", refresh_token_); |
| 125 config->SetString("host_id", host_id_); | 125 config->SetString("host_id", host_id_); |
| 126 config->SetString("host_name", host_name_); | 126 config->SetString("host_name", host_name_); |
| 127 config->SetString("private_key", key_pair_.GetAsString()); | 127 config->SetString("private_key", key_pair_->ToString()); |
| 128 config->SetString("host_secret_hash", host_secret_hash); | 128 config->SetString("host_secret_hash", host_secret_hash); |
| 129 daemon_controller_->SetConfigAndStart( | 129 daemon_controller_->SetConfigAndStart( |
| 130 config.Pass(), consent_to_data_collection_, | 130 config.Pass(), consent_to_data_collection_, |
| 131 base::Bind(&HostStarter::OnHostStarted, base::Unretained(this))); | 131 base::Bind(&HostStarter::OnHostStarted, base::Unretained(this))); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void HostStarter::OnHostStarted(DaemonController::AsyncResult result) { | 134 void HostStarter::OnHostStarted(DaemonController::AsyncResult result) { |
| 135 if (!main_task_runner_->BelongsToCurrentThread()) { | 135 if (!main_task_runner_->BelongsToCurrentThread()) { |
| 136 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 136 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 137 &HostStarter::OnHostStarted, weak_ptr_, result)); | 137 &HostStarter::OnHostStarted, weak_ptr_, result)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 175 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 176 &HostStarter::OnHostUnregistered, weak_ptr_)); | 176 &HostStarter::OnHostUnregistered, weak_ptr_)); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 CompletionCallback cb = on_done_; | 179 CompletionCallback cb = on_done_; |
| 180 on_done_.Reset(); | 180 on_done_.Reset(); |
| 181 cb.Run(START_ERROR); | 181 cb.Run(START_ERROR); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace remoting | 184 } // namespace remoting |
| OLD | NEW |