| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Initiate the loading that has been delayed. | 65 // Initiate the loading that has been delayed. |
| 66 // Called on UI thread. | 66 // Called on UI thread. |
| 67 void PerformDelayedLoading(); | 67 void PerformDelayedLoading(); |
| 68 | 68 |
| 69 // Simulate receiving something from the server. | 69 // Simulate receiving something from the server. |
| 70 // Called on UI thread. | 70 // Called on UI thread. |
| 71 void ReceiveMessage(const std::string& app_id, | 71 void ReceiveMessage(const std::string& app_id, |
| 72 const IncomingMessage& message); | 72 const IncomingMessage& message); |
| 73 void DeleteMessages(const std::string& app_id); | 73 void DeleteMessages(const std::string& app_id); |
| 74 | 74 |
| 75 static std::string GetRegistrationIdFromSenderIds( | 75 std::string GetRegistrationIdFromSenderIds( |
| 76 const std::vector<std::string>& sender_ids); | 76 const std::vector<std::string>& sender_ids) const; |
| 77 | 77 |
| 78 Status status() const { return status_; } | 78 Status status() const { return status_; } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 // Called on IO thread. | 81 // Called on IO thread. |
| 82 void DoLoading(); | 82 void DoLoading(); |
| 83 void CheckinFinished(); | 83 void CheckinFinished(); |
| 84 void RegisterFinished(const std::string& app_id, | 84 void RegisterFinished(const std::string& app_id, |
| 85 const std::string& registrion_id); | 85 const std::string& registrion_id); |
| 86 void UnregisterFinished(const std::string& app_id); | 86 void UnregisterFinished(const std::string& app_id); |
| 87 void SendFinished(const std::string& app_id, const OutgoingMessage& message); | 87 void SendFinished(const std::string& app_id, const OutgoingMessage& message); |
| 88 void MessageReceived(const std::string& app_id, | 88 void MessageReceived(const std::string& app_id, |
| 89 const IncomingMessage& message); | 89 const IncomingMessage& message); |
| 90 void MessagesDeleted(const std::string& app_id); | 90 void MessagesDeleted(const std::string& app_id); |
| 91 void MessageSendError(const std::string& app_id, | 91 void MessageSendError(const std::string& app_id, |
| 92 const SendErrorDetails& send_error_details); | 92 const SendErrorDetails& send_error_details); |
| 93 void SendAcknowledgement(const std::string& app_id, | 93 void SendAcknowledgement(const std::string& app_id, |
| 94 const std::string& message_id); | 94 const std::string& message_id); |
| 95 | 95 |
| 96 Delegate* delegate_; | 96 Delegate* delegate_; |
| 97 // Increased at checkout in order to produce a different registration ID |
| 98 // after checkout and re-checkin. |
| 99 int sequence_id_; |
| 97 Status status_; | 100 Status status_; |
| 98 StartMode start_mode_; | 101 StartMode start_mode_; |
| 99 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 102 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
| 100 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 103 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
| 101 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; | 104 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; |
| 102 | 105 |
| 103 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); | 106 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); |
| 104 }; | 107 }; |
| 105 | 108 |
| 106 } // namespace gcm | 109 } // namespace gcm |
| 107 | 110 |
| 108 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ | 111 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ |
| OLD | NEW |