| 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "extensions/browser/api/cast_channel/logger.h" | 15 #include "extensions/browser/api/cast_channel/logger.h" |
| 16 #include "extensions/common/api/cast_channel.h" | 16 #include "extensions/common/api/cast_channel.h" |
| 17 #include "extensions/common/api/cast_channel/logging.pb.h" | 17 #include "extensions/common/api/cast_channel/logging.pb.h" |
| 18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 19 #include "net/base/ip_endpoint.h" | 19 #include "net/base/ip_endpoint.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 class DrainableIOBuffer; | 22 class DrainableIOBuffer; |
| 23 class DrainableIOBuffer; | 23 class DrainableIOBuffer; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 virtual void Start() = 0; | 65 virtual void Start() = 0; |
| 66 | 66 |
| 67 // Changes the delegate for processing read events. Pending reads remain | 67 // Changes the delegate for processing read events. Pending reads remain |
| 68 // in-flight. | 68 // in-flight. |
| 69 // Ownership of the pointee of |delegate| is assumed by the transport. | 69 // Ownership of the pointee of |delegate| is assumed by the transport. |
| 70 // Prior delegates are deleted automatically. | 70 // Prior delegates are deleted automatically. |
| 71 virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0; | 71 virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Manager class for reading and writing messages to/from a socket. | 74 // Manager class for reading and writing messages to/from a socket. |
| 75 class CastTransportImpl : public CastTransport, public base::NonThreadSafe { | 75 class CastTransportImpl : public CastTransport { |
| 76 public: | 76 public: |
| 77 // Adds a CastMessage read/write layer to a socket. | 77 // Adds a CastMessage read/write layer to a socket. |
| 78 // Message read events are propagated to the owner via |read_delegate|. | 78 // Message read events are propagated to the owner via |read_delegate|. |
| 79 // |vlog_prefix| sets the prefix used for all VLOGged output. | 79 // |vlog_prefix| sets the prefix used for all VLOGged output. |
| 80 // |socket| and |logger| must all out-live the | 80 // |socket| and |logger| must all out-live the |
| 81 // CastTransportImpl instance. | 81 // CastTransportImpl instance. |
| 82 // |read_delegate| is owned by this CastTransportImpl object. | 82 // |read_delegate| is owned by this CastTransportImpl object. |
| 83 CastTransportImpl(net::Socket* socket, | 83 CastTransportImpl(net::Socket* socket, |
| 84 int channel_id, | 84 int channel_id, |
| 85 const net::IPEndPoint& ip_endpoint_, | 85 const net::IPEndPoint& ip_endpoint_, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 // IP address of the remote end. | 209 // IP address of the remote end. |
| 210 const net::IPEndPoint ip_endpoint_; | 210 const net::IPEndPoint ip_endpoint_; |
| 211 | 211 |
| 212 // Authentication level for the connection. | 212 // Authentication level for the connection. |
| 213 ChannelAuthType channel_auth_; | 213 ChannelAuthType channel_auth_; |
| 214 | 214 |
| 215 // Accumulates details of events and errors, for debugging purposes. | 215 // Accumulates details of events and errors, for debugging purposes. |
| 216 scoped_refptr<Logger> logger_; | 216 scoped_refptr<Logger> logger_; |
| 217 | 217 |
| 218 SEQUENCE_CHECKER(sequence_checker_); |
| 219 |
| 218 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); | 220 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); |
| 219 }; | 221 }; |
| 220 } // namespace cast_channel | 222 } // namespace cast_channel |
| 221 } // namespace api | 223 } // namespace api |
| 222 } // namespace extensions | 224 } // namespace extensions |
| 223 | 225 |
| 224 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ | 226 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ |
| OLD | NEW |