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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/gcm_driver/gcm_client.h" | 13 #include "components/gcm_driver/gcm_client.h" |
14 #include "components/gcm_driver/gcm_message_status.h" | |
14 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 15 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
18 } | 19 } |
19 | 20 |
20 namespace gcm { | 21 namespace gcm { |
21 | 22 |
22 class FakeGCMClient : public GCMClient { | 23 class FakeGCMClient : public GCMClient { |
23 public: | 24 public: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; | 81 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; |
81 void RemoveHeartbeatInterval(const std::string& scope) override; | 82 void RemoveHeartbeatInterval(const std::string& scope) override; |
82 | 83 |
83 // Initiate the start that has been delayed. | 84 // Initiate the start that has been delayed. |
84 // Called on UI thread. | 85 // Called on UI thread. |
85 void PerformDelayedStart(); | 86 void PerformDelayedStart(); |
86 | 87 |
87 // Simulate receiving something from the server. | 88 // Simulate receiving something from the server. |
88 // Called on UI thread. | 89 // Called on UI thread. |
89 void ReceiveMessage(const std::string& app_id, | 90 void ReceiveMessage(const std::string& app_id, |
91 const std::string& message_id, | |
90 const IncomingMessage& message); | 92 const IncomingMessage& message); |
91 void DeleteMessages(const std::string& app_id); | 93 void DeleteMessages(const std::string& app_id); |
92 | 94 |
93 void set_start_mode_overridding(StartModeOverridding overridding) { | 95 void set_start_mode_overridding(StartModeOverridding overridding) { |
94 start_mode_overridding_ = overridding; | 96 start_mode_overridding_ = overridding; |
95 } | 97 } |
96 | 98 |
99 const std::string& receipt_app_id() { return receipt_app_id_; } | |
100 const std::string& receipt_message_id() { return receipt_message_id_; } | |
101 GCMMessageStatus receipt_status() { return receipt_status_; } | |
Peter Beverloo
2017/02/08 17:09:08
nit: these methods can be const
harkness
2017/02/09 16:27:29
Done.
| |
102 | |
97 private: | 103 private: |
98 // Called on IO thread. | 104 // Called on IO thread. |
99 void DoStart(); | 105 void DoStart(); |
100 void Started(); | 106 void Started(); |
101 void RegisterFinished( | 107 void RegisterFinished( |
102 const linked_ptr<RegistrationInfo>& registration_info, | 108 const linked_ptr<RegistrationInfo>& registration_info, |
103 const std::string& registrion_id); | 109 const std::string& registrion_id); |
104 void UnregisterFinished( | 110 void UnregisterFinished( |
105 const linked_ptr<RegistrationInfo>& registration_info); | 111 const linked_ptr<RegistrationInfo>& registration_info); |
106 void SendFinished(const std::string& app_id, const OutgoingMessage& message); | 112 void SendFinished(const std::string& app_id, const OutgoingMessage& message); |
107 void MessageReceived(const std::string& app_id, | 113 void MessageReceived(const std::string& app_id, |
108 const IncomingMessage& message); | 114 const IncomingMessage& message, |
115 const MessageReceiptCallback& callback); | |
109 void MessagesDeleted(const std::string& app_id); | 116 void MessagesDeleted(const std::string& app_id); |
110 void MessageSendError(const std::string& app_id, | 117 void MessageSendError(const std::string& app_id, |
111 const SendErrorDetails& send_error_details); | 118 const SendErrorDetails& send_error_details); |
112 void SendAcknowledgement(const std::string& app_id, | 119 void SendAcknowledgement(const std::string& app_id, |
113 const std::string& message_id); | 120 const std::string& message_id); |
121 void SendMessageReceipt(const std::string& message_id, | |
122 const std::string& app_id, | |
123 GCMMessageStatus status); | |
114 | 124 |
115 Delegate* delegate_; | 125 Delegate* delegate_; |
116 std::string product_category_for_subtypes_; | 126 std::string product_category_for_subtypes_; |
117 bool started_; | 127 bool started_; |
118 StartMode start_mode_; | 128 StartMode start_mode_; |
119 StartModeOverridding start_mode_overridding_; | 129 StartModeOverridding start_mode_overridding_; |
120 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 130 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
121 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 131 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
122 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; | 132 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; |
123 GCMStatsRecorderImpl recorder_; | 133 GCMStatsRecorderImpl recorder_; |
134 std::string receipt_app_id_; | |
135 std::string receipt_message_id_; | |
136 GCMMessageStatus receipt_status_; | |
124 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; | 137 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; |
125 | 138 |
126 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); | 139 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); |
127 }; | 140 }; |
128 | 141 |
129 } // namespace gcm | 142 } // namespace gcm |
130 | 143 |
131 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ | 144 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ |
OLD | NEW |