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

Side by Side Diff: remoting/host/setup/host_starter.cc

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename key_pair_ to local_key_pair_ Created 7 years, 9 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/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
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_ = new RsaKeyPair();
110 key_pair_->Generate();
110 service_client_->RegisterHost( 111 service_client_->RegisterHost(
111 host_id_, host_name_, key_pair_.GetPublicKey(), access_token_, this); 112 host_id_, host_name_, key_pair_->GetPublicKey(), access_token_, this);
112 } 113 }
113 114
114 void HostStarter::OnHostRegistered() { 115 void HostStarter::OnHostRegistered() {
115 if (!main_task_runner_->BelongsToCurrentThread()) { 116 if (!main_task_runner_->BelongsToCurrentThread()) {
116 main_task_runner_->PostTask(FROM_HERE, base::Bind( 117 main_task_runner_->PostTask(FROM_HERE, base::Bind(
117 &HostStarter::OnHostRegistered, weak_ptr_)); 118 &HostStarter::OnHostRegistered, weak_ptr_));
118 return; 119 return;
119 } 120 }
120 // Start the host. 121 // Start the host.
121 std::string host_secret_hash = remoting::MakeHostPinHash(host_id_, host_pin_); 122 std::string host_secret_hash = remoting::MakeHostPinHash(host_id_, host_pin_);
122 scoped_ptr<base::DictionaryValue> config(new base::DictionaryValue()); 123 scoped_ptr<base::DictionaryValue> config(new base::DictionaryValue());
123 config->SetString("xmpp_login", user_email_); 124 config->SetString("xmpp_login", user_email_);
124 config->SetString("oauth_refresh_token", refresh_token_); 125 config->SetString("oauth_refresh_token", refresh_token_);
125 config->SetString("host_id", host_id_); 126 config->SetString("host_id", host_id_);
126 config->SetString("host_name", host_name_); 127 config->SetString("host_name", host_name_);
127 config->SetString("private_key", key_pair_.GetAsString()); 128 config->SetString("private_key", key_pair_->GetAsString());
128 config->SetString("host_secret_hash", host_secret_hash); 129 config->SetString("host_secret_hash", host_secret_hash);
129 daemon_controller_->SetConfigAndStart( 130 daemon_controller_->SetConfigAndStart(
130 config.Pass(), consent_to_data_collection_, 131 config.Pass(), consent_to_data_collection_,
131 base::Bind(&HostStarter::OnHostStarted, base::Unretained(this))); 132 base::Bind(&HostStarter::OnHostStarted, base::Unretained(this)));
132 } 133 }
133 134
134 void HostStarter::OnHostStarted(DaemonController::AsyncResult result) { 135 void HostStarter::OnHostStarted(DaemonController::AsyncResult result) {
135 if (!main_task_runner_->BelongsToCurrentThread()) { 136 if (!main_task_runner_->BelongsToCurrentThread()) {
136 main_task_runner_->PostTask(FROM_HERE, base::Bind( 137 main_task_runner_->PostTask(FROM_HERE, base::Bind(
137 &HostStarter::OnHostStarted, weak_ptr_, result)); 138 &HostStarter::OnHostStarted, weak_ptr_, result));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 main_task_runner_->PostTask(FROM_HERE, base::Bind( 176 main_task_runner_->PostTask(FROM_HERE, base::Bind(
176 &HostStarter::OnHostUnregistered, weak_ptr_)); 177 &HostStarter::OnHostUnregistered, weak_ptr_));
177 return; 178 return;
178 } 179 }
179 CompletionCallback cb = on_done_; 180 CompletionCallback cb = on_done_;
180 on_done_.Reset(); 181 on_done_.Reset();
181 cb.Run(START_ERROR); 182 cb.Run(START_ERROR);
182 } 183 }
183 184
184 } // namespace remoting 185 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698