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_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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 ~CastSocket() override {} | 63 ~CastSocket() override {} |
64 | 64 |
65 // Used by BrowserContextKeyedAPIFactory. | 65 // Used by BrowserContextKeyedAPIFactory. |
66 static const char* service_name() { return "CastSocketImplManager"; } | 66 static const char* service_name() { return "CastSocketImplManager"; } |
67 | 67 |
68 // Connects the channel to the peer. If successful, the channel will be in | 68 // Connects the channel to the peer. If successful, the channel will be in |
69 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|. | 69 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|. |
70 // Instead use Close(). | 70 // Instead use Close(). |
71 // |callback| will be invoked with any ChannelError that occurred, or | 71 // |callback| will be invoked with any ChannelError that occurred, or |
72 // CHANNEL_ERROR_NONE if successful. | 72 // CHANNEL_ERROR_NONE if successful. |
73 // If the CastSocket is destroyed while the connection is pending, |callback| | |
74 // will be invoked with CHANNEL_ERROR_UNKNOWN. In this case, invoking | |
mark a. foltz
2017/02/21 18:30:01
CHANNEL_ERROR_SOCKET_ERROR is used elsewhere for s
imcheng
2017/02/21 22:55:48
socket_error is used for errors with read/write so
| |
75 // |callback| must not result in an re-entrancy behavior. | |
mark a. foltz
2017/02/21 18:30:01
s/an/any/
imcheng
2017/02/21 22:55:48
Done.
| |
73 // |delegate| receives message receipt and error events. | 76 // |delegate| receives message receipt and error events. |
74 // Ownership of |delegate| is transferred to this CastSocket. | 77 // Ownership of |delegate| is transferred to this CastSocket. |
75 virtual void Connect(std::unique_ptr<CastTransport::Delegate> delegate, | 78 virtual void Connect(std::unique_ptr<CastTransport::Delegate> delegate, |
76 base::Callback<void(ChannelError)> callback) = 0; | 79 base::Callback<void(ChannelError)> callback) = 0; |
77 | 80 |
78 // Closes the channel if not already closed. On completion, the channel will | 81 // Closes the channel if not already closed. On completion, the channel will |
79 // be in READY_STATE_CLOSED. | 82 // be in READY_STATE_CLOSED. |
80 // | 83 // |
81 // It is fine to delete this object in |callback|. | 84 // It is fine to delete this object in |callback|. |
82 virtual void Close(const net::CompletionCallback& callback) = 0; | 85 virtual void Close(const net::CompletionCallback& callback) = 0; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 std::unique_ptr<net::SSLClientSocket> socket_; | 319 std::unique_ptr<net::SSLClientSocket> socket_; |
317 | 320 |
318 // Certificate of the peer. This field may be empty if the peer | 321 // Certificate of the peer. This field may be empty if the peer |
319 // certificate is not yet fetched. | 322 // certificate is not yet fetched. |
320 scoped_refptr<net::X509Certificate> peer_cert_; | 323 scoped_refptr<net::X509Certificate> peer_cert_; |
321 | 324 |
322 // Reply received from the receiver to a challenge request. | 325 // Reply received from the receiver to a challenge request. |
323 std::unique_ptr<CastMessage> challenge_reply_; | 326 std::unique_ptr<CastMessage> challenge_reply_; |
324 | 327 |
325 // Callback invoked when the socket is connected or fails to connect. | 328 // Callback invoked when the socket is connected or fails to connect. |
329 // TODO(imcheng): Change to OnceCallback? OnceCallback is move-only which | |
mark a. foltz
2017/02/21 18:30:01
I think the benefit is pretty slight here, not sur
imcheng
2017/02/21 22:55:47
Ok, removed TODO.
| |
330 // is an issue for gmock. | |
326 base::Callback<void(ChannelError)> connect_callback_; | 331 base::Callback<void(ChannelError)> connect_callback_; |
327 | 332 |
328 // Callback invoked by |connect_timeout_timer_| to cancel the connection. | 333 // Callback invoked by |connect_timeout_timer_| to cancel the connection. |
329 base::CancelableClosure connect_timeout_callback_; | 334 base::CancelableClosure connect_timeout_callback_; |
330 | 335 |
331 // Duration to wait before timing out. | 336 // Duration to wait before timing out. |
332 base::TimeDelta connect_timeout_; | 337 base::TimeDelta connect_timeout_; |
333 | 338 |
334 // Timer invoked when the connection has timed out. | 339 // Timer invoked when the connection has timed out. |
335 std::unique_ptr<base::Timer> connect_timeout_timer_; | 340 std::unique_ptr<base::Timer> connect_timeout_timer_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 // information. | 383 // information. |
379 AuthTransportDelegate* auth_delegate_; | 384 AuthTransportDelegate* auth_delegate_; |
380 | 385 |
381 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); | 386 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); |
382 }; | 387 }; |
383 } // namespace cast_channel | 388 } // namespace cast_channel |
384 } // namespace api | 389 } // namespace api |
385 } // namespace extensions | 390 } // namespace extensions |
386 | 391 |
387 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_ | 392 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_SOCKET_H_ |
OLD | NEW |