OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/cryptauth/fake_secure_channel.h" | 5 #include "components/cryptauth/fake_secure_channel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace cryptauth { | 9 namespace cryptauth { |
10 | 10 |
11 FakeSecureChannel::SentMessage::SentMessage(const std::string& feature, | 11 FakeSecureChannel::SentMessage::SentMessage(const std::string& feature, |
12 const std::string& payload) | 12 const std::string& payload) |
13 : feature(feature), payload(payload) {} | 13 : feature(feature), payload(payload) {} |
14 | 14 |
15 FakeSecureChannel::FakeSecureChannel(std::unique_ptr<Connection> connection, | 15 FakeSecureChannel::FakeSecureChannel(std::unique_ptr<Connection> connection, |
16 std::unique_ptr<Delegate> delegate) | 16 CryptAuthService* cryptauth_service) |
17 : SecureChannel(std::move(connection), std::move(delegate)) {} | 17 : SecureChannel(std::move(connection), cryptauth_service) {} |
18 | 18 |
19 FakeSecureChannel::~FakeSecureChannel() {} | 19 FakeSecureChannel::~FakeSecureChannel() {} |
20 | 20 |
21 void FakeSecureChannel::ChangeStatus(const Status& new_status) { | 21 void FakeSecureChannel::ChangeStatus(const Status& new_status) { |
22 Status old_status = status_; | 22 Status old_status = status_; |
23 status_ = new_status; | 23 status_ = new_status; |
24 | 24 |
25 // Copy to prevent channel from being removed during handler. | 25 // Copy to prevent channel from being removed during handler. |
26 std::vector<Observer*> observers_copy = observers_; | 26 std::vector<Observer*> observers_copy = observers_; |
27 for (auto* observer : observers_copy) { | 27 for (auto* observer : observers_copy) { |
(...skipping 24 matching lines...) Expand all Loading... |
52 void FakeSecureChannel::AddObserver(Observer* observer) { | 52 void FakeSecureChannel::AddObserver(Observer* observer) { |
53 observers_.push_back(observer); | 53 observers_.push_back(observer); |
54 } | 54 } |
55 | 55 |
56 void FakeSecureChannel::RemoveObserver(Observer* observer) { | 56 void FakeSecureChannel::RemoveObserver(Observer* observer) { |
57 observers_.erase(std::find(observers_.begin(), observers_.end(), observer), | 57 observers_.erase(std::find(observers_.begin(), observers_.end(), observer), |
58 observers_.end()); | 58 observers_.end()); |
59 } | 59 } |
60 | 60 |
61 } // namespace cryptauth | 61 } // namespace cryptauth |
OLD | NEW |