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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return old_https_factory_(request, network_delegate, scheme); 166 return old_https_factory_(request, network_delegate, scheme);
167 } 167 }
168 return NULL; 168 return NULL;
169 } 169 }
170 170
171 // net::URLRequestJob Implementation. 171 // net::URLRequestJob Implementation.
172 void URLRequestAutomationJob::Start() { 172 void URLRequestAutomationJob::Start() {
173 if (!is_pending()) { 173 if (!is_pending()) {
174 // Start reading asynchronously so that all error reporting and data 174 // Start reading asynchronously so that all error reporting and data
175 // callbacks happen as they would for network requests. 175 // callbacks happen as they would for network requests.
176 MessageLoop::current()->PostTask( 176 base::MessageLoop::current()->PostTask(
177 FROM_HERE, 177 FROM_HERE,
178 base::Bind(&URLRequestAutomationJob::StartAsync, 178 base::Bind(&URLRequestAutomationJob::StartAsync,
179 weak_factory_.GetWeakPtr())); 179 weak_factory_.GetWeakPtr()));
180 } else { 180 } else {
181 // If this is a pending job, then register it immediately with the message 181 // If this is a pending job, then register it immediately with the message
182 // filter so it can be serviced later when we receive a request from the 182 // filter so it can be serviced later when we receive a request from the
183 // external host to connect to the corresponding external tab. 183 // external host to connect to the corresponding external tab.
184 message_filter_->RegisterRequest(this); 184 message_filter_->RegisterRequest(this);
185 } 185 }
186 } 186 }
(...skipping 18 matching lines...) Expand all
205 // We should not receive a read request for a pending job. 205 // We should not receive a read request for a pending job.
206 DCHECK(!is_pending()); 206 DCHECK(!is_pending());
207 207
208 pending_buf_ = buf; 208 pending_buf_ = buf;
209 pending_buf_size_ = buf_size; 209 pending_buf_size_ = buf_size;
210 210
211 if (message_filter_) { 211 if (message_filter_) {
212 message_filter_->Send(new AutomationMsg_RequestRead(tab_, id_, buf_size)); 212 message_filter_->Send(new AutomationMsg_RequestRead(tab_, id_, buf_size));
213 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); 213 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
214 } else { 214 } else {
215 MessageLoop::current()->PostTask( 215 base::MessageLoop::current()->PostTask(
216 FROM_HERE, 216 FROM_HERE,
217 base::Bind(&URLRequestAutomationJob::NotifyJobCompletionTask, 217 base::Bind(&URLRequestAutomationJob::NotifyJobCompletionTask,
218 weak_factory_.GetWeakPtr())); 218 weak_factory_.GetWeakPtr()));
219 } 219 }
220 return false; 220 return false;
221 } 221 }
222 222
223 bool URLRequestAutomationJob::GetMimeType(std::string* mime_type) const { 223 bool URLRequestAutomationJob::GetMimeType(std::string* mime_type) const {
224 if (!mime_type_.empty()) { 224 if (!mime_type_.empty()) {
225 *mime_type = mime_type_; 225 *mime_type = mime_type_;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!is_done()) { 532 if (!is_done()) {
533 NotifyDone(request_status_); 533 NotifyDone(request_status_);
534 } 534 }
535 // Reset any pending reads. 535 // Reset any pending reads.
536 if (pending_buf_) { 536 if (pending_buf_) {
537 pending_buf_ = NULL; 537 pending_buf_ = NULL;
538 pending_buf_size_ = 0; 538 pending_buf_size_ = 0;
539 NotifyReadComplete(0); 539 NotifyReadComplete(0);
540 } 540 }
541 } 541 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/background/background_contents_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698