Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / gcm_driver / fake_gcm_app_handler.cc
blob632572b22bebe4d5d698cede49e6504c28b4361f
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 #include "components/gcm_driver/fake_gcm_app_handler.h"
7 #include "base/run_loop.h"
9 namespace gcm {
11 FakeGCMAppHandler::FakeGCMAppHandler() : received_event_(NO_EVENT) {
14 FakeGCMAppHandler::~FakeGCMAppHandler() {
17 void FakeGCMAppHandler::WaitForNotification() {
18 run_loop_.reset(new base::RunLoop);
19 run_loop_->Run();
20 run_loop_.reset();
23 void FakeGCMAppHandler::ShutdownHandler() {
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();
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();
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();
55 void FakeGCMAppHandler::ClearResults() {
56 received_event_ = NO_EVENT;
57 app_id_.clear();
58 message_ = GCMClient::IncomingMessage();
59 send_error_details_ = GCMClient::SendErrorDetails();
62 } // namespace gcm