Chromium Code Reviews| 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 channel_name.clear(); | |
| 46 return channel_name; | |
|
pfeldman
2016/10/04 01:23:42
nit: return std::string();
pwnall
2016/10/04 01:30:50
Done.
FWIW, I was (over-)thinking about RVO.
| |
| 47 } | |
| 45 | 48 |
| 46 int result = server_socket_->Accept( | 49 int result = server_socket_->Accept( |
| 47 &accepted_socket_, | 50 &accepted_socket_, |
| 48 base::Bind(&SocketPump::OnAccepted, base::Unretained(this))); | 51 base::Bind(&SocketPump::OnAccepted, base::Unretained(this))); |
| 49 if (result != net::ERR_IO_PENDING) | 52 if (result != net::ERR_IO_PENDING) |
| 50 OnAccepted(result); | 53 OnAccepted(result); |
| 51 return channel_name; | 54 return channel_name; |
| 52 } | 55 } |
| 53 | 56 |
| 54 private: | 57 private: |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 } | 394 } |
| 392 | 395 |
| 393 void TetheringHandler::SendInternalError(DevToolsCommandId command_id, | 396 void TetheringHandler::SendInternalError(DevToolsCommandId command_id, |
| 394 const std::string& message) { | 397 const std::string& message) { |
| 395 client_->SendError(command_id, Response::InternalError(message)); | 398 client_->SendError(command_id, Response::InternalError(message)); |
| 396 } | 399 } |
| 397 | 400 |
| 398 } // namespace tethering | 401 } // namespace tethering |
| 399 } // namespace devtools | 402 } // namespace devtools |
| 400 } // namespace content | 403 } // namespace content |
| OLD | NEW |