Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: extensions/browser/api/cast_channel/cast_transport.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Initializes the reading state machine and starts reading from the 65 // Initializes the reading state machine and starts reading from the
66 // underlying socket. 66 // underlying socket.
67 // Virtual for testing. 67 // Virtual for testing.
68 virtual void Start() = 0; 68 virtual void Start() = 0;
69 69
70 // Changes the delegate for processing read events. Pending reads remain 70 // Changes the delegate for processing read events. Pending reads remain
71 // in-flight. 71 // in-flight.
72 // Ownership of the pointee of |delegate| is assumed by the transport. 72 // Ownership of the pointee of |delegate| is assumed by the transport.
73 // Prior delegates are deleted automatically. 73 // Prior delegates are deleted automatically.
74 virtual void SetReadDelegate(scoped_ptr<Delegate> delegate) = 0; 74 virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0;
75 }; 75 };
76 76
77 // Manager class for reading and writing messages to/from a socket. 77 // Manager class for reading and writing messages to/from a socket.
78 class CastTransportImpl : public CastTransport, public base::NonThreadSafe { 78 class CastTransportImpl : public CastTransport, public base::NonThreadSafe {
79 public: 79 public:
80 // Adds a CastMessage read/write layer to a socket. 80 // Adds a CastMessage read/write layer to a socket.
81 // Message read events are propagated to the owner via |read_delegate|. 81 // Message read events are propagated to the owner via |read_delegate|.
82 // |vlog_prefix| sets the prefix used for all VLOGged output. 82 // |vlog_prefix| sets the prefix used for all VLOGged output.
83 // |socket| and |logger| must all out-live the 83 // |socket| and |logger| must all out-live the
84 // CastTransportImpl instance. 84 // CastTransportImpl instance.
85 // |read_delegate| is owned by this CastTransportImpl object. 85 // |read_delegate| is owned by this CastTransportImpl object.
86 CastTransportImpl(net::Socket* socket, 86 CastTransportImpl(net::Socket* socket,
87 int channel_id, 87 int channel_id,
88 const net::IPEndPoint& ip_endpoint_, 88 const net::IPEndPoint& ip_endpoint_,
89 ChannelAuthType channel_auth_, 89 ChannelAuthType channel_auth_,
90 scoped_refptr<Logger> logger); 90 scoped_refptr<Logger> logger);
91 91
92 ~CastTransportImpl() override; 92 ~CastTransportImpl() override;
93 93
94 // CastTransport interface. 94 // CastTransport interface.
95 void SendMessage(const CastMessage& message, 95 void SendMessage(const CastMessage& message,
96 const net::CompletionCallback& callback) override; 96 const net::CompletionCallback& callback) override;
97 void Start() override; 97 void Start() override;
98 void SetReadDelegate(scoped_ptr<Delegate> delegate) override; 98 void SetReadDelegate(std::unique_ptr<Delegate> delegate) override;
99 99
100 private: 100 private:
101 // Internal write states. 101 // Internal write states.
102 enum WriteState { 102 enum WriteState {
103 WRITE_STATE_UNKNOWN, 103 WRITE_STATE_UNKNOWN,
104 WRITE_STATE_WRITE, 104 WRITE_STATE_WRITE,
105 WRITE_STATE_WRITE_COMPLETE, 105 WRITE_STATE_WRITE_COMPLETE,
106 WRITE_STATE_DO_CALLBACK, 106 WRITE_STATE_DO_CALLBACK,
107 WRITE_STATE_HANDLE_ERROR, 107 WRITE_STATE_HANDLE_ERROR,
108 WRITE_STATE_ERROR, 108 WRITE_STATE_ERROR,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 bool started_; 178 bool started_;
179 179
180 // Queue of pending writes. The message at the front of the queue is the one 180 // Queue of pending writes. The message at the front of the queue is the one
181 // being written. 181 // being written.
182 std::queue<WriteRequest> write_queue_; 182 std::queue<WriteRequest> write_queue_;
183 183
184 // Buffer used for read operations. Reused for every read. 184 // Buffer used for read operations. Reused for every read.
185 scoped_refptr<net::GrowableIOBuffer> read_buffer_; 185 scoped_refptr<net::GrowableIOBuffer> read_buffer_;
186 186
187 // Constructs and parses the wire representation of message frames. 187 // Constructs and parses the wire representation of message frames.
188 scoped_ptr<MessageFramer> framer_; 188 std::unique_ptr<MessageFramer> framer_;
189 189
190 // Last message received on the socket. 190 // Last message received on the socket.
191 scoped_ptr<CastMessage> current_message_; 191 std::unique_ptr<CastMessage> current_message_;
192 192
193 // Socket used for I/O operations. 193 // Socket used for I/O operations.
194 net::Socket* const socket_; 194 net::Socket* const socket_;
195 195
196 // Methods for communicating message receipt and error status to client code. 196 // Methods for communicating message receipt and error status to client code.
197 scoped_ptr<Delegate> delegate_; 197 std::unique_ptr<Delegate> delegate_;
198 198
199 // Write flow state machine state. 199 // Write flow state machine state.
200 WriteState write_state_; 200 WriteState write_state_;
201 201
202 // Read flow state machine state. 202 // Read flow state machine state.
203 ReadState read_state_; 203 ReadState read_state_;
204 204
205 // The last error encountered by the channel. 205 // The last error encountered by the channel.
206 ChannelError error_state_; 206 ChannelError error_state_;
207 207
(...skipping 10 matching lines...) Expand all
218 // Accumulates details of events and errors, for debugging purposes. 218 // Accumulates details of events and errors, for debugging purposes.
219 scoped_refptr<Logger> logger_; 219 scoped_refptr<Logger> logger_;
220 220
221 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); 221 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl);
222 }; 222 };
223 } // namespace cast_channel 223 } // namespace cast_channel
224 } // namespace api 224 } // namespace api
225 } // namespace extensions 225 } // namespace extensions
226 226
227 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_ 227 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TRANSPORT_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_test_util.cc ('k') | extensions/browser/api/cast_channel/cast_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698