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

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

Issue 588433002: Revert "Make protobuf enums canonical for ReadState/WriteState/ConnectState." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_SOCKET_H_ 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_
6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_ 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "extensions/browser/api/api_resource.h" 17 #include "extensions/browser/api/api_resource.h"
18 #include "extensions/browser/api/api_resource_manager.h" 18 #include "extensions/browser/api/api_resource_manager.h"
19 #include "extensions/browser/api/cast_channel/logging.pb.h"
20 #include "extensions/common/api/cast_channel.h" 19 #include "extensions/common/api/cast_channel.h"
21 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
22 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
23 #include "net/base/ip_endpoint.h" 22 #include "net/base/ip_endpoint.h"
24 #include "net/base/net_log.h" 23 #include "net/base/net_log.h"
25 24
26 namespace net { 25 namespace net {
27 class AddressList; 26 class AddressList;
28 class CertVerifier; 27 class CertVerifier;
29 class SSLClientSocket; 28 class SSLClientSocket;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // DO NOT delete the CastSocket object in |callback|. Instead use Close(). 119 // DO NOT delete the CastSocket object in |callback|. Instead use Close().
121 virtual void SendMessage(const MessageInfo& message, 120 virtual void SendMessage(const MessageInfo& message,
122 const net::CompletionCallback& callback); 121 const net::CompletionCallback& callback);
123 122
124 // Closes the channel if not already closed. On completion, the channel will 123 // Closes the channel if not already closed. On completion, the channel will
125 // be in READY_STATE_CLOSED. 124 // be in READY_STATE_CLOSED.
126 // 125 //
127 // It is fine to delete the CastSocket object in |callback|. 126 // It is fine to delete the CastSocket object in |callback|.
128 virtual void Close(const net::CompletionCallback& callback); 127 virtual void Close(const net::CompletionCallback& callback);
129 128
129 // Internal connection states.
130 enum ConnectionState {
131 CONN_STATE_NONE,
132 CONN_STATE_TCP_CONNECT,
133 CONN_STATE_TCP_CONNECT_COMPLETE,
134 CONN_STATE_SSL_CONNECT,
135 CONN_STATE_SSL_CONNECT_COMPLETE,
136 CONN_STATE_AUTH_CHALLENGE_SEND,
137 CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE,
138 CONN_STATE_AUTH_CHALLENGE_REPLY_COMPLETE,
139 };
140
141 // Internal write states.
142 enum WriteState {
143 WRITE_STATE_NONE,
144 WRITE_STATE_WRITE,
145 WRITE_STATE_WRITE_COMPLETE,
146 WRITE_STATE_DO_CALLBACK,
147 WRITE_STATE_ERROR,
148 };
149
150 // Internal read states.
151 enum ReadState {
152 READ_STATE_NONE,
153 READ_STATE_READ,
154 READ_STATE_READ_COMPLETE,
155 READ_STATE_DO_CALLBACK,
156 READ_STATE_ERROR,
157 };
158
130 private: 159 private:
131 friend class ApiResourceManager<CastSocket>; 160 friend class ApiResourceManager<CastSocket>;
132 friend class CastSocketTest; 161 friend class CastSocketTest;
133 friend class TestCastSocket; 162 friend class TestCastSocket;
134 163
135 static const char* service_name() { return "CastSocketManager"; } 164 static const char* service_name() { return "CastSocketManager"; }
136 165
137 // Creates an instance of TCPClientSocket. 166 // Creates an instance of TCPClientSocket.
138 virtual scoped_ptr<net::TCPClientSocket> CreateTcpSocket(); 167 virtual scoped_ptr<net::TCPClientSocket> CreateTcpSocket();
139 // Creates an instance of SSLClientSocket with the given underlying |socket|. 168 // Creates an instance of SSLClientSocket with the given underlying |socket|.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // pending operations will fail because the socket has been closed. 253 // pending operations will fail because the socket has been closed.
225 void RunPendingCallbacksOnClose(); 254 void RunPendingCallbacksOnClose();
226 // Serializes the content of message_proto (with a header) to |message_data|. 255 // Serializes the content of message_proto (with a header) to |message_data|.
227 static bool Serialize(const CastMessage& message_proto, 256 static bool Serialize(const CastMessage& message_proto,
228 std::string* message_data); 257 std::string* message_data);
229 258
230 virtual bool CalledOnValidThread() const; 259 virtual bool CalledOnValidThread() const;
231 260
232 virtual base::Timer* GetTimer(); 261 virtual base::Timer* GetTimer();
233 262
234 void SetConnectState(proto::ConnectionState connect_state); 263 void SetConnectState(ConnectionState connect_state);
235 void SetReadyState(ReadyState ready_state); 264 void SetReadyState(ReadyState ready_state);
236 void SetErrorState(ChannelError error_state); 265 void SetErrorState(ChannelError error_state);
237 void SetReadState(proto::ReadState read_state); 266 void SetReadState(ReadState read_state);
238 void SetWriteState(proto::WriteState write_state); 267 void SetWriteState(WriteState write_state);
239 268
240 base::ThreadChecker thread_checker_; 269 base::ThreadChecker thread_checker_;
241 270
242 // The id of the channel. 271 // The id of the channel.
243 int channel_id_; 272 int channel_id_;
244 273
245 // The IP endpoint that the the channel is connected to. 274 // The IP endpoint that the the channel is connected to.
246 net::IPEndPoint ip_endpoint_; 275 net::IPEndPoint ip_endpoint_;
247 // Receiver authentication requested for the channel. 276 // Receiver authentication requested for the channel.
248 ChannelAuthType channel_auth_; 277 ChannelAuthType channel_auth_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 base::TimeDelta connect_timeout_; 315 base::TimeDelta connect_timeout_;
287 // Timer invoked when the connection has timed out. 316 // Timer invoked when the connection has timed out.
288 scoped_ptr<base::Timer> connect_timeout_timer_; 317 scoped_ptr<base::Timer> connect_timeout_timer_;
289 // Set when a timeout is triggered and the connection process has 318 // Set when a timeout is triggered and the connection process has
290 // canceled. 319 // canceled.
291 bool is_canceled_; 320 bool is_canceled_;
292 321
293 scoped_ptr<CastMessage> current_message_; 322 scoped_ptr<CastMessage> current_message_;
294 323
295 // Connection flow state machine state. 324 // Connection flow state machine state.
296 proto::ConnectionState connect_state_; 325 ConnectionState connect_state_;
297 // Write flow state machine state. 326 // Write flow state machine state.
298 proto::WriteState write_state_; 327 WriteState write_state_;
299 // Read flow state machine state. 328 // Read flow state machine state.
300 proto::ReadState read_state_; 329 ReadState read_state_;
301 // The last error encountered by the channel. 330 // The last error encountered by the channel.
302 ChannelError error_state_; 331 ChannelError error_state_;
303 // The current status of the channel. 332 // The current status of the channel.
304 ReadyState ready_state_; 333 ReadyState ready_state_;
305 334
306 // Task invoked to (re)start the connect loop. Canceled on entry to the 335 // Task invoked to (re)start the connect loop. Canceled on entry to the
307 // connect loop. 336 // connect loop.
308 base::CancelableClosure connect_loop_callback_; 337 base::CancelableClosure connect_loop_callback_;
309 // Task invoked to send the auth challenge. Canceled when the auth challenge 338 // Task invoked to send the auth challenge. Canceled when the auth challenge
310 // has been sent. 339 // has been sent.
(...skipping 24 matching lines...) Expand all
335 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadHeaderParseError); 364 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadHeaderParseError);
336 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); 365 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany);
337 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestWriteErrorLargeMessage); 366 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestWriteErrorLargeMessage);
338 DISALLOW_COPY_AND_ASSIGN(CastSocket); 367 DISALLOW_COPY_AND_ASSIGN(CastSocket);
339 }; 368 };
340 } // namespace cast_channel 369 } // namespace cast_channel
341 } // namespace core_api 370 } // namespace core_api
342 } // namespace extensions 371 } // namespace extensions
343 372
344 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_ 373 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_channel.proto ('k') | extensions/browser/api/cast_channel/cast_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698