OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 bool URLRequestAutomationJob::is_protocol_factory_registered_ = false; | 45 bool URLRequestAutomationJob::is_protocol_factory_registered_ = false; |
46 | 46 |
47 URLRequest::ProtocolFactory* URLRequestAutomationJob::old_http_factory_ | 47 URLRequest::ProtocolFactory* URLRequestAutomationJob::old_http_factory_ |
48 = NULL; | 48 = NULL; |
49 URLRequest::ProtocolFactory* URLRequestAutomationJob::old_https_factory_ | 49 URLRequest::ProtocolFactory* URLRequestAutomationJob::old_https_factory_ |
50 = NULL; | 50 = NULL; |
51 | 51 |
52 URLRequestAutomationJob::URLRequestAutomationJob(URLRequest* request, int tab, | 52 URLRequestAutomationJob::URLRequestAutomationJob(URLRequest* request, int tab, |
53 int request_id, AutomationResourceMessageFilter* filter) | 53 int request_id, AutomationResourceMessageFilter* filter) |
54 : URLRequestJob(request), | 54 : URLRequestJob(request), |
55 id_(request_id), | |
56 tab_(tab), | 55 tab_(tab), |
57 message_filter_(filter), | 56 message_filter_(filter), |
58 pending_buf_size_(0), | 57 pending_buf_size_(0), |
59 redirect_status_(0) { | 58 redirect_status_(0), |
| 59 request_id_(request_id) { |
60 DLOG(INFO) << "URLRequestAutomationJob create. Count: " << ++instance_count_; | 60 DLOG(INFO) << "URLRequestAutomationJob create. Count: " << ++instance_count_; |
61 DCHECK_NE(id_, -1); | 61 DCHECK(message_filter_ != NULL); |
| 62 |
| 63 if (message_filter_) { |
| 64 id_ = message_filter_->NewAutomationRequestId(); |
| 65 DCHECK_NE(id_, 0); |
| 66 } |
62 } | 67 } |
63 | 68 |
64 URLRequestAutomationJob::~URLRequestAutomationJob() { | 69 URLRequestAutomationJob::~URLRequestAutomationJob() { |
65 DLOG(INFO) << "URLRequestAutomationJob delete. Count: " << --instance_count_; | 70 DLOG(INFO) << "URLRequestAutomationJob delete. Count: " << --instance_count_; |
66 Cleanup(); | 71 Cleanup(); |
67 } | 72 } |
68 | 73 |
69 bool URLRequestAutomationJob::EnsureProtocolFactoryRegistered() { | 74 bool URLRequestAutomationJob::EnsureProtocolFactoryRegistered() { |
70 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 75 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
71 | 76 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 215 } |
211 | 216 |
212 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, | 217 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, |
213 int* request_id) { | 218 int* request_id) { |
214 switch (message.type()) { | 219 switch (message.type()) { |
215 case AutomationMsg_RequestStarted::ID: | 220 case AutomationMsg_RequestStarted::ID: |
216 case AutomationMsg_RequestData::ID: | 221 case AutomationMsg_RequestData::ID: |
217 case AutomationMsg_RequestEnd::ID: { | 222 case AutomationMsg_RequestEnd::ID: { |
218 void* iter = NULL; | 223 void* iter = NULL; |
219 int tab = 0; | 224 int tab = 0; |
220 if (message.ReadInt(&iter, &tab) && message.ReadInt(&iter, request_id)) { | 225 if (message.ReadInt(&iter, &tab) && |
| 226 message.ReadInt(&iter, request_id)) { |
221 return true; | 227 return true; |
222 } | 228 } |
223 break; | 229 break; |
224 } | 230 } |
225 } | 231 } |
226 | 232 |
227 return false; | 233 return false; |
228 } | 234 } |
229 | 235 |
230 void URLRequestAutomationJob::OnMessage(const IPC::Message& message) { | 236 void URLRequestAutomationJob::OnMessage(const IPC::Message& message) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 message_filter_->Send(new AutomationMsg_RequestStart(0, tab_, id_, | 431 message_filter_->Send(new AutomationMsg_RequestStart(0, tab_, id_, |
426 automation_request)); | 432 automation_request)); |
427 } | 433 } |
428 | 434 |
429 void URLRequestAutomationJob::DisconnectFromMessageFilter() { | 435 void URLRequestAutomationJob::DisconnectFromMessageFilter() { |
430 if (message_filter_) { | 436 if (message_filter_) { |
431 message_filter_->UnRegisterRequest(this); | 437 message_filter_->UnRegisterRequest(this); |
432 message_filter_ = NULL; | 438 message_filter_ = NULL; |
433 } | 439 } |
434 } | 440 } |
OLD | NEW |