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

Side by Side Diff: google_apis/gcm/tools/mcs_probe.cc

Issue 819193002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « google_apis/gaia/gaia_urls.cc ('k') | google_apis/google_api_keys.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // A standalone tool for testing MCS connections and the MCS client on their 5 // A standalone tool for testing MCS connections and the MCS client on their
6 // own. 6 // own.
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdio> 9 #include <cstdio>
10 #include <string> 10 #include <string>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 void CancelRequest(RequestHandle req) override { 182 void CancelRequest(RequestHandle req) override {
183 // Do nothing. 183 // Do nothing.
184 } 184 }
185 }; 185 };
186 186
187 class MCSProbe { 187 class MCSProbe {
188 public: 188 public:
189 MCSProbe( 189 MCSProbe(
190 const CommandLine& command_line, 190 const base::CommandLine& command_line,
191 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); 191 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
192 ~MCSProbe(); 192 ~MCSProbe();
193 193
194 void Start(); 194 void Start();
195 195
196 uint64 android_id() const { return android_id_; } 196 uint64 android_id() const { return android_id_; }
197 uint64 secret() const { return secret_; } 197 uint64 secret() const { return secret_; }
198 198
199 private: 199 private:
200 void CheckIn(); 200 void CheckIn();
201 void InitializeNetworkState(); 201 void InitializeNetworkState();
202 void BuildNetworkSession(); 202 void BuildNetworkSession();
203 203
204 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result); 204 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result);
205 void UpdateCallback(bool success); 205 void UpdateCallback(bool success);
206 void ErrorCallback(); 206 void ErrorCallback();
207 void OnCheckInCompleted( 207 void OnCheckInCompleted(
208 const checkin_proto::AndroidCheckinResponse& checkin_response); 208 const checkin_proto::AndroidCheckinResponse& checkin_response);
209 void StartMCSLogin(); 209 void StartMCSLogin();
210 210
211 base::DefaultClock clock_; 211 base::DefaultClock clock_;
212 212
213 CommandLine command_line_; 213 base::CommandLine command_line_;
214 214
215 base::FilePath gcm_store_path_; 215 base::FilePath gcm_store_path_;
216 uint64 android_id_; 216 uint64 android_id_;
217 uint64 secret_; 217 uint64 secret_;
218 std::string server_host_; 218 std::string server_host_;
219 int server_port_; 219 int server_port_;
220 220
221 // Network state. 221 // Network state.
222 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 222 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
223 net::NetLog net_log_; 223 net::NetLog net_log_;
(...skipping 15 matching lines...) Expand all
239 scoped_ptr<CheckinRequest> checkin_request_; 239 scoped_ptr<CheckinRequest> checkin_request_;
240 240
241 scoped_ptr<ConnectionFactoryImpl> connection_factory_; 241 scoped_ptr<ConnectionFactoryImpl> connection_factory_;
242 242
243 base::Thread file_thread_; 243 base::Thread file_thread_;
244 244
245 scoped_ptr<base::RunLoop> run_loop_; 245 scoped_ptr<base::RunLoop> run_loop_;
246 }; 246 };
247 247
248 MCSProbe::MCSProbe( 248 MCSProbe::MCSProbe(
249 const CommandLine& command_line, 249 const base::CommandLine& command_line,
250 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) 250 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
251 : command_line_(command_line), 251 : command_line_(command_line),
252 gcm_store_path_(base::FilePath(FILE_PATH_LITERAL("gcm_store"))), 252 gcm_store_path_(base::FilePath(FILE_PATH_LITERAL("gcm_store"))),
253 android_id_(0), 253 android_id_(0),
254 secret_(0), 254 secret_(0),
255 server_port_(0), 255 server_port_(0),
256 url_request_context_getter_(url_request_context_getter), 256 url_request_context_getter_(url_request_context_getter),
257 file_thread_("FileThread") { 257 file_thread_("FileThread") {
258 if (command_line.HasSwitch(kRMQFileName)) { 258 if (command_line.HasSwitch(kRMQFileName)) {
259 gcm_store_path_ = command_line.GetSwitchValuePath(kRMQFileName); 259 gcm_store_path_ = command_line.GetSwitchValuePath(kRMQFileName);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 463
464 void MCSProbe::StartMCSLogin() { 464 void MCSProbe::StartMCSLogin() {
465 LOG(INFO) << "MCS login initiated."; 465 LOG(INFO) << "MCS login initiated.";
466 466
467 mcs_client_->Login(android_id_, secret_); 467 mcs_client_->Login(android_id_, secret_);
468 } 468 }
469 469
470 int MCSProbeMain(int argc, char* argv[]) { 470 int MCSProbeMain(int argc, char* argv[]) {
471 base::AtExitManager exit_manager; 471 base::AtExitManager exit_manager;
472 472
473 CommandLine::Init(argc, argv); 473 base::CommandLine::Init(argc, argv);
474 logging::LoggingSettings settings; 474 logging::LoggingSettings settings;
475 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 475 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
476 logging::InitLogging(settings); 476 logging::InitLogging(settings);
477 477
478 base::MessageLoopForIO message_loop; 478 base::MessageLoopForIO message_loop;
479 479
480 // For check-in and creating registration ids. 480 // For check-in and creating registration ids.
481 const scoped_refptr<MyTestURLRequestContextGetter> context_getter = 481 const scoped_refptr<MyTestURLRequestContextGetter> context_getter =
482 new MyTestURLRequestContextGetter( 482 new MyTestURLRequestContextGetter(
483 base::MessageLoop::current()->message_loop_proxy()); 483 base::MessageLoop::current()->message_loop_proxy());
484 484
485 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 485 const base::CommandLine& command_line =
486 *base::CommandLine::ForCurrentProcess();
486 487
487 MCSProbe mcs_probe(command_line, context_getter); 488 MCSProbe mcs_probe(command_line, context_getter);
488 mcs_probe.Start(); 489 mcs_probe.Start();
489 490
490 base::RunLoop run_loop; 491 base::RunLoop run_loop;
491 run_loop.Run(); 492 run_loop.Run();
492 493
493 return 0; 494 return 0;
494 } 495 }
495 496
496 } // namespace 497 } // namespace
497 } // namespace gcm 498 } // namespace gcm
498 499
499 int main(int argc, char* argv[]) { 500 int main(int argc, char* argv[]) {
500 return gcm::MCSProbeMain(argc, argv); 501 return gcm::MCSProbeMain(argc, argv);
501 } 502 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_urls.cc ('k') | google_apis/google_api_keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698