OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_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/callback.h" | 12 #include "base/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/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "chrome/browser/extensions/api/api_resource.h" | |
18 #include "chrome/browser/extensions/api/api_resource_manager.h" | |
19 #include "chrome/common/extensions/api/cast_channel.h" | 17 #include "chrome/common/extensions/api/cast_channel.h" |
| 18 #include "extensions/browser/api/api_resource.h" |
| 19 #include "extensions/browser/api/api_resource_manager.h" |
20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
21 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
22 #include "net/base/ip_endpoint.h" | 22 #include "net/base/ip_endpoint.h" |
23 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 class AddressList; | 27 class AddressList; |
28 class CertVerifier; | 28 class CertVerifier; |
29 class SSLClientSocket; | 29 class SSLClientSocket; |
(...skipping 22 matching lines...) Expand all Loading... |
52 // NOTE: Not called "CastChannel" to reduce confusion with the generated API | 52 // NOTE: Not called "CastChannel" to reduce confusion with the generated API |
53 // code. | 53 // code. |
54 class CastSocket : public ApiResource, | 54 class CastSocket : public ApiResource, |
55 public base::SupportsWeakPtr<CastSocket> { | 55 public base::SupportsWeakPtr<CastSocket> { |
56 public: | 56 public: |
57 // Object to be informed of incoming messages and errors. | 57 // Object to be informed of incoming messages and errors. |
58 class Delegate { | 58 class Delegate { |
59 public: | 59 public: |
60 // An error occurred on the channel. | 60 // An error occurred on the channel. |
61 // It is fine to delete the socket in this callback. | 61 // It is fine to delete the socket in this callback. |
62 virtual void OnError(const CastSocket* socket, | 62 virtual void OnError(const CastSocket* socket, ChannelError error) = 0; |
63 ChannelError error) = 0; | |
64 // A message was received on the channel. | 63 // A message was received on the channel. |
65 // Do NOT delete the socket in this callback. | 64 // Do NOT delete the socket in this callback. |
66 virtual void OnMessage(const CastSocket* socket, | 65 virtual void OnMessage(const CastSocket* socket, |
67 const MessageInfo& message) = 0; | 66 const MessageInfo& message) = 0; |
| 67 |
68 protected: | 68 protected: |
69 virtual ~Delegate() {} | 69 virtual ~Delegate() {} |
70 }; | 70 }; |
71 | 71 |
72 // Creates a new CastSocket to |url|. |owner_extension_id| is the id of the | 72 // Creates a new CastSocket to |url|. |owner_extension_id| is the id of the |
73 // extension that opened the socket. | 73 // extension that opened the socket. |
74 CastSocket(const std::string& owner_extension_id, | 74 CastSocket(const std::string& owner_extension_id, |
75 const GURL& url, | 75 const GURL& url, |
76 CastSocket::Delegate* delegate, | 76 CastSocket::Delegate* delegate, |
77 net::NetLog* net_log); | 77 net::NetLog* net_log); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // It is fine to delete the CastSocket object in |callback|. | 119 // It is fine to delete the CastSocket object in |callback|. |
120 virtual void Close(const net::CompletionCallback& callback); | 120 virtual void Close(const net::CompletionCallback& callback); |
121 | 121 |
122 // Fills |channel_info| with the status of this channel. | 122 // Fills |channel_info| with the status of this channel. |
123 virtual void FillChannelInfo(ChannelInfo* channel_info) const; | 123 virtual void FillChannelInfo(ChannelInfo* channel_info) const; |
124 | 124 |
125 private: | 125 private: |
126 friend class ApiResourceManager<CastSocket>; | 126 friend class ApiResourceManager<CastSocket>; |
127 friend class CastSocketTest; | 127 friend class CastSocketTest; |
128 | 128 |
129 static const char* service_name() { | 129 static const char* service_name() { return "CastSocketManager"; } |
130 return "CastSocketManager"; | |
131 } | |
132 | 130 |
133 // Internal connection states. | 131 // Internal connection states. |
134 enum ConnectionState { | 132 enum ConnectionState { |
135 CONN_STATE_NONE, | 133 CONN_STATE_NONE, |
136 CONN_STATE_TCP_CONNECT, | 134 CONN_STATE_TCP_CONNECT, |
137 CONN_STATE_TCP_CONNECT_COMPLETE, | 135 CONN_STATE_TCP_CONNECT_COMPLETE, |
138 CONN_STATE_SSL_CONNECT, | 136 CONN_STATE_SSL_CONNECT, |
139 CONN_STATE_SSL_CONNECT_COMPLETE, | 137 CONN_STATE_SSL_CONNECT_COMPLETE, |
140 CONN_STATE_AUTH_CHALLENGE_SEND, | 138 CONN_STATE_AUTH_CHALLENGE_SEND, |
141 CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE, | 139 CONN_STATE_AUTH_CHALLENGE_SEND_COMPLETE, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); | 350 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); |
353 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestFullSecureConnectionFlowAsync); | 351 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestFullSecureConnectionFlowAsync); |
354 DISALLOW_COPY_AND_ASSIGN(CastSocket); | 352 DISALLOW_COPY_AND_ASSIGN(CastSocket); |
355 }; | 353 }; |
356 | 354 |
357 } // namespace cast_channel | 355 } // namespace cast_channel |
358 } // namespace api | 356 } // namespace api |
359 } // namespace extensions | 357 } // namespace extensions |
360 | 358 |
361 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ | 359 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ |
OLD | NEW |