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

Side by Side Diff: net/proxy/proxy_script_fetcher.cc

Issue 160510: Better match IE's proxy settings.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix merge conflict Created 11 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_script_fetcher.h ('k') | net/proxy/proxy_script_fetcher_unittest.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) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/proxy/proxy_script_fetcher.h" 5 #include "net/proxy/proxy_script_fetcher.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 public: 50 public:
51 // Creates a ProxyScriptFetcher that issues requests through 51 // Creates a ProxyScriptFetcher that issues requests through
52 // |url_request_context|. |url_request_context| must remain valid for the 52 // |url_request_context|. |url_request_context| must remain valid for the
53 // lifetime of ProxyScriptFetcherImpl. 53 // lifetime of ProxyScriptFetcherImpl.
54 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context); 54 explicit ProxyScriptFetcherImpl(URLRequestContext* url_request_context);
55 55
56 virtual ~ProxyScriptFetcherImpl(); 56 virtual ~ProxyScriptFetcherImpl();
57 57
58 // ProxyScriptFetcher methods: 58 // ProxyScriptFetcher methods:
59 59
60 virtual void Fetch(const GURL& url, std::string* bytes, 60 virtual int Fetch(const GURL& url, std::string* bytes,
61 CompletionCallback* callback); 61 CompletionCallback* callback);
62 virtual void Cancel(); 62 virtual void Cancel();
63 63
64 // URLRequest::Delegate methods: 64 // URLRequest::Delegate methods:
65 65
66 virtual void OnAuthRequired(URLRequest* request, 66 virtual void OnAuthRequired(URLRequest* request,
67 AuthChallengeInfo* auth_info); 67 AuthChallengeInfo* auth_info);
68 virtual void OnSSLCertificateError(URLRequest* request, int cert_error, 68 virtual void OnSSLCertificateError(URLRequest* request, int cert_error,
69 X509Certificate* cert); 69 X509Certificate* cert);
70 virtual void OnResponseStarted(URLRequest* request); 70 virtual void OnResponseStarted(URLRequest* request);
71 virtual void OnReadCompleted(URLRequest* request, int num_bytes); 71 virtual void OnReadCompleted(URLRequest* request, int num_bytes);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 result_code_(OK), 130 result_code_(OK),
131 result_bytes_(NULL) { 131 result_bytes_(NULL) {
132 DCHECK(url_request_context); 132 DCHECK(url_request_context);
133 } 133 }
134 134
135 ProxyScriptFetcherImpl::~ProxyScriptFetcherImpl() { 135 ProxyScriptFetcherImpl::~ProxyScriptFetcherImpl() {
136 // The URLRequest's destructor will cancel the outstanding request, and 136 // The URLRequest's destructor will cancel the outstanding request, and
137 // ensure that the delegate (this) is not called again. 137 // ensure that the delegate (this) is not called again.
138 } 138 }
139 139
140 void ProxyScriptFetcherImpl::Fetch(const GURL& url, 140 int ProxyScriptFetcherImpl::Fetch(const GURL& url,
141 std::string* bytes, 141 std::string* bytes,
142 CompletionCallback* callback) { 142 CompletionCallback* callback) {
143 // It is invalid to call Fetch() while a request is already in progress. 143 // It is invalid to call Fetch() while a request is already in progress.
144 DCHECK(!cur_request_.get()); 144 DCHECK(!cur_request_.get());
145 145
146 DCHECK(callback); 146 DCHECK(callback);
147 DCHECK(bytes); 147 DCHECK(bytes);
148 148
149 cur_request_.reset(new URLRequest(url, this)); 149 cur_request_.reset(new URLRequest(url, this));
150 cur_request_->set_context(url_request_context_); 150 cur_request_->set_context(url_request_context_);
151 cur_request_->set_method("GET"); 151 cur_request_->set_method("GET");
152 152
(...skipping 11 matching lines...) Expand all
164 164
165 // Post a task to timeout this request if it takes too long. 165 // Post a task to timeout this request if it takes too long.
166 cur_request_id_ = ++next_id_; 166 cur_request_id_ = ++next_id_;
167 MessageLoop::current()->PostDelayedTask(FROM_HERE, 167 MessageLoop::current()->PostDelayedTask(FROM_HERE,
168 task_factory_.NewRunnableMethod(&ProxyScriptFetcherImpl::OnTimeout, 168 task_factory_.NewRunnableMethod(&ProxyScriptFetcherImpl::OnTimeout,
169 cur_request_id_), 169 cur_request_id_),
170 static_cast<int>(max_duration_ms)); 170 static_cast<int>(max_duration_ms));
171 171
172 // Start the request. 172 // Start the request.
173 cur_request_->Start(); 173 cur_request_->Start();
174 return ERR_IO_PENDING;
174 } 175 }
175 176
176 void ProxyScriptFetcherImpl::Cancel() { 177 void ProxyScriptFetcherImpl::Cancel() {
177 // ResetCurRequestState will free the URLRequest, which will cause 178 // ResetCurRequestState will free the URLRequest, which will cause
178 // cancellation. 179 // cancellation.
179 ResetCurRequestState(); 180 ResetCurRequestState();
180 } 181 }
181 182
182 void ProxyScriptFetcherImpl::OnAuthRequired(URLRequest* request, 183 void ProxyScriptFetcherImpl::OnAuthRequired(URLRequest* request,
183 AuthChallengeInfo* auth_info) { 184 AuthChallengeInfo* auth_info) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 319 }
319 320
320 // static 321 // static
321 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) { 322 size_t ProxyScriptFetcher::SetSizeConstraintForUnittest(size_t size_bytes) {
322 size_t prev = max_response_bytes; 323 size_t prev = max_response_bytes;
323 max_response_bytes = size_bytes; 324 max_response_bytes = size_bytes;
324 return prev; 325 return prev;
325 } 326 }
326 327
327 } // namespace net 328 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher.h ('k') | net/proxy/proxy_script_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698