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

Side by Side Diff: net/socket_stream/socket_stream.h

Issue 669157: Refactor WebSocket throttling feature. (Closed)
Patch Set: Fix for tyoshino's comment Created 10 years, 9 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
« no previous file with comments | « net/net.gyp ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 NET_SOCKET_STREAM_SOCKET_STREAM_H_ 5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_H_
6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_ 6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/linked_ptr.h" 13 #include "base/linked_ptr.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 #include "net/base/address_list.h" 17 #include "net/base/address_list.h"
18 #include "net/base/completion_callback.h" 18 #include "net/base/completion_callback.h"
19 #include "net/base/io_buffer.h" 19 #include "net/base/io_buffer.h"
20 #include "net/base/net_log.h" 20 #include "net/base/net_log.h"
21 #include "net/base/net_errors.h"
21 #include "net/http/http_auth.h" 22 #include "net/http/http_auth.h"
22 #include "net/http/http_auth_cache.h" 23 #include "net/http/http_auth_cache.h"
23 #include "net/http/http_auth_handler.h" 24 #include "net/http/http_auth_handler.h"
24 #include "net/proxy/proxy_service.h" 25 #include "net/proxy/proxy_service.h"
25 #include "net/socket/tcp_client_socket.h" 26 #include "net/socket/tcp_client_socket.h"
26 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
27 28
28 namespace net { 29 namespace net {
29 30
30 class AuthChallengeInfo; 31 class AuthChallengeInfo;
31 class ClientSocketFactory; 32 class ClientSocketFactory;
32 class HostResolver; 33 class HostResolver;
33 class HttpAuthHandlerFactory; 34 class HttpAuthHandlerFactory;
34 class SSLConfigService; 35 class SSLConfigService;
35 class SingleRequestHostResolver; 36 class SingleRequestHostResolver;
36 class SocketStreamMetrics; 37 class SocketStreamMetrics;
37 class SocketStreamThrottle;
38 38
39 // SocketStream is used to implement Web Sockets. 39 // SocketStream is used to implement Web Sockets.
40 // It provides plain full-duplex stream with proxy and SSL support. 40 // It provides plain full-duplex stream with proxy and SSL support.
41 // For proxy authentication, only basic mechanisum is supported. It will try 41 // For proxy authentication, only basic mechanisum is supported. It will try
42 // authentication identity for proxy URL first. If server requires proxy 42 // authentication identity for proxy URL first. If server requires proxy
43 // authentication, it will try authentication identity for realm that server 43 // authentication, it will try authentication identity for realm that server
44 // requests. 44 // requests.
45 class SocketStream : public base::RefCountedThreadSafe<SocketStream> { 45 class SocketStream : public base::RefCountedThreadSafe<SocketStream> {
46 public: 46 public:
47 // Derive from this class and add your own data members to associate extra 47 // Derive from this class and add your own data members to associate extra
48 // information with a SocketStream. Use GetUserData(key) and 48 // information with a SocketStream. Use GetUserData(key) and
49 // SetUserData(key, data). 49 // SetUserData(key, data).
50 class UserData { 50 class UserData {
51 public: 51 public:
52 UserData() {} 52 UserData() {}
53 virtual ~UserData() {} 53 virtual ~UserData() {}
54 }; 54 };
55 55
56 class Delegate { 56 class Delegate {
57 public: 57 public:
58 virtual ~Delegate() {} 58 virtual ~Delegate() {}
59 59
60 virtual int OnStartOpenConnection(SocketStream* socket,
61 CompletionCallback* callback) {
62 return OK;
63 }
64
60 // Called when socket stream has been connected. The socket stream accepts 65 // Called when socket stream has been connected. The socket stream accepts
61 // at most |max_pending_send_allowed| so that a client of the socket stream 66 // at most |max_pending_send_allowed| so that a client of the socket stream
62 // should keep track of how much it has pending and shouldn't go over 67 // should keep track of how much it has pending and shouldn't go over
63 // |max_pending_send_allowed| bytes. 68 // |max_pending_send_allowed| bytes.
64 virtual void OnConnected(SocketStream* socket, 69 virtual void OnConnected(SocketStream* socket,
65 int max_pending_send_allowed) = 0; 70 int max_pending_send_allowed) = 0;
66 71
67 // Called when |amount_sent| bytes of data are sent. 72 // Called when |amount_sent| bytes of data are sent.
68 virtual void OnSentData(SocketStream* socket, 73 virtual void OnSentData(SocketStream* socket,
69 int amount_sent) = 0; 74 int amount_sent) = 0;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // |max_pending_send_allowed_|. 311 // |max_pending_send_allowed_|.
307 // |write_buf_| holds requested data and |current_write_buf_| is used 312 // |write_buf_| holds requested data and |current_write_buf_| is used
308 // for Write operation, that is, |current_write_buf_| is 313 // for Write operation, that is, |current_write_buf_| is
309 // |write_buf_| + |write_buf_offset_|. 314 // |write_buf_| + |write_buf_offset_|.
310 scoped_refptr<IOBuffer> write_buf_; 315 scoped_refptr<IOBuffer> write_buf_;
311 scoped_refptr<DrainableIOBuffer> current_write_buf_; 316 scoped_refptr<DrainableIOBuffer> current_write_buf_;
312 int write_buf_offset_; 317 int write_buf_offset_;
313 int write_buf_size_; 318 int write_buf_size_;
314 PendingDataQueue pending_write_bufs_; 319 PendingDataQueue pending_write_bufs_;
315 320
316 SocketStreamThrottle* throttle_;
317
318 scoped_ptr<SocketStreamMetrics> metrics_; 321 scoped_ptr<SocketStreamMetrics> metrics_;
319 322
320 DISALLOW_COPY_AND_ASSIGN(SocketStream); 323 DISALLOW_COPY_AND_ASSIGN(SocketStream);
321 }; 324 };
322 325
323 } // namespace net 326 } // namespace net
324 327
325 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ 328 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698