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 | 11 |
12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/threading/worker_pool.h" | 22 #include "base/threading/worker_pool.h" |
| 23 #include "base/time/default_clock.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
24 #include "google_apis/gcm/base/mcs_message.h" | 25 #include "google_apis/gcm/base/mcs_message.h" |
25 #include "google_apis/gcm/base/mcs_util.h" | 26 #include "google_apis/gcm/base/mcs_util.h" |
26 #include "google_apis/gcm/engine/connection_factory_impl.h" | 27 #include "google_apis/gcm/engine/connection_factory_impl.h" |
27 #include "google_apis/gcm/engine/mcs_client.h" | 28 #include "google_apis/gcm/engine/mcs_client.h" |
28 #include "net/base/host_mapping_rules.h" | 29 #include "net/base/host_mapping_rules.h" |
29 #include "net/base/net_log_logger.h" | 30 #include "net/base/net_log_logger.h" |
30 #include "net/cert/cert_verifier.h" | 31 #include "net/cert/cert_verifier.h" |
31 #include "net/dns/host_resolver.h" | 32 #include "net/dns/host_resolver.h" |
32 #include "net/http/http_auth_handler_factory.h" | 33 #include "net/http/http_auth_handler_factory.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 uint64 secret() const { return secret_; } | 165 uint64 secret() const { return secret_; } |
165 | 166 |
166 private: | 167 private: |
167 void InitializeNetworkState(); | 168 void InitializeNetworkState(); |
168 void BuildNetworkSession(); | 169 void BuildNetworkSession(); |
169 | 170 |
170 void InitializationCallback(bool success, | 171 void InitializationCallback(bool success, |
171 uint64 restored_android_id, | 172 uint64 restored_android_id, |
172 uint64 restored_security_token); | 173 uint64 restored_security_token); |
173 | 174 |
| 175 base::DefaultClock clock_; |
| 176 |
174 CommandLine command_line_; | 177 CommandLine command_line_; |
175 | 178 |
176 base::FilePath rmq_path_; | 179 base::FilePath rmq_path_; |
177 uint64 android_id_; | 180 uint64 android_id_; |
178 uint64 secret_; | 181 uint64 secret_; |
179 std::string server_host_; | 182 std::string server_host_; |
180 int server_port_; | 183 int server_port_; |
181 | 184 |
182 // Network state. | 185 // Network state. |
183 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 186 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void MCSProbe::Start() { | 247 void MCSProbe::Start() { |
245 file_thread_.Start(); | 248 file_thread_.Start(); |
246 InitializeNetworkState(); | 249 InitializeNetworkState(); |
247 BuildNetworkSession(); | 250 BuildNetworkSession(); |
248 connection_factory_.reset( | 251 connection_factory_.reset( |
249 new ConnectionFactoryImpl(GURL("https://" + net::HostPortPair( | 252 new ConnectionFactoryImpl(GURL("https://" + net::HostPortPair( |
250 server_host_, server_port_).ToString()), | 253 server_host_, server_port_).ToString()), |
251 network_session_, | 254 network_session_, |
252 &net_log_)); | 255 &net_log_)); |
253 rmq_store_.reset(new RMQStore(rmq_path_, file_thread_.message_loop_proxy())); | 256 rmq_store_.reset(new RMQStore(rmq_path_, file_thread_.message_loop_proxy())); |
254 mcs_client_.reset(new MCSClient(connection_factory_.get(), | 257 mcs_client_.reset(new MCSClient(&clock_, |
| 258 connection_factory_.get(), |
255 rmq_store_.get())); | 259 rmq_store_.get())); |
256 run_loop_.reset(new base::RunLoop()); | 260 run_loop_.reset(new base::RunLoop()); |
257 rmq_store_->Load(base::Bind(&MCSClient::Initialize, | 261 rmq_store_->Load(base::Bind(&MCSClient::Initialize, |
258 base::Unretained(mcs_client_.get()), | 262 base::Unretained(mcs_client_.get()), |
259 base::Bind(&MCSProbe::InitializationCallback, | 263 base::Bind(&MCSProbe::InitializationCallback, |
260 base::Unretained(this)), | 264 base::Unretained(this)), |
261 base::Bind(&MessageReceivedCallback), | 265 base::Bind(&MessageReceivedCallback), |
262 base::Bind(&MessageSentCallback))); | 266 base::Bind(&MessageSentCallback))); |
263 run_loop_->Run(); | 267 run_loop_->Run(); |
264 } | 268 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 370 |
367 return 0; | 371 return 0; |
368 } | 372 } |
369 | 373 |
370 } // namespace | 374 } // namespace |
371 } // namespace gcm | 375 } // namespace gcm |
372 | 376 |
373 int main(int argc, char* argv[]) { | 377 int main(int argc, char* argv[]) { |
374 return gcm::MCSProbeMain(argc, argv); | 378 return gcm::MCSProbeMain(argc, argv); |
375 } | 379 } |
OLD | NEW |