| 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_stream_socket.h" | 5 #include "remoting/protocol/fake_stream_socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); | 36 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); |
| 37 input_data_.insert(input_data_.end(), data.begin(), data.end()); | 37 input_data_.insert(input_data_.end(), data.begin(), data.end()); |
| 38 // Complete pending read if any. | 38 // Complete pending read if any. |
| 39 if (!read_callback_.is_null()) { | 39 if (!read_callback_.is_null()) { |
| 40 int result = std::min(read_buffer_size_, | 40 int result = std::min(read_buffer_size_, |
| 41 static_cast<int>(input_data_.size() - input_pos_)); | 41 static_cast<int>(input_data_.size() - input_pos_)); |
| 42 EXPECT_GT(result, 0); | 42 EXPECT_GT(result, 0); |
| 43 memcpy(read_buffer_->data(), | 43 memcpy(read_buffer_->data(), |
| 44 &(*input_data_.begin()) + input_pos_, result); | 44 &(*input_data_.begin()) + input_pos_, result); |
| 45 input_pos_ += result; | 45 input_pos_ += result; |
| 46 read_buffer_ = NULL; | 46 read_buffer_ = nullptr; |
| 47 | 47 |
| 48 net::CompletionCallback callback = read_callback_; | 48 net::CompletionCallback callback = read_callback_; |
| 49 read_callback_.Reset(); | 49 read_callback_.Reset(); |
| 50 callback.Run(result); | 50 callback.Run(result); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 void FakeStreamSocket::PairWith(FakeStreamSocket* peer_socket) { | 54 void FakeStreamSocket::PairWith(FakeStreamSocket* peer_socket) { |
| 55 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); | 55 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); |
| 56 peer_socket_ = peer_socket->GetWeakPtr(); | 56 peer_socket_ = peer_socket->GetWeakPtr(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 if (channels_.find(name) != channels_.end()) | 268 if (channels_.find(name) != channels_.end()) |
| 269 callback.Run(owned_channel.Pass()); | 269 callback.Run(owned_channel.Pass()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void FakeStreamChannelFactory::CancelChannelCreation(const std::string& name) { | 272 void FakeStreamChannelFactory::CancelChannelCreation(const std::string& name) { |
| 273 channels_.erase(name); | 273 channels_.erase(name); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace protocol | 276 } // namespace protocol |
| 277 } // namespace remoting | 277 } // namespace remoting |
| OLD | NEW |