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 <stdint.h> |
| 9 |
8 #include <cstddef> | 10 #include <cstddef> |
9 #include <cstdio> | 11 #include <cstdio> |
10 #include <string> | 12 #include <string> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/at_exit.h" | 15 #include "base/at_exit.h" |
14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
16 #include "base/files/scoped_file.h" | 18 #include "base/files/scoped_file.h" |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
18 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
20 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
21 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
22 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
23 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
24 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
25 #include "base/threading/worker_pool.h" | 27 #include "base/threading/worker_pool.h" |
26 #include "base/time/default_clock.h" | 28 #include "base/time/default_clock.h" |
27 #include "base/values.h" | 29 #include "base/values.h" |
| 30 #include "build/build_config.h" |
28 #include "google_apis/gcm/base/fake_encryptor.h" | 31 #include "google_apis/gcm/base/fake_encryptor.h" |
29 #include "google_apis/gcm/base/mcs_message.h" | 32 #include "google_apis/gcm/base/mcs_message.h" |
30 #include "google_apis/gcm/base/mcs_util.h" | 33 #include "google_apis/gcm/base/mcs_util.h" |
31 #include "google_apis/gcm/engine/checkin_request.h" | 34 #include "google_apis/gcm/engine/checkin_request.h" |
32 #include "google_apis/gcm/engine/connection_factory_impl.h" | 35 #include "google_apis/gcm/engine/connection_factory_impl.h" |
33 #include "google_apis/gcm/engine/gcm_store_impl.h" | 36 #include "google_apis/gcm/engine/gcm_store_impl.h" |
34 #include "google_apis/gcm/engine/gservices_settings.h" | 37 #include "google_apis/gcm/engine/gservices_settings.h" |
35 #include "google_apis/gcm/engine/mcs_client.h" | 38 #include "google_apis/gcm/engine/mcs_client.h" |
36 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" | 39 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
37 #include "net/base/host_mapping_rules.h" | 40 #include "net/base/host_mapping_rules.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 86 |
84 // Don't use initial delay unless the last request was an error. | 87 // Don't use initial delay unless the last request was an error. |
85 false, | 88 false, |
86 }; | 89 }; |
87 | 90 |
88 // Default values used to communicate with the check-in server. | 91 // Default values used to communicate with the check-in server. |
89 const char kChromeVersion[] = "Chrome MCS Probe"; | 92 const char kChromeVersion[] = "Chrome MCS Probe"; |
90 | 93 |
91 // The default server to communicate with. | 94 // The default server to communicate with. |
92 const char kMCSServerHost[] = "mtalk.google.com"; | 95 const char kMCSServerHost[] = "mtalk.google.com"; |
93 const uint16 kMCSServerPort = 5228; | 96 const uint16_t kMCSServerPort = 5228; |
94 | 97 |
95 // Command line switches. | 98 // Command line switches. |
96 const char kRMQFileName[] = "rmq_file"; | 99 const char kRMQFileName[] = "rmq_file"; |
97 const char kAndroidIdSwitch[] = "android_id"; | 100 const char kAndroidIdSwitch[] = "android_id"; |
98 const char kSecretSwitch[] = "secret"; | 101 const char kSecretSwitch[] = "secret"; |
99 const char kLogFileSwitch[] = "log-file"; | 102 const char kLogFileSwitch[] = "log-file"; |
100 const char kIgnoreCertSwitch[] = "ignore-certs"; | 103 const char kIgnoreCertSwitch[] = "ignore-certs"; |
101 const char kServerHostSwitch[] = "host"; | 104 const char kServerHostSwitch[] = "host"; |
102 const char kServerPortSwitch[] = "port"; | 105 const char kServerPortSwitch[] = "port"; |
103 | 106 |
(...skipping 11 matching lines...) Expand all Loading... |
115 DVLOG(1) << " category: " << data_message.category(); | 118 DVLOG(1) << " category: " << data_message.category(); |
116 DVLOG(1) << " sent: " << data_message.sent(); | 119 DVLOG(1) << " sent: " << data_message.sent(); |
117 for (int i = 0; i < data_message.app_data_size(); ++i) { | 120 for (int i = 0; i < data_message.app_data_size(); ++i) { |
118 DVLOG(1) << " App data " << i << " " | 121 DVLOG(1) << " App data " << i << " " |
119 << data_message.app_data(i).key() << " : " | 122 << data_message.app_data(i).key() << " : " |
120 << data_message.app_data(i).value(); | 123 << data_message.app_data(i).value(); |
121 } | 124 } |
122 } | 125 } |
123 } | 126 } |
124 | 127 |
125 void MessageSentCallback(int64 user_serial_number, | 128 void MessageSentCallback(int64_t user_serial_number, |
126 const std::string& app_id, | 129 const std::string& app_id, |
127 const std::string& message_id, | 130 const std::string& message_id, |
128 MCSClient::MessageSendStatus status) { | 131 MCSClient::MessageSendStatus status) { |
129 LOG(INFO) << "Message sent. Serial number: " << user_serial_number | 132 LOG(INFO) << "Message sent. Serial number: " << user_serial_number |
130 << " Application ID: " << app_id | 133 << " Application ID: " << app_id |
131 << " Message ID: " << message_id | 134 << " Message ID: " << message_id |
132 << " Message send status: " << status; | 135 << " Message send status: " << status; |
133 } | 136 } |
134 | 137 |
135 // Needed to use a real host resolver. | 138 // Needed to use a real host resolver. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 211 |
209 class MCSProbe { | 212 class MCSProbe { |
210 public: | 213 public: |
211 MCSProbe( | 214 MCSProbe( |
212 const base::CommandLine& command_line, | 215 const base::CommandLine& command_line, |
213 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | 216 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); |
214 ~MCSProbe(); | 217 ~MCSProbe(); |
215 | 218 |
216 void Start(); | 219 void Start(); |
217 | 220 |
218 uint64 android_id() const { return android_id_; } | 221 uint64_t android_id() const { return android_id_; } |
219 uint64 secret() const { return secret_; } | 222 uint64_t secret() const { return secret_; } |
220 | 223 |
221 private: | 224 private: |
222 void CheckIn(); | 225 void CheckIn(); |
223 void InitializeNetworkState(); | 226 void InitializeNetworkState(); |
224 void BuildNetworkSession(); | 227 void BuildNetworkSession(); |
225 | 228 |
226 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result); | 229 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result); |
227 void UpdateCallback(bool success); | 230 void UpdateCallback(bool success); |
228 void ErrorCallback(); | 231 void ErrorCallback(); |
229 void OnCheckInCompleted( | 232 void OnCheckInCompleted( |
230 const checkin_proto::AndroidCheckinResponse& checkin_response); | 233 const checkin_proto::AndroidCheckinResponse& checkin_response); |
231 void StartMCSLogin(); | 234 void StartMCSLogin(); |
232 | 235 |
233 base::DefaultClock clock_; | 236 base::DefaultClock clock_; |
234 | 237 |
235 base::CommandLine command_line_; | 238 base::CommandLine command_line_; |
236 | 239 |
237 base::FilePath gcm_store_path_; | 240 base::FilePath gcm_store_path_; |
238 uint64 android_id_; | 241 uint64_t android_id_; |
239 uint64 secret_; | 242 uint64_t secret_; |
240 std::string server_host_; | 243 std::string server_host_; |
241 int server_port_; | 244 int server_port_; |
242 | 245 |
243 // Network state. | 246 // Network state. |
244 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 247 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
245 net::NetLog net_log_; | 248 net::NetLog net_log_; |
246 scoped_ptr<net::WriteToFileNetLogObserver> logger_; | 249 scoped_ptr<net::WriteToFileNetLogObserver> logger_; |
247 scoped_ptr<net::HostResolver> host_resolver_; | 250 scoped_ptr<net::HostResolver> host_resolver_; |
248 scoped_ptr<net::CertVerifier> cert_verifier_; | 251 scoped_ptr<net::CertVerifier> cert_verifier_; |
249 scoped_ptr<net::ChannelIDService> system_channel_id_service_; | 252 scoped_ptr<net::ChannelIDService> system_channel_id_service_; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 516 |
514 return 0; | 517 return 0; |
515 } | 518 } |
516 | 519 |
517 } // namespace | 520 } // namespace |
518 } // namespace gcm | 521 } // namespace gcm |
519 | 522 |
520 int main(int argc, char* argv[]) { | 523 int main(int argc, char* argv[]) { |
521 return gcm::MCSProbeMain(argc, argv); | 524 return gcm::MCSProbeMain(argc, argv); |
522 } | 525 } |
OLD | NEW |