[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 8d41e5a | 2014-05-28 03:18:49 | [diff] [blame] | 5 | #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_ |
6 | #define COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_ | ||||
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 7 | |
dcheng | a77e28eb | 2016-04-21 21:34:37 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 10 | #include "base/compiler_specific.h" |
avi | 2606292 | 2015-12-26 00:14:18 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 12 | #include "components/gcm_driver/gcm_app_handler.h" |
13 | |||||
14 | namespace base { | ||||
15 | class RunLoop; | ||||
16 | } | ||||
17 | |||||
18 | namespace gcm { | ||||
19 | |||||
20 | class FakeGCMAppHandler : public GCMAppHandler { | ||||
21 | public: | ||||
22 | enum Event { | ||||
23 | NO_EVENT, | ||||
24 | MESSAGE_EVENT, | ||||
25 | MESSAGES_DELETED_EVENT, | ||||
26 | SEND_ERROR_EVENT | ||||
27 | }; | ||||
28 | |||||
29 | FakeGCMAppHandler(); | ||||
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 30 | ~FakeGCMAppHandler() override; |
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 31 | |
32 | const Event& received_event() const { return received_event_; } | ||||
33 | const std::string& app_id() const { return app_id_; } | ||||
[email protected] | 292af2b2 | 2014-08-06 19:42:45 | [diff] [blame] | 34 | const std::string& acked_message_id() const { return acked_message_id_; } |
mvanouwerkerk | f8633deb | 2015-07-13 11:04:06 | [diff] [blame] | 35 | const IncomingMessage& message() const { return message_; } |
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 36 | const GCMClient::SendErrorDetails& send_error_details() const { |
37 | return send_error_details_; | ||||
38 | } | ||||
39 | |||||
40 | void WaitForNotification(); | ||||
41 | |||||
[email protected] | fc6078a | 2014-06-14 08:28:43 | [diff] [blame] | 42 | // GCMAppHandler implementation. |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 43 | void ShutdownHandler() override; |
johnme | 93ec793 | 2016-11-17 14:26:58 | [diff] [blame] | 44 | void OnStoreReset() override; |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 45 | void OnMessage(const std::string& app_id, |
mvanouwerkerk | f8633deb | 2015-07-13 11:04:06 | [diff] [blame] | 46 | const IncomingMessage& message) override; |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 47 | void OnMessagesDeleted(const std::string& app_id) override; |
48 | void OnSendError( | ||||
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 49 | const std::string& app_id, |
mostynb | fe59f48 | 2014-10-06 15:04:46 | [diff] [blame] | 50 | const GCMClient::SendErrorDetails& send_error_details) override; |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 51 | void OnSendAcknowledged(const std::string& app_id, |
52 | const std::string& message_id) override; | ||||
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 53 | |
54 | private: | ||||
55 | void ClearResults(); | ||||
56 | |||||
dcheng | a77e28eb | 2016-04-21 21:34:37 | [diff] [blame] | 57 | std::unique_ptr<base::RunLoop> run_loop_; |
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 58 | |
59 | Event received_event_; | ||||
60 | std::string app_id_; | ||||
[email protected] | 292af2b2 | 2014-08-06 19:42:45 | [diff] [blame] | 61 | std::string acked_message_id_; |
mvanouwerkerk | f8633deb | 2015-07-13 11:04:06 | [diff] [blame] | 62 | IncomingMessage message_; |
[email protected] | 3ecb2b58 | 2014-05-23 00:25:39 | [diff] [blame] | 63 | GCMClient::SendErrorDetails send_error_details_; |
64 | |||||
65 | DISALLOW_COPY_AND_ASSIGN(FakeGCMAppHandler); | ||||
66 | }; | ||||
67 | |||||
68 | } // namespace gcm | ||||
69 | |||||
[email protected] | 8d41e5a | 2014-05-28 03:18:49 | [diff] [blame] | 70 | #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_ |