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" | 17 #include "chrome/browser/extensions/api/api_resource.h" |
18 #include "chrome/browser/extensions/api/api_resource_manager.h" | 18 #include "chrome/browser/extensions/api/api_resource_manager.h" |
19 #include "chrome/browser/extensions/api/cast_channel/cast_channel.pb.h" | |
Wez
2014/02/12 21:13:16
How did this make the build flaky? Something inclu
mark a. foltz
2014/02/12 21:45:02
The files generated from the IDL included the .pb.
Munjal (Google)
2014/02/12 22:34:36
It is complicated and hence took me a while to fig
| |
20 #include "chrome/common/extensions/api/cast_channel.h" | 19 #include "chrome/common/extensions/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 #include "url/gurl.h" | 24 #include "url/gurl.h" |
26 | 25 |
27 namespace net { | 26 namespace net { |
28 class AddressList; | 27 class AddressList; |
29 class CertVerifier; | 28 class CertVerifier; |
30 class SSLClientSocket; | 29 class SSLClientSocket; |
31 class StreamSocket; | 30 class StreamSocket; |
32 class TCPClientSocket; | 31 class TCPClientSocket; |
33 class TransportSecurityState; | 32 class TransportSecurityState; |
34 } | 33 } |
35 | 34 |
36 namespace extensions { | 35 namespace extensions { |
37 namespace api { | 36 namespace api { |
38 namespace cast_channel { | 37 namespace cast_channel { |
39 | 38 |
39 class CastMessage; | |
40 | |
40 // Size (in bytes) of the largest allowed message payload on the wire (without | 41 // Size (in bytes) of the largest allowed message payload on the wire (without |
41 // the header). | 42 // the header). |
42 extern const uint32 kMaxMessageSize; | 43 extern const uint32 kMaxMessageSize; |
43 | 44 |
44 // Size (in bytes) of the message header. | 45 // Size (in bytes) of the message header. |
45 extern const uint32 kMessageHeaderSize; | 46 extern const uint32 kMessageHeaderSize; |
46 | 47 |
47 // This class implements a channel between Chrome and a Cast device using a TCP | 48 // This class implements a channel between Chrome and a Cast device using a TCP |
48 // socket. The channel may be unauthenticated (cast://) or authenticated | 49 // socket. The channel may be unauthenticated (cast://) or authenticated |
49 // (casts://). All CastSocket objects must be used only on the IO thread. | 50 // (casts://). All CastSocket objects must be used only on the IO thread. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 | 255 |
255 virtual bool CalledOnValidThread() const; | 256 virtual bool CalledOnValidThread() const; |
256 | 257 |
257 base::ThreadChecker thread_checker_; | 258 base::ThreadChecker thread_checker_; |
258 | 259 |
259 // The id of the channel. | 260 // The id of the channel. |
260 int channel_id_; | 261 int channel_id_; |
261 | 262 |
262 // The URL of the peer (cast:// or casts://). | 263 // The URL of the peer (cast:// or casts://). |
263 GURL url_; | 264 GURL url_; |
265 // String used in log messages for url. | |
Wez
2014/02/12 21:13:16
Suggest renaming this to |log_prefix_| - you could
Munjal (Google)
2014/02/12 22:34:36
Done.
Munjal (Google)
2014/02/12 22:34:36
Done.
| |
266 std::string url_log_str_; | |
264 // Delegate to inform of incoming messages and errors. | 267 // Delegate to inform of incoming messages and errors. |
265 Delegate* delegate_; | 268 Delegate* delegate_; |
266 // True if receiver authentication should be performed. | 269 // True if receiver authentication should be performed. |
267 bool auth_required_; | 270 bool auth_required_; |
268 // The IP endpoint of the peer. | 271 // The IP endpoint of the peer. |
269 net::IPEndPoint ip_endpoint_; | 272 net::IPEndPoint ip_endpoint_; |
270 | 273 |
271 // IOBuffer for reading the message header. | 274 // IOBuffer for reading the message header. |
272 scoped_refptr<net::GrowableIOBuffer> header_read_buffer_; | 275 scoped_refptr<net::GrowableIOBuffer> header_read_buffer_; |
273 // IOBuffer for reading the message body. | 276 // IOBuffer for reading the message body. |
274 scoped_refptr<net::GrowableIOBuffer> body_read_buffer_; | 277 scoped_refptr<net::GrowableIOBuffer> body_read_buffer_; |
275 // IOBuffer to currently read into. | 278 // IOBuffer to currently read into. |
276 scoped_refptr<net::GrowableIOBuffer> current_read_buffer_; | 279 scoped_refptr<net::GrowableIOBuffer> current_read_buffer_; |
277 // The number of bytes in the current message body. | 280 // The number of bytes in the current message body. |
278 uint32 current_message_size_; | 281 uint32 current_message_size_; |
279 // Last message received on the socket. | 282 // Last message received on the socket. |
280 CastMessage current_message_; | 283 scoped_ptr<CastMessage> current_message_; |
281 | 284 |
282 // The NetLog for this service. | 285 // The NetLog for this service. |
283 net::NetLog* net_log_; | 286 net::NetLog* net_log_; |
284 // The NetLog source for this service. | 287 // The NetLog source for this service. |
285 net::NetLog::Source net_log_source_; | 288 net::NetLog::Source net_log_source_; |
286 | 289 |
287 // CertVerifier is owned by us but should be deleted AFTER SSLClientSocket | 290 // CertVerifier is owned by us but should be deleted AFTER SSLClientSocket |
288 // since in some cases the destructor of SSLClientSocket may call a method | 291 // since in some cases the destructor of SSLClientSocket may call a method |
289 // to cancel a cert verification request. | 292 // to cancel a cert verification request. |
290 scoped_ptr<net::CertVerifier> cert_verifier_; | 293 scoped_ptr<net::CertVerifier> cert_verifier_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); | 354 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestReadMany); |
352 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestFullSecureConnectionFlowAsync); | 355 FRIEND_TEST_ALL_PREFIXES(CastSocketTest, TestFullSecureConnectionFlowAsync); |
353 DISALLOW_COPY_AND_ASSIGN(CastSocket); | 356 DISALLOW_COPY_AND_ASSIGN(CastSocket); |
354 }; | 357 }; |
355 | 358 |
356 } // namespace cast_channel | 359 } // namespace cast_channel |
357 } // namespace api | 360 } // namespace api |
358 } // namespace extensions | 361 } // namespace extensions |
359 | 362 |
360 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ | 363 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_SOCKET_H_ |
OLD | NEW |