| OLD | NEW |
| 1 // Copyright (c) 2011 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 // This class simulates what wininet does when a dns lookup fails. | 4 // This class simulates what wininet does when a dns lookup fails. |
| 5 | 5 |
| 6 #ifndef CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ | 6 #ifndef CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ |
| 7 #define CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ | 7 #define CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 10 #include "base/task.h" | 11 #include "base/task.h" |
| 11 #include "chrome/common/ref_counted_util.h" | 12 #include "chrome/common/ref_counted_util.h" |
| 12 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
| 13 #include "net/url_request/url_request_job.h" | 14 #include "net/url_request/url_request_job.h" |
| 14 | 15 |
| 15 class AutomationResourceMessageFilter; | 16 class AutomationResourceMessageFilter; |
| 16 struct AutomationURLResponse; | 17 struct AutomationURLResponse; |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 class HttpResponseHeaders; | 20 class HttpResponseHeaders; |
| 20 class HttpResponseInfo; | 21 class HttpResponseInfo; |
| 21 class HostPortPair; | 22 class HostPortPair; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace IPC { | 25 namespace IPC { |
| 25 class Message; | 26 class Message; |
| 26 } | 27 } |
| 27 | 28 |
| 28 // net::URLRequestJob implementation that loads the resources using | 29 // net::URLRequestJob implementation that loads the resources using |
| 29 // automation. | 30 // automation. |
| 30 class URLRequestAutomationJob : public net::URLRequestJob { | 31 class URLRequestAutomationJob : public net::URLRequestJob { |
| 31 public: | 32 public: |
| 32 URLRequestAutomationJob(net::URLRequest* request, int tab, int request_id, | 33 URLRequestAutomationJob(net::URLRequest* request, int tab, int request_id, |
| 33 AutomationResourceMessageFilter* filter, | 34 AutomationResourceMessageFilter* filter, |
| 34 bool is_pending); | 35 bool is_pending); |
| 35 | 36 |
| 36 // Register our factory for HTTP/HTTPs requests. | 37 // Register our factory for HTTP/HTTPs requests. |
| 37 static bool EnsureProtocolFactoryRegistered(); | 38 static void EnsureProtocolFactoryRegistered(); |
| 38 | 39 |
| 39 static net::URLRequest::ProtocolFactory Factory; | 40 static net::URLRequest::ProtocolFactory Factory; |
| 40 | 41 |
| 41 // net::URLRequestJob methods. | 42 // net::URLRequestJob methods. |
| 42 virtual void Start(); | 43 virtual void Start(); |
| 43 virtual void Kill(); | 44 virtual void Kill(); |
| 44 virtual bool GetMimeType(std::string* mime_type) const; | 45 virtual bool GetMimeType(std::string* mime_type) const; |
| 45 virtual bool GetCharset(std::string* charset); | 46 virtual bool GetCharset(std::string* charset); |
| 46 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 47 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
| 47 virtual int GetResponseCode() const; | 48 virtual int GetResponseCode() const; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // the host. | 122 // the host. |
| 122 bool is_pending_; | 123 bool is_pending_; |
| 123 | 124 |
| 124 // Contains the request status code, which is eventually passed to the http | 125 // Contains the request status code, which is eventually passed to the http |
| 125 // stack when we receive a Read request for a completed job. | 126 // stack when we receive a Read request for a completed job. |
| 126 net::URLRequestStatus request_status_; | 127 net::URLRequestStatus request_status_; |
| 127 | 128 |
| 128 // Contains the ip address and port of the destination host. | 129 // Contains the ip address and port of the destination host. |
| 129 net::HostPortPair socket_address_; | 130 net::HostPortPair socket_address_; |
| 130 | 131 |
| 131 ScopedRunnableMethodFactory<URLRequestAutomationJob> method_factory_; | 132 base::WeakPtrFactory<URLRequestAutomationJob> weak_factory_; |
| 132 | 133 |
| 133 DISALLOW_COPY_AND_ASSIGN(URLRequestAutomationJob); | 134 DISALLOW_COPY_AND_ASSIGN(URLRequestAutomationJob); |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 #endif // CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ | 137 #endif // CHROME_BROWSER_AUTOMATION_URL_REQUEST_AUTOMATION_JOB_H_ |
| OLD | NEW |