| 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 #ifndef COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ | 5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| 6 #define COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ | 6 #define COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Changes the delegate for processing read events. Pending reads remain | 64 // Changes the delegate for processing read events. Pending reads remain |
| 65 // in-flight. | 65 // in-flight. |
| 66 // Ownership of the pointee of |delegate| is assumed by the transport. | 66 // Ownership of the pointee of |delegate| is assumed by the transport. |
| 67 // Prior delegates are deleted automatically. | 67 // Prior delegates are deleted automatically. |
| 68 virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0; | 68 virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Manager class for reading and writing messages to/from a socket. | 71 // Manager class for reading and writing messages to/from a socket. |
| 72 class CastTransportImpl : public CastTransport { | 72 class CastTransportImpl : public CastTransport { |
| 73 public: | 73 public: |
| 74 using ChannelAuthType = ::cast_channel::ChannelAuthType; | |
| 75 using ChannelError = ::cast_channel::ChannelError; | 74 using ChannelError = ::cast_channel::ChannelError; |
| 76 | 75 |
| 77 // Adds a CastMessage read/write layer to a socket. | 76 // Adds a CastMessage read/write layer to a socket. |
| 78 // Message read events are propagated to the owner via |read_delegate|. | 77 // Message read events are propagated to the owner via |read_delegate|. |
| 79 // |vlog_prefix| sets the prefix used for all VLOGged output. | 78 // |vlog_prefix| sets the prefix used for all VLOGged output. |
| 80 // |socket| and |logger| must all out-live the | 79 // |socket| and |logger| must all out-live the |
| 81 // CastTransportImpl instance. | 80 // CastTransportImpl instance. |
| 82 // |read_delegate| is owned by this CastTransportImpl object. | 81 // |read_delegate| is owned by this CastTransportImpl object. |
| 83 CastTransportImpl(net::Socket* socket, | 82 CastTransportImpl(net::Socket* socket, |
| 84 int channel_id, | 83 int channel_id, |
| 85 const net::IPEndPoint& ip_endpoint_, | 84 const net::IPEndPoint& ip_endpoint_, |
| 86 ChannelAuthType channel_auth_, | |
| 87 scoped_refptr<Logger> logger); | 85 scoped_refptr<Logger> logger); |
| 88 | 86 |
| 89 ~CastTransportImpl() override; | 87 ~CastTransportImpl() override; |
| 90 | 88 |
| 91 // CastTransport interface. | 89 // CastTransport interface. |
| 92 void SendMessage(const CastMessage& message, | 90 void SendMessage(const CastMessage& message, |
| 93 const net::CompletionCallback& callback) override; | 91 const net::CompletionCallback& callback) override; |
| 94 void Start() override; | 92 void Start() override; |
| 95 void SetReadDelegate(std::unique_ptr<Delegate> delegate) override; | 93 void SetReadDelegate(std::unique_ptr<Delegate> delegate) override; |
| 96 | 94 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // The last error encountered by the channel. | 175 // The last error encountered by the channel. |
| 178 ChannelError error_state_; | 176 ChannelError error_state_; |
| 179 | 177 |
| 180 // Connection metadata for logging purposes. | 178 // Connection metadata for logging purposes. |
| 181 // Socket ID assigned by ApiResourceManager. | 179 // Socket ID assigned by ApiResourceManager. |
| 182 int channel_id_; | 180 int channel_id_; |
| 183 | 181 |
| 184 // IP address of the remote end. | 182 // IP address of the remote end. |
| 185 const net::IPEndPoint ip_endpoint_; | 183 const net::IPEndPoint ip_endpoint_; |
| 186 | 184 |
| 187 // Authentication level for the connection. | |
| 188 ChannelAuthType channel_auth_; | |
| 189 | |
| 190 // Accumulates details of events and errors, for debugging purposes. | 185 // Accumulates details of events and errors, for debugging purposes. |
| 191 scoped_refptr<Logger> logger_; | 186 scoped_refptr<Logger> logger_; |
| 192 | 187 |
| 193 SEQUENCE_CHECKER(sequence_checker_); | 188 SEQUENCE_CHECKER(sequence_checker_); |
| 194 | 189 |
| 195 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); | 190 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); |
| 196 }; | 191 }; |
| 197 } // namespace cast_channel | 192 } // namespace cast_channel |
| 198 | 193 |
| 199 #endif // COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ | 194 #endif // COMPONENTS_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| OLD | NEW |