| Index: components/cryptauth/secure_channel.cc
|
| diff --git a/components/cryptauth/secure_channel.cc b/components/cryptauth/secure_channel.cc
|
| index c8ed9fdc4471b35ed2cdc1733269e2ac8912f8f0..351e2ec6b90a49f2482715172d39cdf2cc308ce0 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:
|
| @@ -42,9 +68,9 @@ SecureChannel::PendingMessage::~PendingMessage() {}
|
| SecureChannel::SecureChannel(
|
| std::unique_ptr<Connection> connection,
|
| std::unique_ptr<Delegate> delegate)
|
| - : connection_(std::move(connection)),
|
| + : status_(Status::DISCONNECTED),
|
| + connection_(std::move(connection)),
|
| delegate_(std::move(delegate)),
|
| - status_(Status::DISCONNECTED),
|
| weak_ptr_factory_(this) {
|
| DCHECK(connection_);
|
| DCHECK(!connection_->IsConnected());
|
|
|