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

Side by Side Diff: net/http/http_proxy_client_socket.h

Issue 3058013: Fix late binding induced mismatch of Socket and AuthController (Closed)
Patch Set: Address comments Created 10 years, 4 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 (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_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 17 matching lines...) Expand all
28 class HttpStream; 28 class HttpStream;
29 class IOBuffer;; 29 class IOBuffer;;
30 30
31 class HttpProxyClientSocket : public ClientSocket { 31 class HttpProxyClientSocket : public ClientSocket {
32 public: 32 public:
33 // Takes ownership of |transport_socket|, which should already be connected 33 // Takes ownership of |transport_socket|, which should already be connected
34 // by the time Connect() is called. If tunnel is true then on Connect() 34 // by the time Connect() is called. If tunnel is true then on Connect()
35 // this socket will establish an Http tunnel. 35 // this socket will establish an Http tunnel.
36 HttpProxyClientSocket(ClientSocketHandle* transport_socket, 36 HttpProxyClientSocket(ClientSocketHandle* transport_socket,
37 const GURL& request_url, const HostPortPair& endpoint, 37 const GURL& request_url, const HostPortPair& endpoint,
38 const scoped_refptr<HttpAuthController>& auth, 38 const HostPortPair& proxy_server,
39 const scoped_refptr<HttpNetworkSession>& session,
39 bool tunnel); 40 bool tunnel);
40 41
41 // On destruction Disconnect() is called. 42 // On destruction Disconnect() is called.
42 virtual ~HttpProxyClientSocket(); 43 virtual ~HttpProxyClientSocket();
43 44
44 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then 45 // If Connect (or its callback) returns PROXY_AUTH_REQUESTED, then
45 // credentials should be added to the HttpAuthController before calling 46 // credentials should be added to the HttpAuthController before calling
46 // RestartWithAuth. 47 // RestartWithAuth.
47 int RestartWithAuth(CompletionCallback* callback); 48 int RestartWithAuth(CompletionCallback* callback);
48 49
49 // Indicates if RestartWithAuth needs to be called. i.e. if Connect 50 const HttpResponseInfo* GetResponseInfo() const {
50 // returned PROXY_AUTH_REQUESTED. Only valid after Connect has been called. 51 return response_.headers ? &response_ : NULL;
51 bool NeedsRestartWithAuth() const; 52 }
52 53
53 const HttpResponseInfo* GetResponseInfo() const { 54 const scoped_refptr<HttpAuthController>& auth_controller() {
54 return response_.headers ? &response_ : NULL; 55 return auth_;
55 } 56 }
56 57
57 // ClientSocket methods: 58 // ClientSocket methods:
58 59
59 // Authenticates to the Http Proxy and then passes data freely. 60 // Authenticates to the Http Proxy and then passes data freely.
60 virtual int Connect(CompletionCallback* callback); 61 virtual int Connect(CompletionCallback* callback);
61 virtual void Disconnect(); 62 virtual void Disconnect();
62 virtual bool IsConnected() const; 63 virtual bool IsConnected() const;
63 virtual bool IsConnectedAndIdle() const; 64 virtual bool IsConnectedAndIdle() const;
64 virtual const BoundNetLog& NetLog() const { return net_log_; } 65 virtual const BoundNetLog& NetLog() const { return net_log_; }
(...skipping 13 matching lines...) Expand all
78 STATE_GENERATE_AUTH_TOKEN, 79 STATE_GENERATE_AUTH_TOKEN,
79 STATE_GENERATE_AUTH_TOKEN_COMPLETE, 80 STATE_GENERATE_AUTH_TOKEN_COMPLETE,
80 STATE_SEND_REQUEST, 81 STATE_SEND_REQUEST,
81 STATE_SEND_REQUEST_COMPLETE, 82 STATE_SEND_REQUEST_COMPLETE,
82 STATE_READ_HEADERS, 83 STATE_READ_HEADERS,
83 STATE_READ_HEADERS_COMPLETE, 84 STATE_READ_HEADERS_COMPLETE,
84 STATE_RESOLVE_CANONICAL_NAME, 85 STATE_RESOLVE_CANONICAL_NAME,
85 STATE_RESOLVE_CANONICAL_NAME_COMPLETE, 86 STATE_RESOLVE_CANONICAL_NAME_COMPLETE,
86 STATE_DRAIN_BODY, 87 STATE_DRAIN_BODY,
87 STATE_DRAIN_BODY_COMPLETE, 88 STATE_DRAIN_BODY_COMPLETE,
89 STATE_TCP_RESTART,
90 STATE_TCP_RESTART_COMPLETE,
88 STATE_DONE, 91 STATE_DONE,
89 }; 92 };
90 93
91 // The size in bytes of the buffer we use to drain the response body that 94 // The size in bytes of the buffer we use to drain the response body that
92 // we want to throw away. The response body is typically a small error 95 // we want to throw away. The response body is typically a small error
93 // page just a few hundred bytes long. 96 // page just a few hundred bytes long.
94 enum { kDrainBodyBufferSize = 1024 }; 97 enum { kDrainBodyBufferSize = 1024 };
95 98
96 int PrepareForAuthRestart(); 99 int PrepareForAuthRestart();
97 int DidDrainBodyForAuthRestart(bool keep_alive); 100 int DidDrainBodyForAuthRestart(bool keep_alive);
98 101
99 int HandleAuthChallenge(); 102 int HandleAuthChallenge();
100 103
101 void LogBlockedTunnelResponse(int response_code) const; 104 void LogBlockedTunnelResponse(int response_code) const;
102 105
103 void DoCallback(int result); 106 void DoCallback(int result);
104 void OnIOComplete(int result); 107 void OnIOComplete(int result);
105 108
106 int DoLoop(int last_io_result); 109 int DoLoop(int last_io_result);
107 int DoGenerateAuthToken(); 110 int DoGenerateAuthToken();
108 int DoGenerateAuthTokenComplete(int result); 111 int DoGenerateAuthTokenComplete(int result);
109 int DoSendRequest(); 112 int DoSendRequest();
110 int DoSendRequestComplete(int result); 113 int DoSendRequestComplete(int result);
111 int DoReadHeaders(); 114 int DoReadHeaders();
112 int DoReadHeadersComplete(int result); 115 int DoReadHeadersComplete(int result);
113 int DoDrainBody(); 116 int DoDrainBody();
114 int DoDrainBodyComplete(int result); 117 int DoDrainBodyComplete(int result);
118 int DoTCPRestart();
119 int DoTCPRestartComplete(int result);
115 120
116 CompletionCallbackImpl<HttpProxyClientSocket> io_callback_; 121 CompletionCallbackImpl<HttpProxyClientSocket> io_callback_;
117 State next_state_; 122 State next_state_;
118 123
119 // Stores the callback to the layer above, called on completing Connect(). 124 // Stores the callback to the layer above, called on completing Connect().
120 CompletionCallback* user_callback_; 125 CompletionCallback* user_callback_;
121 126
122 HttpRequestInfo request_; 127 HttpRequestInfo request_;
123 HttpResponseInfo response_; 128 HttpResponseInfo response_;
124 129
(...skipping 12 matching lines...) Expand all
137 std::string request_headers_; 142 std::string request_headers_;
138 143
139 const BoundNetLog net_log_; 144 const BoundNetLog net_log_;
140 145
141 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket); 146 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocket);
142 }; 147 };
143 148
144 } // namespace net 149 } // namespace net
145 150
146 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_ 151 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698