| 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 #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ | 6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/gcm_driver/gcm_client.h" | 10 #include "components/gcm_driver/gcm_client.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 void Initialize( | 34 void Initialize( |
| 35 const ChromeBuildInfo& chrome_build_info, | 35 const ChromeBuildInfo& chrome_build_info, |
| 36 const base::FilePath& store_path, | 36 const base::FilePath& store_path, |
| 37 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 37 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 38 const scoped_refptr<net::URLRequestContextGetter>& | 38 const scoped_refptr<net::URLRequestContextGetter>& |
| 39 url_request_context_getter, | 39 url_request_context_getter, |
| 40 scoped_ptr<Encryptor> encryptor, | 40 scoped_ptr<Encryptor> encryptor, |
| 41 Delegate* delegate) override; | 41 Delegate* delegate) override; |
| 42 void Start(StartMode start_mode) override; | 42 void Start(StartMode start_mode) override; |
| 43 void Stop() override; | 43 void Stop() override; |
| 44 void Register(const std::string& app_id, | 44 void Register(const linked_ptr<RegistrationInfo>& registration_info) override; |
| 45 const std::vector<std::string>& sender_ids) override; | 45 void Unregister( |
| 46 void Unregister(const std::string& app_id) override; | 46 const linked_ptr<RegistrationInfo>& registration_info) override; |
| 47 void Send(const std::string& app_id, | 47 void Send(const std::string& app_id, |
| 48 const std::string& receiver_id, | 48 const std::string& receiver_id, |
| 49 const OutgoingMessage& message) override; | 49 const OutgoingMessage& message) override; |
| 50 void SetRecording(bool recording) override; | 50 void SetRecording(bool recording) override; |
| 51 void ClearActivityLogs() override; | 51 void ClearActivityLogs() override; |
| 52 GCMStatistics GetStatistics() const override; | 52 GCMStatistics GetStatistics() const override; |
| 53 void SetAccountTokens( | 53 void SetAccountTokens( |
| 54 const std::vector<AccountTokenInfo>& account_tokens) override; | 54 const std::vector<AccountTokenInfo>& account_tokens) override; |
| 55 void UpdateAccountMapping(const AccountMapping& account_mapping) override; | 55 void UpdateAccountMapping(const AccountMapping& account_mapping) override; |
| 56 void RemoveAccountMapping(const std::string& account_id) override; | 56 void RemoveAccountMapping(const std::string& account_id) override; |
| 57 void SetLastTokenFetchTime(const base::Time& time) override; | 57 void SetLastTokenFetchTime(const base::Time& time) override; |
| 58 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) override; | 58 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) override; |
| 59 void AddInstanceIDData(const std::string& app_id, | 59 void AddInstanceIDData(const std::string& app_id, |
| 60 const std::string& instance_id_data) override; | 60 const std::string& instance_id, |
| 61 const std::string& extra_data) override; |
| 61 void RemoveInstanceIDData(const std::string& app_id) override; | 62 void RemoveInstanceIDData(const std::string& app_id) override; |
| 62 std::string GetInstanceIDData(const std::string& app_id) override; | 63 void GetInstanceIDData(const std::string& app_id, |
| 64 std::string* instance_id, |
| 65 std::string* extra_data) override; |
| 63 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; | 66 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; |
| 64 void RemoveHeartbeatInterval(const std::string& scope) override; | 67 void RemoveHeartbeatInterval(const std::string& scope) override; |
| 65 | 68 |
| 66 // Initiate the start that has been delayed. | 69 // Initiate the start that has been delayed. |
| 67 // Called on UI thread. | 70 // Called on UI thread. |
| 68 void PerformDelayedStart(); | 71 void PerformDelayedStart(); |
| 69 | 72 |
| 70 // Simulate receiving something from the server. | 73 // Simulate receiving something from the server. |
| 71 // Called on UI thread. | 74 // Called on UI thread. |
| 72 void ReceiveMessage(const std::string& app_id, | 75 void ReceiveMessage(const std::string& app_id, |
| 73 const IncomingMessage& message); | 76 const IncomingMessage& message); |
| 74 void DeleteMessages(const std::string& app_id); | 77 void DeleteMessages(const std::string& app_id); |
| 75 | 78 |
| 76 std::string GetRegistrationIdFromSenderIds( | 79 std::string GetRegistrationIdFromSenderIds( |
| 77 const std::vector<std::string>& sender_ids) const; | 80 const std::vector<std::string>& sender_ids) const; |
| 78 | 81 |
| 79 void set_start_mode_overridding(StartModeOverridding overridding) { | 82 void set_start_mode_overridding(StartModeOverridding overridding) { |
| 80 start_mode_overridding_ = overridding; | 83 start_mode_overridding_ = overridding; |
| 81 } | 84 } |
| 82 | 85 |
| 83 private: | 86 private: |
| 84 // Called on IO thread. | 87 // Called on IO thread. |
| 85 void DoStart(); | 88 void DoStart(); |
| 86 void Started(); | 89 void Started(); |
| 87 void RegisterFinished(const std::string& app_id, | 90 void RegisterFinished( |
| 88 const std::string& registrion_id); | 91 const linked_ptr<RegistrationInfo>& registration_info, |
| 89 void UnregisterFinished(const std::string& app_id); | 92 const std::string& registrion_id); |
| 93 void UnregisterFinished( |
| 94 const linked_ptr<RegistrationInfo>& registration_info); |
| 90 void SendFinished(const std::string& app_id, const OutgoingMessage& message); | 95 void SendFinished(const std::string& app_id, const OutgoingMessage& message); |
| 91 void MessageReceived(const std::string& app_id, | 96 void MessageReceived(const std::string& app_id, |
| 92 const IncomingMessage& message); | 97 const IncomingMessage& message); |
| 93 void MessagesDeleted(const std::string& app_id); | 98 void MessagesDeleted(const std::string& app_id); |
| 94 void MessageSendError(const std::string& app_id, | 99 void MessageSendError(const std::string& app_id, |
| 95 const SendErrorDetails& send_error_details); | 100 const SendErrorDetails& send_error_details); |
| 96 void SendAcknowledgement(const std::string& app_id, | 101 void SendAcknowledgement(const std::string& app_id, |
| 97 const std::string& message_id); | 102 const std::string& message_id); |
| 98 | 103 |
| 99 Delegate* delegate_; | 104 Delegate* delegate_; |
| 100 bool started_; | 105 bool started_; |
| 101 StartMode start_mode_; | 106 StartMode start_mode_; |
| 102 StartModeOverridding start_mode_overridding_; | 107 StartModeOverridding start_mode_overridding_; |
| 103 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 108 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
| 104 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 109 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
| 105 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; | 110 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; |
| 106 | 111 |
| 107 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); | 112 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); |
| 108 }; | 113 }; |
| 109 | 114 |
| 110 } // namespace gcm | 115 } // namespace gcm |
| 111 | 116 |
| 112 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ | 117 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ |
| OLD | NEW |