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

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 10007048: Cleanup and simplify HostConfig and JsonHostConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/plugin/daemon_controller_mac.cc ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file implements a standalone host process for Me2Me, which is currently 5 // This file implements a standalone host process for Me2Me, which is currently
6 // used for the Linux-only Virtual Me2Me build. 6 // used for the Linux-only Virtual Me2Me build.
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void StartWatchingNatPolicy() { 148 void StartWatchingNatPolicy() {
149 nat_policy_.reset( 149 nat_policy_.reset(
150 policy_hack::NatPolicy::Create(file_io_thread_.message_loop_proxy())); 150 policy_hack::NatPolicy::Create(file_io_thread_.message_loop_proxy()));
151 nat_policy_->StartWatching( 151 nat_policy_->StartWatching(
152 base::Bind(&HostProcess::OnNatPolicyUpdate, base::Unretained(this))); 152 base::Bind(&HostProcess::OnNatPolicyUpdate, base::Unretained(this)));
153 } 153 }
154 154
155 // Read Host config from disk, returning true if successful. 155 // Read Host config from disk, returning true if successful.
156 bool LoadConfig(base::MessageLoopProxy* io_message_loop, 156 bool LoadConfig(base::MessageLoopProxy* io_message_loop,
157 bool* tokens_pending) { 157 bool* tokens_pending) {
158 scoped_refptr<JsonHostConfig> host_config = 158 JsonHostConfig host_config(host_config_path_);
159 new JsonHostConfig(host_config_path_, io_message_loop); 159 JsonHostConfig auth_config(auth_config_path_);
160 scoped_refptr<JsonHostConfig> auth_config =
161 new JsonHostConfig(auth_config_path_, io_message_loop);
162 160
163 FilePath failed_path; 161 FilePath failed_path;
164 if (!host_config->Read()) { 162 if (!host_config.Read()) {
165 failed_path = host_config_path_; 163 failed_path = host_config_path_;
166 } else if (!auth_config->Read()) { 164 } else if (!auth_config.Read()) {
167 failed_path = auth_config_path_; 165 failed_path = auth_config_path_;
168 } 166 }
169 if (!failed_path.empty()) { 167 if (!failed_path.empty()) {
170 LOG(ERROR) << "Failed to read configuration file " << failed_path.value(); 168 LOG(ERROR) << "Failed to read configuration file " << failed_path.value();
171 return false; 169 return false;
172 } 170 }
173 171
174 if (!host_config->GetString(kHostIdConfigPath, &host_id_)) { 172 if (!host_config.GetString(kHostIdConfigPath, &host_id_)) {
175 LOG(ERROR) << "host_id is not defined in the config."; 173 LOG(ERROR) << "host_id is not defined in the config.";
176 return false; 174 return false;
177 } 175 }
178 176
179 if (!key_pair_.Load(host_config)) { 177 if (!key_pair_.Load(host_config)) {
180 return false; 178 return false;
181 } 179 }
182 180
183 std::string host_secret_hash_string; 181 std::string host_secret_hash_string;
184 if (!host_config->GetString(kHostSecretHashConfigPath, 182 if (!host_config.GetString(kHostSecretHashConfigPath,
185 &host_secret_hash_string)) { 183 &host_secret_hash_string)) {
186 host_secret_hash_string = "plain:"; 184 host_secret_hash_string = "plain:";
187 } 185 }
188 186
189 if (!host_secret_hash_.Parse(host_secret_hash_string)) { 187 if (!host_secret_hash_.Parse(host_secret_hash_string)) {
190 LOG(ERROR) << "Invalid host_secret_hash."; 188 LOG(ERROR) << "Invalid host_secret_hash.";
191 return false; 189 return false;
192 } 190 }
193 191
194 // Use an XMPP connection to the Talk network for session signalling. 192 // Use an XMPP connection to the Talk network for session signalling.
195 if (!auth_config->GetString(kXmppLoginConfigPath, &xmpp_login_) || 193 if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) ||
196 !(auth_config->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) || 194 !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) ||
197 auth_config->GetString(kOAuthRefreshTokenConfigPath, 195 auth_config.GetString(kOAuthRefreshTokenConfigPath,
198 &oauth_refresh_token_))) { 196 &oauth_refresh_token_))) {
199 LOG(ERROR) << "XMPP credentials are not defined in the config."; 197 LOG(ERROR) << "XMPP credentials are not defined in the config.";
200 return false; 198 return false;
201 } 199 }
202 200
203 *tokens_pending = oauth_refresh_token_ != ""; 201 *tokens_pending = oauth_refresh_token_ != "";
204 if (*tokens_pending) { 202 if (*tokens_pending) {
205 xmpp_auth_token_ = ""; // This will be set to the access token later. 203 xmpp_auth_token_ = ""; // This will be set to the access token later.
206 xmpp_auth_service_ = "oauth2"; 204 xmpp_auth_service_ = "oauth2";
207 } else if (!auth_config->GetString(kXmppAuthServiceConfigPath, 205 } else if (!auth_config.GetString(kXmppAuthServiceConfigPath,
208 &xmpp_auth_service_)) { 206 &xmpp_auth_service_)) {
209 // For the me2me host, we default to ClientLogin token for chromiumsync 207 // For the me2me host, we default to ClientLogin token for chromiumsync
210 // because earlier versions of the host had no HTTP stack with which to 208 // because earlier versions of the host had no HTTP stack with which to
211 // request an OAuth2 access token. 209 // request an OAuth2 access token.
212 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; 210 xmpp_auth_service_ = kChromotingTokenDefaultServiceName;
213 } 211 }
214 return true; 212 return true;
215 } 213 }
216 214
217 void OnNatPolicyUpdate(bool nat_traversal_enabled) { 215 void OnNatPolicyUpdate(bool nat_traversal_enabled) {
218 if (!context_->network_message_loop()->BelongsToCurrentThread()) { 216 if (!context_->network_message_loop()->BelongsToCurrentThread()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 int CALLBACK WinMain(HINSTANCE instance, 374 int CALLBACK WinMain(HINSTANCE instance,
377 HINSTANCE previous_instance, 375 HINSTANCE previous_instance,
378 LPSTR command_line, 376 LPSTR command_line,
379 int show_command) { 377 int show_command) {
380 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 378 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
381 // the command line from GetCommandLineW(), so we can safely pass NULL here. 379 // the command line from GetCommandLineW(), so we can safely pass NULL here.
382 return main(0, NULL); 380 return main(0, NULL);
383 } 381 }
384 382
385 #endif 383 #endif
OLDNEW
« no previous file with comments | « remoting/host/plugin/daemon_controller_mac.cc ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698