| OLD | NEW |
| 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 #include "chrome/browser/automation/url_request_automation_job.h" | 5 #include "chrome/browser/automation/url_request_automation_job.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "chrome/browser/automation/automation_resource_message_filter.h" | 9 #include "chrome/browser/automation/automation_resource_message_filter.h" |
| 10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DCHECK_NE(id_, 0); | 62 DCHECK_NE(id_, 0); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 URLRequestAutomationJob::~URLRequestAutomationJob() { | 66 URLRequestAutomationJob::~URLRequestAutomationJob() { |
| 67 DLOG(INFO) << "URLRequestAutomationJob delete. Count: " << --instance_count_; | 67 DLOG(INFO) << "URLRequestAutomationJob delete. Count: " << --instance_count_; |
| 68 Cleanup(); | 68 Cleanup(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool URLRequestAutomationJob::EnsureProtocolFactoryRegistered() { | 71 bool URLRequestAutomationJob::EnsureProtocolFactoryRegistered() { |
| 72 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 73 | 73 |
| 74 if (!is_protocol_factory_registered_) { | 74 if (!is_protocol_factory_registered_) { |
| 75 old_http_factory_ = | 75 old_http_factory_ = |
| 76 URLRequest::RegisterProtocolFactory("http", | 76 URLRequest::RegisterProtocolFactory("http", |
| 77 &URLRequestAutomationJob::Factory); | 77 &URLRequestAutomationJob::Factory); |
| 78 old_https_factory_ = | 78 old_https_factory_ = |
| 79 URLRequest::RegisterProtocolFactory("https", | 79 URLRequest::RegisterProtocolFactory("https", |
| 80 &URLRequestAutomationJob::Factory); | 80 &URLRequestAutomationJob::Factory); |
| 81 is_protocol_factory_registered_ = true; | 81 is_protocol_factory_registered_ = true; |
| 82 } | 82 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 DCHECK(!is_pending()); | 155 DCHECK(!is_pending()); |
| 156 | 156 |
| 157 pending_buf_ = buf; | 157 pending_buf_ = buf; |
| 158 pending_buf_size_ = buf_size; | 158 pending_buf_size_ = buf_size; |
| 159 | 159 |
| 160 if (message_filter_) { | 160 if (message_filter_) { |
| 161 message_filter_->Send(new AutomationMsg_RequestRead(0, tab_, id_, | 161 message_filter_->Send(new AutomationMsg_RequestRead(0, tab_, id_, |
| 162 buf_size)); | 162 buf_size)); |
| 163 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 163 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
| 164 } else { | 164 } else { |
| 165 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, | 165 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 166 NewRunnableMethod(this, | 166 NewRunnableMethod(this, |
| 167 &URLRequestAutomationJob::NotifyJobCompletionTask)); | 167 &URLRequestAutomationJob::NotifyJobCompletionTask)); |
| 168 } | 168 } |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool URLRequestAutomationJob::GetMimeType(std::string* mime_type) const { | 172 bool URLRequestAutomationJob::GetMimeType(std::string* mime_type) const { |
| 173 if (!mime_type_.empty()) { | 173 if (!mime_type_.empty()) { |
| 174 *mime_type = mime_type_; | 174 *mime_type = mime_type_; |
| 175 } else if (headers_) { | 175 } else if (headers_) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if (!is_done()) { | 460 if (!is_done()) { |
| 461 NotifyDone(request_status_); | 461 NotifyDone(request_status_); |
| 462 } | 462 } |
| 463 // Reset any pending reads. | 463 // Reset any pending reads. |
| 464 if (pending_buf_) { | 464 if (pending_buf_) { |
| 465 pending_buf_ = NULL; | 465 pending_buf_ = NULL; |
| 466 pending_buf_size_ = 0; | 466 pending_buf_size_ = 0; |
| 467 NotifyReadComplete(0); | 467 NotifyReadComplete(0); |
| 468 } | 468 } |
| 469 } | 469 } |
| OLD | NEW |