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> |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 uint64 secret() const { return secret_; } | 203 uint64 secret() const { return secret_; } |
204 | 204 |
205 private: | 205 private: |
206 void CheckIn(); | 206 void CheckIn(); |
207 void InitializeNetworkState(); | 207 void InitializeNetworkState(); |
208 void BuildNetworkSession(); | 208 void BuildNetworkSession(); |
209 | 209 |
210 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result); | 210 void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result); |
211 void UpdateCallback(bool success); | 211 void UpdateCallback(bool success); |
212 void ErrorCallback(); | 212 void ErrorCallback(); |
213 void OnCheckInCompleted(uint64 android_id, uint64 secret); | 213 void OnCheckInCompleted( |
| 214 const checkin_proto::AndroidCheckinResponse& checkin_response); |
214 void StartMCSLogin(); | 215 void StartMCSLogin(); |
215 | 216 |
216 base::DefaultClock clock_; | 217 base::DefaultClock clock_; |
217 | 218 |
218 CommandLine command_line_; | 219 CommandLine command_line_; |
219 | 220 |
220 base::FilePath gcm_store_path_; | 221 base::FilePath gcm_store_path_; |
221 uint64 android_id_; | 222 uint64 android_id_; |
222 uint64 secret_; | 223 uint64 secret_; |
223 std::string server_host_; | 224 std::string server_host_; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } | 417 } |
417 | 418 |
418 void MCSProbe::CheckIn() { | 419 void MCSProbe::CheckIn() { |
419 LOG(INFO) << "Check-in request initiated."; | 420 LOG(INFO) << "Check-in request initiated."; |
420 checkin_proto::ChromeBuildProto chrome_build_proto; | 421 checkin_proto::ChromeBuildProto chrome_build_proto; |
421 chrome_build_proto.set_platform( | 422 chrome_build_proto.set_platform( |
422 checkin_proto::ChromeBuildProto::PLATFORM_LINUX); | 423 checkin_proto::ChromeBuildProto::PLATFORM_LINUX); |
423 chrome_build_proto.set_channel( | 424 chrome_build_proto.set_channel( |
424 checkin_proto::ChromeBuildProto::CHANNEL_CANARY); | 425 checkin_proto::ChromeBuildProto::CHANNEL_CANARY); |
425 chrome_build_proto.set_chrome_version(kChromeVersion); | 426 chrome_build_proto.set_chrome_version(kChromeVersion); |
| 427 |
| 428 CheckinRequest::RequestInfo request_info( |
| 429 0, 0, std::string(), std::vector<std::string>(), chrome_build_proto); |
| 430 |
426 checkin_request_.reset(new CheckinRequest( | 431 checkin_request_.reset(new CheckinRequest( |
| 432 request_info, |
| 433 kDefaultBackoffPolicy, |
427 base::Bind(&MCSProbe::OnCheckInCompleted, base::Unretained(this)), | 434 base::Bind(&MCSProbe::OnCheckInCompleted, base::Unretained(this)), |
428 kDefaultBackoffPolicy, | |
429 chrome_build_proto, | |
430 0, | |
431 0, | |
432 std::vector<std::string>(), | |
433 url_request_context_getter_.get())); | 435 url_request_context_getter_.get())); |
434 checkin_request_->Start(); | 436 checkin_request_->Start(); |
435 } | 437 } |
436 | 438 |
437 void MCSProbe::OnCheckInCompleted(uint64 android_id, uint64 secret) { | 439 void MCSProbe::OnCheckInCompleted( |
| 440 const checkin_proto::AndroidCheckinResponse& checkin_response) { |
| 441 bool success = checkin_response.has_android_id() && |
| 442 checkin_response.android_id() != 0UL && |
| 443 checkin_response.has_security_token() && |
| 444 checkin_response.security_token() != 0UL; |
438 LOG(INFO) << "Check-in request completion " | 445 LOG(INFO) << "Check-in request completion " |
439 << (android_id ? "success!" : "failure!"); | 446 << (success ? "success!" : "failure!"); |
440 if (!android_id || !secret) | 447 |
| 448 if (!success) |
441 return; | 449 return; |
442 android_id_ = android_id; | 450 |
443 secret_ = secret; | 451 android_id_ = checkin_response.android_id(); |
| 452 secret_ = checkin_response.security_token(); |
444 | 453 |
445 gcm_store_->SetDeviceCredentials(android_id_, | 454 gcm_store_->SetDeviceCredentials(android_id_, |
446 secret_, | 455 secret_, |
447 base::Bind(&MCSProbe::UpdateCallback, | 456 base::Bind(&MCSProbe::UpdateCallback, |
448 base::Unretained(this))); | 457 base::Unretained(this))); |
449 | 458 |
450 StartMCSLogin(); | 459 StartMCSLogin(); |
451 } | 460 } |
452 | 461 |
453 void MCSProbe::StartMCSLogin() { | 462 void MCSProbe::StartMCSLogin() { |
(...skipping 27 matching lines...) Expand all Loading... |
481 | 490 |
482 return 0; | 491 return 0; |
483 } | 492 } |
484 | 493 |
485 } // namespace | 494 } // namespace |
486 } // namespace gcm | 495 } // namespace gcm |
487 | 496 |
488 int main(int argc, char* argv[]) { | 497 int main(int argc, char* argv[]) { |
489 return gcm::MCSProbeMain(argc, argv); | 498 return gcm::MCSProbeMain(argc, argv); |
490 } | 499 } |
OLD | NEW |