Automated Commit: Committing new LKGM version 6953.0.0 for chromeos.
[chromium-blink-merge.git] / components / gcm_driver / fake_gcm_app_handler.h
blob29fcd296334f2e4b1c88e28eee0cf3727e7f85ad
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.
5 #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_
6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/gcm_driver/gcm_app_handler.h"
12 namespace base {
13 class RunLoop;
16 namespace gcm {
18 class FakeGCMAppHandler : public GCMAppHandler {
19 public:
20 enum Event {
21 NO_EVENT,
22 MESSAGE_EVENT,
23 MESSAGES_DELETED_EVENT,
24 SEND_ERROR_EVENT
27 FakeGCMAppHandler();
28 ~FakeGCMAppHandler() override;
30 const Event& received_event() const { return received_event_; }
31 const std::string& app_id() const { return app_id_; }
32 const std::string& acked_message_id() const { return acked_message_id_; }
33 const GCMClient::IncomingMessage& message() const { return message_; }
34 const GCMClient::SendErrorDetails& send_error_details() const {
35 return send_error_details_;
38 void WaitForNotification();
40 // GCMAppHandler implementation.
41 void ShutdownHandler() override;
42 void OnMessage(const std::string& app_id,
43 const GCMClient::IncomingMessage& message) override;
44 void OnMessagesDeleted(const std::string& app_id) override;
45 void OnSendError(
46 const std::string& app_id,
47 const GCMClient::SendErrorDetails& send_error_details) override;
48 void OnSendAcknowledged(const std::string& app_id,
49 const std::string& message_id) override;
51 private:
52 void ClearResults();
54 scoped_ptr<base::RunLoop> run_loop_;
56 Event received_event_;
57 std::string app_id_;
58 std::string acked_message_id_;
59 GCMClient::IncomingMessage message_;
60 GCMClient::SendErrorDetails send_error_details_;
62 DISALLOW_COPY_AND_ASSIGN(FakeGCMAppHandler);
65 } // namespace gcm
67 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_APP_HANDLER_H_