blob: 72acb8796bbfc693cec34a3ade2e38d10f145f93 [file] [log] [blame]
tengs757fd842015-07-28 16:52:061// Copyright 2015 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
khorimoto999e934c2016-11-18 20:10:425#include "components/cryptauth/fake_cryptauth_gcm_manager.h"
tengs757fd842015-07-28 16:52:066
khorimoto999e934c2016-11-18 20:10:427namespace cryptauth {
tengs757fd842015-07-28 16:52:068
9FakeCryptAuthGCMManager::FakeCryptAuthGCMManager(
10 const std::string& registration_id)
11 : registration_in_progress_(false), registration_id_(registration_id) {}
12
13FakeCryptAuthGCMManager::~FakeCryptAuthGCMManager() {}
14
15void FakeCryptAuthGCMManager::StartListening() {}
16
17void FakeCryptAuthGCMManager::RegisterWithGCM() {
18 registration_in_progress_ = true;
19}
20
21std::string FakeCryptAuthGCMManager::GetRegistrationId() {
22 return registration_id_;
23}
24
25void FakeCryptAuthGCMManager::AddObserver(Observer* observer) {
26 observers_.AddObserver(observer);
27}
28
29void FakeCryptAuthGCMManager::RemoveObserver(Observer* observer) {
30 observers_.RemoveObserver(observer);
31}
32
33void FakeCryptAuthGCMManager::CompleteRegistration(
34 const std::string& registration_id) {
35 DCHECK(registration_in_progress_);
36 registration_in_progress_ = false;
37 registration_id_ = registration_id;
38 bool success = !registration_id_.empty();
ericwilligersfe109cd2016-10-19 01:45:5139 for (auto& observer : observers_)
40 observer.OnGCMRegistrationResult(success);
tengs757fd842015-07-28 16:52:0641}
42
43void FakeCryptAuthGCMManager::PushReenrollMessage() {
ericwilligersfe109cd2016-10-19 01:45:5144 for (auto& observer : observers_)
45 observer.OnReenrollMessage();
tengs757fd842015-07-28 16:52:0646}
47
48void FakeCryptAuthGCMManager::PushResyncMessage() {
ericwilligersfe109cd2016-10-19 01:45:5149 for (auto& observer : observers_)
50 observer.OnResyncMessage();
tengs757fd842015-07-28 16:52:0651}
52
khorimoto999e934c2016-11-18 20:10:4253} // namespace cryptauth