OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ | 5 #ifndef CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ |
6 #define CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ | 6 #define CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/scoped_ptr.h" |
8 #include "net/url_request/url_request_job.h" | 11 #include "net/url_request/url_request_job.h" |
9 #include "chrome/browser/chrome_plugin_host.h" | 12 #include "chrome/browser/chrome_plugin_host.h" |
10 #include "chrome/common/chrome_plugin_api.h" | 13 #include "chrome/common/chrome_plugin_api.h" |
11 #include "chrome/common/chrome_plugin_util.h" | 14 #include "chrome/common/chrome_plugin_util.h" |
12 #include "chrome/common/notification_observer.h" | 15 #include "chrome/common/notification_observer.h" |
13 | 16 |
14 class ChromePluginLib; | 17 class ChromePluginLib; |
15 class URLRequest; | 18 class URLRequest; |
16 | 19 |
17 // A request job that handles network requests intercepted by a Chrome plugin. | 20 // A request job that handles network requests intercepted by a Chrome plugin. |
18 class URLRequestInterceptJob | 21 class URLRequestInterceptJob |
19 : public URLRequestJob, public NotificationObserver { | 22 : public URLRequestJob, public NotificationObserver { |
20 public: | 23 public: |
21 static URLRequestInterceptJob* FromCPRequest(CPRequest* request) { | 24 static URLRequestInterceptJob* FromCPRequest(CPRequest* request) { |
22 return ScopableCPRequest::GetData<URLRequestInterceptJob*>(request); | 25 return ScopableCPRequest::GetData<URLRequestInterceptJob*>(request); |
23 } | 26 } |
24 | 27 |
25 URLRequestInterceptJob(URLRequest* request, ChromePluginLib* plugin, | 28 URLRequestInterceptJob(URLRequest* request, ChromePluginLib* plugin, |
26 ScopableCPRequest* cprequest); | 29 ScopableCPRequest* cprequest); |
27 virtual ~URLRequestInterceptJob(); | 30 virtual ~URLRequestInterceptJob(); |
28 | 31 |
29 // Plugin callbacks. | 32 // Plugin callbacks. |
30 void OnStartCompleted(int result); | 33 void OnStartCompleted(int result); |
31 void OnReadCompleted(int bytes_read); | 34 void OnReadCompleted(int bytes_read); |
32 | 35 |
33 // URLRequestJob | 36 // URLRequestJob |
34 virtual void Start(); | 37 virtual void Start(); |
35 virtual void Kill(); | 38 virtual void Kill(); |
36 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 39 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
37 virtual bool GetMimeType(std::string* mime_type); | 40 virtual bool GetMimeType(std::string* mime_type) const; |
38 virtual bool GetCharset(std::string* charset); | 41 virtual bool GetCharset(std::string* charset); |
39 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 42 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
40 virtual int GetResponseCode(); | 43 virtual int GetResponseCode(); |
41 virtual bool GetContentEncoding(std::string* encoding_type); | 44 virtual bool GetContentEncoding(std::string* encoding_type); |
42 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 45 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
43 | 46 |
44 // NotificationObserver | 47 // NotificationObserver |
45 virtual void Observe(NotificationType type, | 48 virtual void Observe(NotificationType type, |
46 const NotificationSource& source, | 49 const NotificationSource& source, |
47 const NotificationDetails& details); | 50 const NotificationDetails& details); |
48 private: | 51 private: |
49 void StartAsync(); | 52 void StartAsync(); |
50 void DetachPlugin(); | 53 void DetachPlugin(); |
51 | 54 |
52 scoped_ptr<ScopableCPRequest> cprequest_; | 55 scoped_ptr<ScopableCPRequest> cprequest_; |
53 ChromePluginLib* plugin_; | 56 ChromePluginLib* plugin_; |
54 bool got_headers_; | 57 bool got_headers_; |
55 net::IOBuffer* read_buffer_; | 58 net::IOBuffer* read_buffer_; |
56 int read_buffer_size_; | 59 int read_buffer_size_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptJob); | 61 DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptJob); |
59 }; | 62 }; |
60 | 63 |
61 #endif // CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ | 64 #endif // CHROME_COMMON_NET_URL_REQUEST_INTERCEPT_JOB_H_ |
OLD | NEW |