Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: components/cryptauth/fake_secure_channel.cc

Issue 2697763002: [CrOS Tether]: Create BleConnectionManager, which manages secure connections between the current de… (Closed)
Patch Set: Add missing DEP. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cryptauth/fake_secure_channel.h ('k') | components/cryptauth/secure_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/fake_secure_channel.cc
diff --git a/components/cryptauth/fake_secure_channel.cc b/components/cryptauth/fake_secure_channel.cc
new file mode 100644
index 0000000000000000000000000000000000000000..11bfe1797f4a25512af3e1b2364bac0986857a64
--- /dev/null
+++ b/components/cryptauth/fake_secure_channel.cc
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cryptauth/fake_secure_channel.h"
+
+#include "base/logging.h"
+
+namespace cryptauth {
+
+FakeSecureChannel::SentMessage::SentMessage(const std::string& feature,
+ const std::string& payload)
+ : feature(feature), payload(payload) {}
+
+FakeSecureChannel::FakeSecureChannel(std::unique_ptr<Connection> connection,
+ std::unique_ptr<Delegate> delegate)
+ : SecureChannel(std::move(connection), std::move(delegate)) {}
+
+FakeSecureChannel::~FakeSecureChannel() {}
+
+void FakeSecureChannel::ChangeStatus(const Status& new_status) {
+ Status old_status = status_;
+ status_ = new_status;
+
+ // Copy to prevent channel from being removed during handler.
+ std::vector<Observer*> observers_copy = observers_;
+ for (auto observer : observers_copy) {
+ observer->OnSecureChannelStatusChanged(this, old_status, status_);
+ }
+}
+
+void FakeSecureChannel::ReceiveMessage(const std::string& feature,
+ const std::string& payload) {
+ // Copy to prevent channel from being removed during handler.
+ std::vector<Observer*> observers_copy = observers_;
+ for (auto observer : observers_copy) {
+ observer->OnMessageReceived(this, feature, payload);
+ }
+}
+
+void FakeSecureChannel::Initialize() {}
+
+void FakeSecureChannel::SendMessage(const std::string& feature,
+ const std::string& payload) {
+ sent_messages_.push_back(SentMessage(feature, payload));
+}
+
+void FakeSecureChannel::Disconnect() {
+ ChangeStatus(Status::DISCONNECTED);
+}
+
+void FakeSecureChannel::AddObserver(Observer* observer) {
+ observers_.push_back(observer);
+}
+
+void FakeSecureChannel::RemoveObserver(Observer* observer) {
+ observers_.erase(std::find(observers_.begin(), observers_.end(), observer),
+ observers_.end());
+}
+
+} // namespace cryptauth
« no previous file with comments | « components/cryptauth/fake_secure_channel.h ('k') | components/cryptauth/secure_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698