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 "components/devtools_bridge/socket_tunnel_server.h" | 5 #include "components/devtools_bridge/socket_tunnel_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "components/devtools_bridge/abstract_data_channel.h" | 9 #include "components/devtools_bridge/abstract_data_channel.h" |
10 #include "components/devtools_bridge/session_dependency_factory.h" | 10 #include "components/devtools_bridge/session_dependency_factory.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 protected: | 49 protected: |
50 net::StreamSocket* socket() override { | 50 net::StreamSocket* socket() override { |
51 return &socket_; | 51 return &socket_; |
52 } | 52 } |
53 | 53 |
54 void OnDataPacketRead(const void* data, size_t length) override { | 54 void OnDataPacketRead(const void* data, size_t length) override { |
55 delegate_->SendPacket(data, length); | 55 delegate_->SendPacket(data, length); |
56 ReadNextChunk(); | 56 ReadNextChunk(); |
57 } | 57 } |
58 | 58 |
59 virtual void OnReadError(int error) override { | 59 void OnReadError(int error) override { |
60 socket()->Disconnect(); | 60 socket()->Disconnect(); |
61 SendControlPacket(SERVER_CLOSE); | 61 SendControlPacket(SERVER_CLOSE); |
62 delegate_->RemoveConnection(index_); | 62 delegate_->RemoveConnection(index_); |
63 delegate_ = NULL; | 63 delegate_ = NULL; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 void OnConnectionComplete(int result) { | 67 void OnConnectionComplete(int result) { |
68 if (result == net::OK) { | 68 if (result == net::OK) { |
69 SendControlPacket(SERVER_OPEN_ACK); | 69 SendControlPacket(SERVER_OPEN_ACK); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 controller.Pass())); | 257 controller.Pass())); |
258 | 258 |
259 data_channel_->RegisterObserver(data_channel_observer.Pass()); | 259 data_channel_->RegisterObserver(data_channel_observer.Pass()); |
260 } | 260 } |
261 | 261 |
262 SocketTunnelServer::~SocketTunnelServer() { | 262 SocketTunnelServer::~SocketTunnelServer() { |
263 data_channel_->UnregisterObserver(); | 263 data_channel_->UnregisterObserver(); |
264 } | 264 } |
265 | 265 |
266 } // namespace devtools_bridge | 266 } // namespace devtools_bridge |
OLD | NEW |