| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/protocol/fake_datagram_socket.h" | 5 #include "remoting/protocol/fake_datagram_socket.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 FakeDatagramChannelFactory::FakeDatagramChannelFactory() | 130 FakeDatagramChannelFactory::FakeDatagramChannelFactory() |
| 131 : task_runner_(base::ThreadTaskRunnerHandle::Get()), | 131 : task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 132 asynchronous_create_(false), | 132 asynchronous_create_(false), |
| 133 fail_create_(false), | 133 fail_create_(false), |
| 134 weak_factory_(this) { | 134 weak_factory_(this) { |
| 135 } | 135 } |
| 136 | 136 |
| 137 FakeDatagramChannelFactory::~FakeDatagramChannelFactory() { | 137 FakeDatagramChannelFactory::~FakeDatagramChannelFactory() { |
| 138 for (ChannelsMap::iterator it = channels_.begin(); it != channels_.end(); | 138 for (ChannelsMap::iterator it = channels_.begin(); it != channels_.end(); |
| 139 ++it) { | 139 ++it) { |
| 140 EXPECT_TRUE(it->second == nullptr); | 140 EXPECT_FALSE(it->second); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void FakeDatagramChannelFactory::PairWith( | 144 void FakeDatagramChannelFactory::PairWith( |
| 145 FakeDatagramChannelFactory* peer_factory) { | 145 FakeDatagramChannelFactory* peer_factory) { |
| 146 peer_factory_ = peer_factory->weak_factory_.GetWeakPtr(); | 146 peer_factory_ = peer_factory->weak_factory_.GetWeakPtr(); |
| 147 peer_factory_->peer_factory_ = weak_factory_.GetWeakPtr(); | 147 peer_factory_->peer_factory_ = weak_factory_.GetWeakPtr(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 FakeDatagramSocket* FakeDatagramChannelFactory::GetFakeChannel( | 150 FakeDatagramSocket* FakeDatagramChannelFactory::GetFakeChannel( |
| 151 const std::string& name) { | 151 const std::string& name) { |
| 152 return channels_[name].get(); | 152 return channels_[name].get(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void FakeDatagramChannelFactory::CreateChannel( | 155 void FakeDatagramChannelFactory::CreateChannel( |
| 156 const std::string& name, | 156 const std::string& name, |
| 157 const ChannelCreatedCallback& callback) { | 157 const ChannelCreatedCallback& callback) { |
| 158 EXPECT_TRUE(channels_[name] == nullptr); | 158 EXPECT_FALSE(channels_[name]); |
| 159 | 159 |
| 160 std::unique_ptr<FakeDatagramSocket> channel(new FakeDatagramSocket()); | 160 std::unique_ptr<FakeDatagramSocket> channel(new FakeDatagramSocket()); |
| 161 channels_[name] = channel->GetWeakPtr(); | 161 channels_[name] = channel->GetWeakPtr(); |
| 162 | 162 |
| 163 if (peer_factory_) { | 163 if (peer_factory_) { |
| 164 FakeDatagramSocket* peer_socket = peer_factory_->GetFakeChannel(name); | 164 FakeDatagramSocket* peer_socket = peer_factory_->GetFakeChannel(name); |
| 165 if (peer_socket) | 165 if (peer_socket) |
| 166 channel->PairWith(peer_socket); | 166 channel->PairWith(peer_socket); |
| 167 } | 167 } |
| 168 | 168 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 188 callback.Run(std::move(owned_socket)); | 188 callback.Run(std::move(owned_socket)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void FakeDatagramChannelFactory::CancelChannelCreation( | 191 void FakeDatagramChannelFactory::CancelChannelCreation( |
| 192 const std::string& name) { | 192 const std::string& name) { |
| 193 channels_.erase(name); | 193 channels_.erase(name); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace protocol | 196 } // namespace protocol |
| 197 } // namespace remoting | 197 } // namespace remoting |
| OLD | NEW |