blob: 147b2a27b8ab6a0edeb171fdef554f930a12ff0b [file] [log] [blame]
[email protected]3ecb2b582014-05-23 00:25:391// 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]8d41e5a2014-05-28 03:18:495#include "components/gcm_driver/fake_gcm_app_handler.h"
[email protected]3ecb2b582014-05-23 00:25:396
7#include "base/run_loop.h"
8
9namespace gcm {
10
[email protected]fc6078a2014-06-14 08:28:4311FakeGCMAppHandler::FakeGCMAppHandler()
fgorski0d5c00d2014-08-28 16:21:4512 : received_event_(NO_EVENT) {
[email protected]3ecb2b582014-05-23 00:25:3913}
14
15FakeGCMAppHandler::~FakeGCMAppHandler() {
16}
17
18void FakeGCMAppHandler::WaitForNotification() {
19 run_loop_.reset(new base::RunLoop);
20 run_loop_->Run();
21 run_loop_.reset();
22}
23
24void FakeGCMAppHandler::ShutdownHandler() {
25}
26
johnme93ec7932016-11-17 14:26:5827void FakeGCMAppHandler::OnStoreReset() {}
28
[email protected]3ecb2b582014-05-23 00:25:3929void FakeGCMAppHandler::OnMessage(const std::string& app_id,
mvanouwerkerkf8633deb2015-07-13 11:04:0630 const IncomingMessage& message) {
[email protected]3ecb2b582014-05-23 00:25:3931 ClearResults();
32 received_event_ = MESSAGE_EVENT;
33 app_id_ = app_id;
34 message_ = message;
35 if (run_loop_)
36 run_loop_->Quit();
37}
38
39void FakeGCMAppHandler::OnMessagesDeleted(const std::string& app_id) {
40 ClearResults();
41 received_event_ = MESSAGES_DELETED_EVENT;
42 app_id_ = app_id;
43 if (run_loop_)
44 run_loop_->Quit();
45}
46
47void FakeGCMAppHandler::OnSendError(
48 const std::string& app_id,
49 const GCMClient::SendErrorDetails& send_error_details) {
50 ClearResults();
51 received_event_ = SEND_ERROR_EVENT;
52 app_id_ = app_id;
53 send_error_details_ = send_error_details;
54 if (run_loop_)
55 run_loop_->Quit();
56}
57
[email protected]292af2b22014-08-06 19:42:4558void FakeGCMAppHandler::OnSendAcknowledged(
59 const std::string& app_id,
60 const std::string& message_id) {
61 ClearResults();
62 app_id_ = app_id;
63 acked_message_id_ = message_id;
64 if (run_loop_)
65 run_loop_->Quit();
66}
67
[email protected]3ecb2b582014-05-23 00:25:3968void FakeGCMAppHandler::ClearResults() {
69 received_event_ = NO_EVENT;
70 app_id_.clear();
[email protected]292af2b22014-08-06 19:42:4571 acked_message_id_.clear();
mvanouwerkerkf8633deb2015-07-13 11:04:0672 message_ = IncomingMessage();
[email protected]3ecb2b582014-05-23 00:25:3973 send_error_details_ = GCMClient::SendErrorDetails();
74}
75
[email protected]3ecb2b582014-05-23 00:25:3976} // namespace gcm