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

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

Issue 6338002: net: Remove typedef net::URLRequestContext URLRequestContext; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for real Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "net/proxy/proxy_script_fetcher_impl.h" 5 #include "net/proxy/proxy_script_fetcher_impl.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // outside of |charset| (i.e. invalid), then substitute them with 63 // outside of |charset| (i.e. invalid), then substitute them with
64 // U+FFFD rather than failing. 64 // U+FFFD rather than failing.
65 base::CodepageToUTF16(bytes, codepage, 65 base::CodepageToUTF16(bytes, codepage,
66 base::OnStringConversionError::SUBSTITUTE, 66 base::OnStringConversionError::SUBSTITUTE,
67 utf16); 67 utf16);
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( 72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl(
73 URLRequestContext* url_request_context) 73 net::URLRequestContext* url_request_context)
wtc 2011/01/15 17:54:23 Undo the changes to this file (already in the 'net
74 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), 74 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
75 url_request_context_(url_request_context), 75 url_request_context_(url_request_context),
76 buf_(new net::IOBuffer(kBufSize)), 76 buf_(new net::IOBuffer(kBufSize)),
77 next_id_(0), 77 next_id_(0),
78 cur_request_(NULL), 78 cur_request_(NULL),
79 cur_request_id_(0), 79 cur_request_id_(0),
80 callback_(NULL), 80 callback_(NULL),
81 result_code_(OK), 81 result_code_(OK),
82 result_text_(NULL), 82 result_text_(NULL),
83 max_response_bytes_(kDefaultMaxResponseBytes), 83 max_response_bytes_(kDefaultMaxResponseBytes),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 cur_request_->Start(); 127 cur_request_->Start();
128 return ERR_IO_PENDING; 128 return ERR_IO_PENDING;
129 } 129 }
130 130
131 void ProxyScriptFetcherImpl::Cancel() { 131 void ProxyScriptFetcherImpl::Cancel() {
132 // ResetCurRequestState will free the net::URLRequest, which will cause 132 // ResetCurRequestState will free the net::URLRequest, which will cause
133 // cancellation. 133 // cancellation.
134 ResetCurRequestState(); 134 ResetCurRequestState();
135 } 135 }
136 136
137 URLRequestContext* ProxyScriptFetcherImpl::GetRequestContext() { 137 net::URLRequestContext* ProxyScriptFetcherImpl::GetRequestContext() {
138 return url_request_context_; 138 return url_request_context_;
139 } 139 }
140 140
141 void ProxyScriptFetcherImpl::OnAuthRequired(net::URLRequest* request, 141 void ProxyScriptFetcherImpl::OnAuthRequired(net::URLRequest* request,
142 AuthChallengeInfo* auth_info) { 142 AuthChallengeInfo* auth_info) {
143 DCHECK_EQ(request, cur_request_.get()); 143 DCHECK_EQ(request, cur_request_.get());
144 // TODO(eroman): 144 // TODO(eroman):
145 LOG(WARNING) << "Auth required to fetch PAC script, aborting."; 145 LOG(WARNING) << "Auth required to fetch PAC script, aborting.";
146 result_code_ = ERR_NOT_IMPLEMENTED; 146 result_code_ = ERR_NOT_IMPLEMENTED;
147 request->CancelAuth(); 147 request->CancelAuth();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 cur_request_->GetCharset(&charset); 253 cur_request_->GetCharset(&charset);
254 ConvertResponseToUTF16(charset, bytes_read_so_far_, result_text_); 254 ConvertResponseToUTF16(charset, bytes_read_so_far_, result_text_);
255 } else { 255 } else {
256 // On error, the caller expects empty string for bytes. 256 // On error, the caller expects empty string for bytes.
257 result_text_->clear(); 257 result_text_->clear();
258 } 258 }
259 259
260 int result_code = result_code_; 260 int result_code = result_code_;
261 CompletionCallback* callback = callback_; 261 CompletionCallback* callback = callback_;
262 262
263 // Hold a reference to the URLRequestContext to prevent re-entrancy from 263 // Hold a reference to the net::URLRequestContext to prevent re-entrancy from
264 // ~URLRequestContext. 264 // ~net::URLRequestContext.
265 scoped_refptr<URLRequestContext> context(cur_request_->context()); 265 scoped_refptr<net::URLRequestContext> context(cur_request_->context());
266 ResetCurRequestState(); 266 ResetCurRequestState();
267 267
268 callback->Run(result_code); 268 callback->Run(result_code);
269 } 269 }
270 270
271 void ProxyScriptFetcherImpl::ResetCurRequestState() { 271 void ProxyScriptFetcherImpl::ResetCurRequestState() {
272 cur_request_.reset(); 272 cur_request_.reset();
273 cur_request_id_ = 0; 273 cur_request_id_ = 0;
274 callback_ = NULL; 274 callback_ = NULL;
275 result_code_ = OK; 275 result_code_ = OK;
(...skipping 18 matching lines...) Expand all
294 return prev; 294 return prev;
295 } 295 }
296 296
297 size_t ProxyScriptFetcherImpl::SetSizeConstraint(size_t size_bytes) { 297 size_t ProxyScriptFetcherImpl::SetSizeConstraint(size_t size_bytes) {
298 size_t prev = max_response_bytes_; 298 size_t prev = max_response_bytes_;
299 max_response_bytes_ = size_bytes; 299 max_response_bytes_ = size_bytes;
300 return prev; 300 return prev;
301 } 301 }
302 302
303 } // namespace net 303 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698