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 | |
113 // For testing purpose. Can be called from UI thread. Use with care. | 110 // For testing purpose. Can be called from UI thread. Use with care. |
114 GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } | 111 GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
115 | 112 |
116 private: | 113 private: |
117 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 114 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
118 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 115 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
119 | 116 |
120 base::WeakPtr<GCMDriverDesktop> service_; | 117 base::WeakPtr<GCMDriverDesktop> service_; |
121 | 118 |
122 scoped_ptr<GCMClient> gcm_client_; | 119 scoped_ptr<GCMClient> gcm_client_; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 489 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
493 gcm_client_->AddHeartbeatInterval(scope, interval_ms); | 490 gcm_client_->AddHeartbeatInterval(scope, interval_ms); |
494 } | 491 } |
495 | 492 |
496 void GCMDriverDesktop::IOWorker::RemoveHeartbeatInterval( | 493 void GCMDriverDesktop::IOWorker::RemoveHeartbeatInterval( |
497 const std::string& scope) { | 494 const std::string& scope) { |
498 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 495 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
499 gcm_client_->RemoveHeartbeatInterval(scope); | 496 gcm_client_->RemoveHeartbeatInterval(scope); |
500 } | 497 } |
501 | 498 |
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 | |
509 GCMDriverDesktop::GCMDriverDesktop( | 499 GCMDriverDesktop::GCMDriverDesktop( |
510 scoped_ptr<GCMClientFactory> gcm_client_factory, | 500 scoped_ptr<GCMClientFactory> gcm_client_factory, |
511 const GCMClient::ChromeBuildInfo& chrome_build_info, | 501 const GCMClient::ChromeBuildInfo& chrome_build_info, |
512 const std::string& channel_status_request_url, | 502 const std::string& channel_status_request_url, |
513 const std::string& user_agent, | 503 const std::string& user_agent, |
514 PrefService* prefs, | 504 PrefService* prefs, |
515 const base::FilePath& store_path, | 505 const base::FilePath& store_path, |
516 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 506 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
517 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, | 507 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
518 const scoped_refptr<base::SequencedTaskRunner>& io_thread, | 508 const scoped_refptr<base::SequencedTaskRunner>& io_thread, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 715 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
726 io_thread_->PostTask( | 716 io_thread_->PostTask( |
727 FROM_HERE, | 717 FROM_HERE, |
728 base::Bind(&GCMDriverDesktop::IOWorker::Send, | 718 base::Bind(&GCMDriverDesktop::IOWorker::Send, |
729 base::Unretained(io_worker_.get()), | 719 base::Unretained(io_worker_.get()), |
730 app_id, | 720 app_id, |
731 receiver_id, | 721 receiver_id, |
732 message)); | 722 message)); |
733 } | 723 } |
734 | 724 |
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 | |
746 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { | 725 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { |
747 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 726 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
748 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; | 727 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; |
749 } | 728 } |
750 | 729 |
751 bool GCMDriverDesktop::IsStarted() const { | 730 bool GCMDriverDesktop::IsStarted() const { |
752 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 731 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
753 return gcm_started_; | 732 return gcm_started_; |
754 } | 733 } |
755 | 734 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 | 1301 |
1323 if (base::get<1>(a) < base::get<1>(b)) | 1302 if (base::get<1>(a) < base::get<1>(b)) |
1324 return true; | 1303 return true; |
1325 if (base::get<1>(a) > base::get<1>(b)) | 1304 if (base::get<1>(a) > base::get<1>(b)) |
1326 return false; | 1305 return false; |
1327 | 1306 |
1328 return base::get<2>(a) < base::get<2>(b); | 1307 return base::get<2>(a) < base::get<2>(b); |
1329 } | 1308 } |
1330 | 1309 |
1331 } // namespace gcm | 1310 } // namespace gcm |
OLD | NEW |