OLD | NEW |
| (Empty) |
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 | |
5 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_APP_HANDLER_H_ | |
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_APP_HANDLER_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "components/gcm_driver/gcm_app_handler.h" | |
11 | |
12 namespace base { | |
13 class RunLoop; | |
14 } | |
15 | |
16 namespace gcm { | |
17 | |
18 class FakeGCMAppHandler : public GCMAppHandler { | |
19 public: | |
20 enum Event { | |
21 NO_EVENT, | |
22 MESSAGE_EVENT, | |
23 MESSAGES_DELETED_EVENT, | |
24 SEND_ERROR_EVENT | |
25 }; | |
26 | |
27 FakeGCMAppHandler(); | |
28 virtual ~FakeGCMAppHandler(); | |
29 | |
30 const Event& received_event() const { return received_event_; } | |
31 const std::string& app_id() const { return app_id_; } | |
32 const GCMClient::IncomingMessage& message() const { return message_; } | |
33 const GCMClient::SendErrorDetails& send_error_details() const { | |
34 return send_error_details_; | |
35 } | |
36 | |
37 void WaitForNotification(); | |
38 | |
39 // GCMAppHandler: | |
40 virtual void ShutdownHandler() OVERRIDE; | |
41 virtual void OnMessage(const std::string& app_id, | |
42 const GCMClient::IncomingMessage& message) OVERRIDE; | |
43 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; | |
44 virtual void OnSendError( | |
45 const std::string& app_id, | |
46 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; | |
47 | |
48 private: | |
49 void ClearResults(); | |
50 | |
51 scoped_ptr<base::RunLoop> run_loop_; | |
52 | |
53 Event received_event_; | |
54 std::string app_id_; | |
55 GCMClient::IncomingMessage message_; | |
56 GCMClient::SendErrorDetails send_error_details_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(FakeGCMAppHandler); | |
59 }; | |
60 | |
61 } // namespace gcm | |
62 | |
63 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_APP_HANDLER_H_ | |
OLD | NEW |