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

Unified Diff: components/cryptauth/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/secure_channel.h ('k') | components/cryptauth/secure_channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/secure_channel.cc
diff --git a/components/cryptauth/secure_channel.cc b/components/cryptauth/secure_channel.cc
index c8ed9fdc4471b35ed2cdc1733269e2ac8912f8f0..a51b5c8e5871f7df80f50cec2a6ab8b97b259969 100644
--- a/components/cryptauth/secure_channel.cc
+++ b/components/cryptauth/secure_channel.cc
@@ -12,6 +12,32 @@
namespace cryptauth {
// static
+SecureChannel::Factory* SecureChannel::Factory::factory_instance_ = nullptr;
+
+// static
+std::unique_ptr<SecureChannel> SecureChannel::Factory::NewInstance(
+ std::unique_ptr<Connection> connection,
+ std::unique_ptr<Delegate> delegate) {
+ if (!factory_instance_) {
+ factory_instance_ = new Factory();
+ }
+ return factory_instance_->BuildInstance(std::move(connection),
+ std::move(delegate));
+}
+
+// static
+void SecureChannel::Factory::SetInstanceForTesting(Factory* factory) {
+ factory_instance_ = factory;
+}
+
+std::unique_ptr<SecureChannel> SecureChannel::Factory::BuildInstance(
+ std::unique_ptr<Connection> connection,
+ std::unique_ptr<Delegate> delegate) {
+ return base::WrapUnique(
+ new SecureChannel(std::move(connection), std::move(delegate)));
+}
+
+// static
std::string SecureChannel::StatusToString(const Status& status) {
switch (status) {
case Status::DISCONNECTED:
@@ -39,12 +65,11 @@ SecureChannel::PendingMessage::PendingMessage(
SecureChannel::PendingMessage::~PendingMessage() {}
-SecureChannel::SecureChannel(
- std::unique_ptr<Connection> connection,
- std::unique_ptr<Delegate> delegate)
- : connection_(std::move(connection)),
+SecureChannel::SecureChannel(std::unique_ptr<Connection> connection,
+ std::unique_ptr<Delegate> delegate)
+ : status_(Status::DISCONNECTED),
+ connection_(std::move(connection)),
delegate_(std::move(delegate)),
- status_(Status::DISCONNECTED),
weak_ptr_factory_(this) {
DCHECK(connection_);
DCHECK(!connection_->IsConnected());
« no previous file with comments | « components/cryptauth/secure_channel.h ('k') | components/cryptauth/secure_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698