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 #include "chrome/browser/services/gcm/fake_gcm_app_handler.h" | |
6 | |
7 #include "base/run_loop.h" | |
8 | |
9 namespace gcm { | |
10 | |
11 FakeGCMAppHandler::FakeGCMAppHandler() : received_event_(NO_EVENT) { | |
12 } | |
13 | |
14 FakeGCMAppHandler::~FakeGCMAppHandler() { | |
15 } | |
16 | |
17 void FakeGCMAppHandler::WaitForNotification() { | |
18 run_loop_.reset(new base::RunLoop); | |
19 run_loop_->Run(); | |
20 run_loop_.reset(); | |
21 } | |
22 | |
23 void FakeGCMAppHandler::ShutdownHandler() { | |
24 } | |
25 | |
26 void FakeGCMAppHandler::OnMessage(const std::string& app_id, | |
27 const GCMClient::IncomingMessage& message) { | |
28 ClearResults(); | |
29 received_event_ = MESSAGE_EVENT; | |
30 app_id_ = app_id; | |
31 message_ = message; | |
32 if (run_loop_) | |
33 run_loop_->Quit(); | |
34 } | |
35 | |
36 void FakeGCMAppHandler::OnMessagesDeleted(const std::string& app_id) { | |
37 ClearResults(); | |
38 received_event_ = MESSAGES_DELETED_EVENT; | |
39 app_id_ = app_id; | |
40 if (run_loop_) | |
41 run_loop_->Quit(); | |
42 } | |
43 | |
44 void FakeGCMAppHandler::OnSendError( | |
45 const std::string& app_id, | |
46 const GCMClient::SendErrorDetails& send_error_details) { | |
47 ClearResults(); | |
48 received_event_ = SEND_ERROR_EVENT; | |
49 app_id_ = app_id; | |
50 send_error_details_ = send_error_details; | |
51 if (run_loop_) | |
52 run_loop_->Quit(); | |
53 } | |
54 | |
55 void FakeGCMAppHandler::ClearResults() { | |
56 received_event_ = NO_EVENT; | |
57 app_id_.clear(); | |
58 message_ = GCMClient::IncomingMessage(); | |
59 send_error_details_ = GCMClient::SendErrorDetails(); | |
60 } | |
61 | |
62 } // namespace gcm | |
OLD | NEW |