| 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 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_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 "google_apis/gcm/gcm_client.h" | 10 #include "google_apis/gcm/gcm_client.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 const base::FilePath& store_path, | 41 const base::FilePath& store_path, |
| 42 const std::vector<std::string>& account_ids, | 42 const std::vector<std::string>& account_ids, |
| 43 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 43 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 44 const scoped_refptr<net::URLRequestContextGetter>& | 44 const scoped_refptr<net::URLRequestContextGetter>& |
| 45 url_request_context_getter, | 45 url_request_context_getter, |
| 46 Delegate* delegate) OVERRIDE; | 46 Delegate* delegate) OVERRIDE; |
| 47 virtual void Load() OVERRIDE; | 47 virtual void Load() OVERRIDE; |
| 48 virtual void CheckOut() OVERRIDE; | 48 virtual void CheckOut() OVERRIDE; |
| 49 virtual void Register(const std::string& app_id, | 49 virtual void Register(const std::string& app_id, |
| 50 const std::string& cert, | 50 const std::string& cert, |
| 51 const std::vector<std::string>& sender_ids) OVERRIDE; | 51 const std::string& sender_id) OVERRIDE; |
| 52 virtual void Unregister(const std::string& app_id) OVERRIDE; | 52 virtual void Unregister(const std::string& app_id) OVERRIDE; |
| 53 virtual void Send(const std::string& app_id, | 53 virtual void Send(const std::string& app_id, |
| 54 const std::string& receiver_id, | 54 const std::string& receiver_id, |
| 55 const OutgoingMessage& message) OVERRIDE; | 55 const OutgoingMessage& message) OVERRIDE; |
| 56 | 56 |
| 57 // Initiate the loading that has been delayed. | 57 // Initiate the loading that has been delayed. |
| 58 // Called on UI thread. | 58 // Called on UI thread. |
| 59 void PerformDelayedLoading(); | 59 void PerformDelayedLoading(); |
| 60 | 60 |
| 61 // Simulate receiving something from the server. | 61 // Simulate receiving something from the server. |
| 62 // Called on UI thread. | 62 // Called on UI thread. |
| 63 void ReceiveMessage(const std::string& app_id, | 63 void ReceiveMessage(const std::string& app_id, |
| 64 const IncomingMessage& message); | 64 const IncomingMessage& message); |
| 65 void DeleteMessages(const std::string& app_id); | 65 void DeleteMessages(const std::string& app_id); |
| 66 | 66 |
| 67 static std::string GetRegistrationIdFromSenderIds( | 67 static std::string GetRegistrationIdFromSenderId( |
| 68 const std::vector<std::string>& sender_ids); | 68 const std::string& sender_id); |
| 69 | 69 |
| 70 Status status() const { return status_; } | 70 Status status() const { return status_; } |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 // Called on IO thread. | 73 // Called on IO thread. |
| 74 void DoLoading(); | 74 void DoLoading(); |
| 75 void CheckinFinished(); | 75 void CheckinFinished(); |
| 76 void RegisterFinished(const std::string& app_id, | 76 void RegisterFinished(const std::string& app_id, |
| 77 const std::string& registrion_id); | 77 const std::string& registrion_id); |
| 78 void SendFinished(const std::string& app_id, const std::string& message_id); | 78 void SendFinished(const std::string& app_id, const std::string& message_id); |
| 79 void MessageReceived(const std::string& app_id, | 79 void MessageReceived(const std::string& app_id, |
| 80 const IncomingMessage& message); | 80 const IncomingMessage& message); |
| 81 void MessagesDeleted(const std::string& app_id); | 81 void MessagesDeleted(const std::string& app_id); |
| 82 void MessageSendError(const std::string& app_id, | 82 void MessageSendError(const std::string& app_id, |
| 83 const std::string& message_id); | 83 const std::string& message_id); |
| 84 | 84 |
| 85 Delegate* delegate_; | 85 Delegate* delegate_; |
| 86 Status status_; | 86 Status status_; |
| 87 LoadingDelay loading_delay_; | 87 LoadingDelay loading_delay_; |
| 88 ErrorSimulation error_simulation_; | 88 ErrorSimulation error_simulation_; |
| 89 base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_; | 89 base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(GCMClientMock); | 91 DISALLOW_COPY_AND_ASSIGN(GCMClientMock); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace gcm | 94 } // namespace gcm |
| 95 | 95 |
| 96 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 96 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ |
| OLD | NEW |