OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void RemoveInstanceIDData(const std::string& app_id); | 100 void RemoveInstanceIDData(const std::string& app_id); |
101 void GetInstanceIDData(const std::string& app_id); | 101 void GetInstanceIDData(const std::string& app_id); |
102 void GetToken(const std::string& app_id, | 102 void GetToken(const std::string& app_id, |
103 const std::string& authorized_entity, | 103 const std::string& authorized_entity, |
104 const std::string& scope, | 104 const std::string& scope, |
105 const std::map<std::string, std::string>& options); | 105 const std::map<std::string, std::string>& options); |
106 void DeleteToken(const std::string& app_id, | 106 void DeleteToken(const std::string& app_id, |
107 const std::string& authorized_entity, | 107 const std::string& authorized_entity, |
108 const std::string& scope); | 108 const std::string& scope); |
109 | 109 |
| 110 void RecordDecryptionFailure(const std::string& app_id, |
| 111 GCMEncryptionProvider::DecryptionFailure reason); |
| 112 |
110 // For testing purpose. Can be called from UI thread. Use with care. | 113 // For testing purpose. Can be called from UI thread. Use with care. |
111 GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } | 114 GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
112 | 115 |
113 private: | 116 private: |
114 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 117 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
115 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 118 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
116 | 119 |
117 base::WeakPtr<GCMDriverDesktop> service_; | 120 base::WeakPtr<GCMDriverDesktop> service_; |
118 | 121 |
119 scoped_ptr<GCMClient> gcm_client_; | 122 scoped_ptr<GCMClient> gcm_client_; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 492 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
490 gcm_client_->AddHeartbeatInterval(scope, interval_ms); | 493 gcm_client_->AddHeartbeatInterval(scope, interval_ms); |
491 } | 494 } |
492 | 495 |
493 void GCMDriverDesktop::IOWorker::RemoveHeartbeatInterval( | 496 void GCMDriverDesktop::IOWorker::RemoveHeartbeatInterval( |
494 const std::string& scope) { | 497 const std::string& scope) { |
495 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 498 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
496 gcm_client_->RemoveHeartbeatInterval(scope); | 499 gcm_client_->RemoveHeartbeatInterval(scope); |
497 } | 500 } |
498 | 501 |
| 502 void GCMDriverDesktop::IOWorker::RecordDecryptionFailure( |
| 503 const std::string& app_id, |
| 504 GCMEncryptionProvider::DecryptionFailure reason) { |
| 505 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
| 506 gcm_client_->RecordDecryptionFailure(app_id, reason); |
| 507 } |
| 508 |
499 GCMDriverDesktop::GCMDriverDesktop( | 509 GCMDriverDesktop::GCMDriverDesktop( |
500 scoped_ptr<GCMClientFactory> gcm_client_factory, | 510 scoped_ptr<GCMClientFactory> gcm_client_factory, |
501 const GCMClient::ChromeBuildInfo& chrome_build_info, | 511 const GCMClient::ChromeBuildInfo& chrome_build_info, |
502 const std::string& channel_status_request_url, | 512 const std::string& channel_status_request_url, |
503 const std::string& user_agent, | 513 const std::string& user_agent, |
504 PrefService* prefs, | 514 PrefService* prefs, |
505 const base::FilePath& store_path, | 515 const base::FilePath& store_path, |
506 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 516 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
507 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, | 517 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
508 const scoped_refptr<base::SequencedTaskRunner>& io_thread, | 518 const scoped_refptr<base::SequencedTaskRunner>& io_thread, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 725 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
716 io_thread_->PostTask( | 726 io_thread_->PostTask( |
717 FROM_HERE, | 727 FROM_HERE, |
718 base::Bind(&GCMDriverDesktop::IOWorker::Send, | 728 base::Bind(&GCMDriverDesktop::IOWorker::Send, |
719 base::Unretained(io_worker_.get()), | 729 base::Unretained(io_worker_.get()), |
720 app_id, | 730 app_id, |
721 receiver_id, | 731 receiver_id, |
722 message)); | 732 message)); |
723 } | 733 } |
724 | 734 |
| 735 void GCMDriverDesktop::RecordDecryptionFailure( |
| 736 const std::string& app_id, |
| 737 GCMEncryptionProvider::DecryptionFailure reason) { |
| 738 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| 739 io_thread_->PostTask( |
| 740 FROM_HERE, |
| 741 base::Bind(&GCMDriverDesktop::IOWorker::RecordDecryptionFailure, |
| 742 base::Unretained(io_worker_.get()), |
| 743 app_id, reason)); |
| 744 } |
| 745 |
725 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { | 746 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { |
726 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 747 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
727 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; | 748 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; |
728 } | 749 } |
729 | 750 |
730 bool GCMDriverDesktop::IsStarted() const { | 751 bool GCMDriverDesktop::IsStarted() const { |
731 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 752 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
732 return gcm_started_; | 753 return gcm_started_; |
733 } | 754 } |
734 | 755 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 | 1322 |
1302 if (base::get<1>(a) < base::get<1>(b)) | 1323 if (base::get<1>(a) < base::get<1>(b)) |
1303 return true; | 1324 return true; |
1304 if (base::get<1>(a) > base::get<1>(b)) | 1325 if (base::get<1>(a) > base::get<1>(b)) |
1305 return false; | 1326 return false; |
1306 | 1327 |
1307 return base::get<2>(a) < base::get<2>(b); | 1328 return base::get<2>(a) < base::get<2>(b); |
1308 } | 1329 } |
1309 | 1330 |
1310 } // namespace gcm | 1331 } // namespace gcm |
OLD | NEW |