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

Side by Side Diff: chrome/browser/automation/url_request_automation_job.cc

Issue 10825073: Stop using ScopedAllowIO in content::ResourceDispatcherHostImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Chrome Frame fix Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/automation/url_request_automation_job.h" 5 #include "chrome/browser/automation/url_request_automation_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 AutomationResourceMessageFilter* filter, 57 AutomationResourceMessageFilter* filter,
58 bool is_pending) 58 bool is_pending)
59 : net::URLRequestJob(request, request->context()->network_delegate()), 59 : net::URLRequestJob(request, request->context()->network_delegate()),
60 id_(0), 60 id_(0),
61 tab_(tab), 61 tab_(tab),
62 message_filter_(filter), 62 message_filter_(filter),
63 pending_buf_size_(0), 63 pending_buf_size_(0),
64 redirect_status_(0), 64 redirect_status_(0),
65 request_id_(request_id), 65 request_id_(request_id),
66 is_pending_(is_pending), 66 is_pending_(is_pending),
67 upload_size_(0),
67 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 68 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
68 DVLOG(1) << "URLRequestAutomationJob create. Count: " << ++instance_count_; 69 DVLOG(1) << "URLRequestAutomationJob create. Count: " << ++instance_count_;
69 DCHECK(message_filter_ != NULL); 70 DCHECK(message_filter_ != NULL);
70 71
71 if (message_filter_) { 72 if (message_filter_) {
72 id_ = message_filter_->NewAutomationRequestId(); 73 id_ = message_filter_->NewAutomationRequestId();
73 DCHECK_NE(id_, 0); 74 DCHECK_NE(id_, 0);
74 } 75 }
75 } 76 }
76 77
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 *http_status_code = redirect_status_; 228 *http_status_code = redirect_status_;
228 *location = GURL(redirect_url_); 229 *location = GURL(redirect_url_);
229 return true; 230 return true;
230 } 231 }
231 232
232 uint64 URLRequestAutomationJob::GetUploadProgress() const { 233 uint64 URLRequestAutomationJob::GetUploadProgress() const {
233 if (request_ && request_->status().is_success()) { 234 if (request_ && request_->status().is_success()) {
234 // We don't support incremental progress notifications in ChromeFrame. When 235 // We don't support incremental progress notifications in ChromeFrame. When
235 // we receive a response for the POST request from Chromeframe, it means 236 // we receive a response for the POST request from Chromeframe, it means
236 // that the upload is fully complete. 237 // that the upload is fully complete.
237 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); 238 return upload_size_;
238 if (info) {
239 return info->GetUploadSize();
240 }
241 } 239 }
242 return 0; 240 return 0;
243 } 241 }
244 242
245 net::HostPortPair URLRequestAutomationJob::GetSocketAddress() const { 243 net::HostPortPair URLRequestAutomationJob::GetSocketAddress() const {
246 return socket_address_; 244 return socket_address_;
247 } 245 }
248 246
249 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, 247 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message,
250 int* request_id) { 248 int* request_id) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 redirect_status_ = response.redirect_status; 293 redirect_status_ = response.redirect_status;
296 DCHECK(redirect_status_ == 0 || redirect_status_ == 200 || 294 DCHECK(redirect_status_ == 0 || redirect_status_ == 200 ||
297 (redirect_status_ >= 300 && redirect_status_ < 400)); 295 (redirect_status_ >= 300 && redirect_status_ < 400));
298 296
299 if (!response.headers.empty()) { 297 if (!response.headers.empty()) {
300 headers_ = new net::HttpResponseHeaders( 298 headers_ = new net::HttpResponseHeaders(
301 net::HttpUtil::AssembleRawHeaders(response.headers.data(), 299 net::HttpUtil::AssembleRawHeaders(response.headers.data(),
302 response.headers.size())); 300 response.headers.size()));
303 } 301 }
304 socket_address_ = response.socket_address; 302 socket_address_ = response.socket_address;
303 upload_size_ = response.upload_size;
304 // Notify upload size to delegate.
305 request_->NotifyRequestBodyInitialized(upload_size_);
306
305 NotifyHeadersComplete(); 307 NotifyHeadersComplete();
306 } 308 }
307 309
308 void URLRequestAutomationJob::OnDataAvailable( 310 void URLRequestAutomationJob::OnDataAvailable(
309 int id, const std::string& bytes) { 311 int id, const std::string& bytes) {
310 DVLOG(1) << "URLRequestAutomationJob: " << request_->url().spec() 312 DVLOG(1) << "URLRequestAutomationJob: " << request_->url().spec()
311 << " - data available, Size: " << bytes.size(); 313 << " - data available, Size: " << bytes.size();
312 DCHECK(!bytes.empty()); 314 DCHECK(!bytes.empty());
313 315
314 // The request completed, and we have all the data. 316 // The request completed, and we have all the data.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (!is_done()) { 489 if (!is_done()) {
488 NotifyDone(request_status_); 490 NotifyDone(request_status_);
489 } 491 }
490 // Reset any pending reads. 492 // Reset any pending reads.
491 if (pending_buf_) { 493 if (pending_buf_) {
492 pending_buf_ = NULL; 494 pending_buf_ = NULL;
493 pending_buf_size_ = 0; 495 pending_buf_size_ = 0;
494 NotifyReadComplete(0); 496 NotifyReadComplete(0);
495 } 497 }
496 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698