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

Side by Side Diff: remoting/host/simple_host_process.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/remoting_me2me_host.cc ('k') | no next file » | 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 is an application of a minimal host process in a Chromoting 5 // This is an application of a minimal host process in a Chromoting
6 // system. It serves the purpose of gluing different pieces together 6 // system. It serves the purpose of gluing different pieces together
7 // to make a functional host process for testing. 7 // to make a functional host process for testing.
8 // 8 //
9 // It peforms the following functionality: 9 // It peforms the following functionality:
10 // 1. Connect to the GTalk network and register the machine as a host. 10 // 1. Connect to the GTalk network and register the machine as a host.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 context_(NULL, message_loop_.message_loop_proxy()), 97 context_(NULL, message_loop_.message_loop_proxy()),
98 fake_(false), 98 fake_(false),
99 is_it2me_(false) { 99 is_it2me_(false) {
100 context_.Start(); 100 context_.Start();
101 file_io_thread_.Start(); 101 file_io_thread_.Start();
102 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 102 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
103 } 103 }
104 104
105 int Run() { 105 int Run() {
106 FilePath config_path = GetConfigPath(); 106 FilePath config_path = GetConfigPath();
107 scoped_refptr<JsonHostConfig> config = new JsonHostConfig( 107 JsonHostConfig config(config_path);
108 config_path, file_io_thread_.message_loop_proxy()); 108 if (!config.Read()) {
109 if (!config->Read()) {
110 LOG(ERROR) << "Failed to read configuration file " 109 LOG(ERROR) << "Failed to read configuration file "
111 << config_path.value(); 110 << config_path.value();
112 return 1; 111 return 1;
113 } 112 }
114 113
115 if (!config->GetString(kHostIdConfigPath, &host_id_)) { 114 if (!config.GetString(kHostIdConfigPath, &host_id_)) {
116 LOG(ERROR) << "host_id is not defined in the config."; 115 LOG(ERROR) << "host_id is not defined in the config.";
117 return 1; 116 return 1;
118 } 117 }
119 118
120 if (!key_pair_.Load(config)) { 119 if (!key_pair_.Load(config)) {
121 return 1; 120 return 1;
122 } 121 }
123 122
124 std::string host_secret_hash_string; 123 std::string host_secret_hash_string;
125 if (!config->GetString(kHostSecretHashConfigPath, 124 if (!config.GetString(kHostSecretHashConfigPath,
126 &host_secret_hash_string)) { 125 &host_secret_hash_string)) {
127 host_secret_hash_string = "plain:"; 126 host_secret_hash_string = "plain:";
128 } 127 }
129 128
130 if (!host_secret_hash_.Parse(host_secret_hash_string)) { 129 if (!host_secret_hash_.Parse(host_secret_hash_string)) {
131 LOG(ERROR) << "Invalid host_secret_hash."; 130 LOG(ERROR) << "Invalid host_secret_hash.";
132 return false; 131 return false;
133 } 132 }
134 133
135 // Use an XMPP connection to the Talk network for session signalling. 134 // Use an XMPP connection to the Talk network for session signalling.
136 if (!config->GetString(kXmppLoginConfigPath, &xmpp_login_) || 135 if (!config.GetString(kXmppLoginConfigPath, &xmpp_login_) ||
137 !config->GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_)) { 136 !config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_)) {
138 LOG(ERROR) << "XMPP credentials are not defined in the config."; 137 LOG(ERROR) << "XMPP credentials are not defined in the config.";
139 return 1; 138 return 1;
140 } 139 }
141 if (!config->GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) { 140 if (!config.GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) {
142 // For the simple host, we assume we always use the ClientLogin token for 141 // For the simple host, we assume we always use the ClientLogin token for
143 // chromiumsync because we do not have an HTTP stack with which we can 142 // chromiumsync because we do not have an HTTP stack with which we can
144 // easily request an OAuth2 access token even if we had a RefreshToken for 143 // easily request an OAuth2 access token even if we had a RefreshToken for
145 // the account. 144 // the account.
146 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; 145 xmpp_auth_service_ = kChromotingTokenDefaultServiceName;
147 } 146 }
148 147
149 context_.network_message_loop()->PostTask(FROM_HERE, base::Bind( 148 context_.network_message_loop()->PostTask(FROM_HERE, base::Bind(
150 &SimpleHost::StartHost, base::Unretained(this))); 149 &SimpleHost::StartHost, base::Unretained(this)));
151 150
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 max_port < 0 || max_port > 65535) { 370 max_port < 0 || max_port > 65535) {
372 LOG(ERROR) << "Invalid max-port value: " << max_port 371 LOG(ERROR) << "Invalid max-port value: " << max_port
373 << ". Expected integer in range [0, 65535]."; 372 << ". Expected integer in range [0, 65535].";
374 return 1; 373 return 1;
375 } 374 }
376 simple_host.network_settings()->max_port = max_port; 375 simple_host.network_settings()->max_port = max_port;
377 } 376 }
378 377
379 return simple_host.Run(); 378 return simple_host.Run();
380 } 379 }
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698