OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
23 #include "base/threading/worker_pool.h" | 23 #include "base/threading/worker_pool.h" |
24 #include "base/time/default_clock.h" | 24 #include "base/time/default_clock.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
| 26 #include "google_apis/gcm/base/fake_encryptor.h" |
26 #include "google_apis/gcm/base/mcs_message.h" | 27 #include "google_apis/gcm/base/mcs_message.h" |
27 #include "google_apis/gcm/base/mcs_util.h" | 28 #include "google_apis/gcm/base/mcs_util.h" |
28 #include "google_apis/gcm/engine/checkin_request.h" | 29 #include "google_apis/gcm/engine/checkin_request.h" |
29 #include "google_apis/gcm/engine/connection_factory_impl.h" | 30 #include "google_apis/gcm/engine/connection_factory_impl.h" |
30 #include "google_apis/gcm/engine/gcm_store_impl.h" | 31 #include "google_apis/gcm/engine/gcm_store_impl.h" |
31 #include "google_apis/gcm/engine/gservices_settings.h" | 32 #include "google_apis/gcm/engine/gservices_settings.h" |
32 #include "google_apis/gcm/engine/mcs_client.h" | 33 #include "google_apis/gcm/engine/mcs_client.h" |
33 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 34 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
34 #include "net/base/host_mapping_rules.h" | 35 #include "net/base/host_mapping_rules.h" |
35 #include "net/base/net_log_logger.h" | 36 #include "net/base/net_log_logger.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 scoped_refptr<net::HttpNetworkSession> network_session_; | 243 scoped_refptr<net::HttpNetworkSession> network_session_; |
243 scoped_ptr<net::ProxyService> proxy_service_; | 244 scoped_ptr<net::ProxyService> proxy_service_; |
244 | 245 |
245 GCMStatsRecorder recorder_; | 246 GCMStatsRecorder recorder_; |
246 scoped_ptr<GCMStore> gcm_store_; | 247 scoped_ptr<GCMStore> gcm_store_; |
247 scoped_ptr<MCSClient> mcs_client_; | 248 scoped_ptr<MCSClient> mcs_client_; |
248 scoped_ptr<CheckinRequest> checkin_request_; | 249 scoped_ptr<CheckinRequest> checkin_request_; |
249 | 250 |
250 scoped_ptr<ConnectionFactoryImpl> connection_factory_; | 251 scoped_ptr<ConnectionFactoryImpl> connection_factory_; |
251 | 252 |
| 253 FakeEncryptor fake_encryptor_; |
| 254 |
252 base::Thread file_thread_; | 255 base::Thread file_thread_; |
253 | 256 |
254 scoped_ptr<base::RunLoop> run_loop_; | 257 scoped_ptr<base::RunLoop> run_loop_; |
255 }; | 258 }; |
256 | 259 |
257 MCSProbe::MCSProbe( | 260 MCSProbe::MCSProbe( |
258 const CommandLine& command_line, | 261 const CommandLine& command_line, |
259 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) | 262 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
260 : command_line_(command_line), | 263 : command_line_(command_line), |
261 gcm_store_path_(base::FilePath(FILE_PATH_LITERAL("gcm_store"))), | 264 gcm_store_path_(base::FilePath(FILE_PATH_LITERAL("gcm_store"))), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 net::HostPortPair(server_host_, | 302 net::HostPortPair(server_host_, |
300 server_port_).ToString())); | 303 server_port_).ToString())); |
301 connection_factory_.reset( | 304 connection_factory_.reset( |
302 new ConnectionFactoryImpl(endpoints, | 305 new ConnectionFactoryImpl(endpoints, |
303 kDefaultBackoffPolicy, | 306 kDefaultBackoffPolicy, |
304 network_session_, | 307 network_session_, |
305 &net_log_, | 308 &net_log_, |
306 &recorder_)); | 309 &recorder_)); |
307 gcm_store_.reset( | 310 gcm_store_.reset( |
308 new GCMStoreImpl(gcm_store_path_, | 311 new GCMStoreImpl(gcm_store_path_, |
309 file_thread_.message_loop_proxy())); | 312 file_thread_.message_loop_proxy(), |
| 313 &fake_encryptor_)); |
310 mcs_client_.reset(new MCSClient("probe", | 314 mcs_client_.reset(new MCSClient("probe", |
311 &clock_, | 315 &clock_, |
312 connection_factory_.get(), | 316 connection_factory_.get(), |
313 gcm_store_.get(), | 317 gcm_store_.get(), |
314 &recorder_)); | 318 &recorder_)); |
315 run_loop_.reset(new base::RunLoop()); | 319 run_loop_.reset(new base::RunLoop()); |
316 gcm_store_->Load(base::Bind(&MCSProbe::LoadCallback, | 320 gcm_store_->Load(base::Bind(&MCSProbe::LoadCallback, |
317 base::Unretained(this))); | 321 base::Unretained(this))); |
318 run_loop_->Run(); | 322 run_loop_->Run(); |
319 } | 323 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 501 |
498 return 0; | 502 return 0; |
499 } | 503 } |
500 | 504 |
501 } // namespace | 505 } // namespace |
502 } // namespace gcm | 506 } // namespace gcm |
503 | 507 |
504 int main(int argc, char* argv[]) { | 508 int main(int argc, char* argv[]) { |
505 return gcm::MCSProbeMain(argc, argv); | 509 return gcm::MCSProbeMain(argc, argv); |
506 } | 510 } |
OLD | NEW |