| 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 "content/browser/devtools/protocol/tethering_handler.h" | 5 #include "content/browser/devtools/protocol/tethering_handler.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/ip_address.h" | 10 #include "net/base/ip_address.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 SocketPump(net::StreamSocket* client_socket) | 34 SocketPump(net::StreamSocket* client_socket) |
| 35 : client_socket_(client_socket), | 35 : client_socket_(client_socket), |
| 36 pending_writes_(0), | 36 pending_writes_(0), |
| 37 pending_destruction_(false) { | 37 pending_destruction_(false) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 std::string Init(const CreateServerSocketCallback& socket_callback) { | 40 std::string Init(const CreateServerSocketCallback& socket_callback) { |
| 41 std::string channel_name; | 41 std::string channel_name; |
| 42 server_socket_ = socket_callback.Run(&channel_name); | 42 server_socket_ = socket_callback.Run(&channel_name); |
| 43 if (!server_socket_.get() || channel_name.empty()) | 43 if (!server_socket_.get() || channel_name.empty()) { |
| 44 SelfDestruct(); | 44 SelfDestruct(); |
| 45 return std::string(); |
| 46 } |
| 45 | 47 |
| 46 int result = server_socket_->Accept( | 48 int result = server_socket_->Accept( |
| 47 &accepted_socket_, | 49 &accepted_socket_, |
| 48 base::Bind(&SocketPump::OnAccepted, base::Unretained(this))); | 50 base::Bind(&SocketPump::OnAccepted, base::Unretained(this))); |
| 49 if (result != net::ERR_IO_PENDING) | 51 if (result != net::ERR_IO_PENDING) |
| 50 OnAccepted(result); | 52 OnAccepted(result); |
| 51 return channel_name; | 53 return channel_name; |
| 52 } | 54 } |
| 53 | 55 |
| 54 private: | 56 private: |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 393 } |
| 392 | 394 |
| 393 void TetheringHandler::SendInternalError(DevToolsCommandId command_id, | 395 void TetheringHandler::SendInternalError(DevToolsCommandId command_id, |
| 394 const std::string& message) { | 396 const std::string& message) { |
| 395 client_->SendError(command_id, Response::InternalError(message)); | 397 client_->SendError(command_id, Response::InternalError(message)); |
| 396 } | 398 } |
| 397 | 399 |
| 398 } // namespace tethering | 400 } // namespace tethering |
| 399 } // namespace devtools | 401 } // namespace devtools |
| 400 } // namespace content | 402 } // namespace content |
| OLD | NEW |