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 // This job type handles Chrome plugin network interception. When a plugin | 5 // This job type handles Chrome plugin network interception. When a plugin |
6 // wants to intercept a request, a job of this type is created. The intercept | 6 // wants to intercept a request, a job of this type is created. The intercept |
7 // job communicates with the plugin to retrieve the response headers and data. | 7 // job communicates with the plugin to retrieve the response headers and data. |
8 | 8 |
9 #include "chrome/common/net/url_request_intercept_job.h" | 9 #include "chrome/common/net/url_request_intercept_job.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 using base::Time; | 22 using base::Time; |
23 using base::TimeDelta; | 23 using base::TimeDelta; |
24 | 24 |
25 // | 25 // |
26 // URLRequestInterceptJob | 26 // URLRequestInterceptJob |
27 // | 27 // |
28 | 28 |
29 URLRequestInterceptJob::URLRequestInterceptJob(net::URLRequest* request, | 29 URLRequestInterceptJob::URLRequestInterceptJob(net::URLRequest* request, |
30 ChromePluginLib* plugin, | 30 ChromePluginLib* plugin, |
31 ScopableCPRequest* cprequest) | 31 ScopableCPRequest* cprequest) |
32 : URLRequestJob(request), | 32 : net::URLRequestJob(request), |
33 cprequest_(cprequest), | 33 cprequest_(cprequest), |
34 plugin_(plugin), | 34 plugin_(plugin), |
35 read_buffer_(NULL), | 35 read_buffer_(NULL), |
36 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 36 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
37 cprequest_->data = this; // see FromCPRequest(). | 37 cprequest_->data = this; // see FromCPRequest(). |
38 | 38 |
39 registrar_.Add(this, NotificationType::CHROME_PLUGIN_UNLOADED, | 39 registrar_.Add(this, NotificationType::CHROME_PLUGIN_UNLOADED, |
40 Source<ChromePluginLib>(plugin_)); | 40 Source<ChromePluginLib>(plugin_)); |
41 } | 41 } |
42 | 42 |
(...skipping 17 matching lines...) Expand all Loading... |
60 method_factory_.NewRunnableMethod( | 60 method_factory_.NewRunnableMethod( |
61 &URLRequestInterceptJob::StartAsync)); | 61 &URLRequestInterceptJob::StartAsync)); |
62 } | 62 } |
63 | 63 |
64 void URLRequestInterceptJob::Kill() { | 64 void URLRequestInterceptJob::Kill() { |
65 if (plugin_) { | 65 if (plugin_) { |
66 plugin_->functions().request_funcs->end_request(cprequest_.get(), | 66 plugin_->functions().request_funcs->end_request(cprequest_.get(), |
67 CPERR_CANCELLED); | 67 CPERR_CANCELLED); |
68 DetachPlugin(); | 68 DetachPlugin(); |
69 } | 69 } |
70 URLRequestJob::Kill(); | 70 net::URLRequestJob::Kill(); |
71 method_factory_.RevokeAll(); | 71 method_factory_.RevokeAll(); |
72 } | 72 } |
73 | 73 |
74 bool URLRequestInterceptJob::ReadRawData(net::IOBuffer* dest, int dest_size, | 74 bool URLRequestInterceptJob::ReadRawData(net::IOBuffer* dest, int dest_size, |
75 int* bytes_read) { | 75 int* bytes_read) { |
76 DCHECK_NE(dest_size, 0); | 76 DCHECK_NE(dest_size, 0); |
77 DCHECK(bytes_read); | 77 DCHECK(bytes_read); |
78 | 78 |
79 if (!plugin_) | 79 if (!plugin_) |
80 return false; | 80 return false; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 NotifyReadComplete(bytes_read); | 224 NotifyReadComplete(bytes_read); |
225 } | 225 } |
226 | 226 |
227 void URLRequestInterceptJob::Observe(NotificationType type, | 227 void URLRequestInterceptJob::Observe(NotificationType type, |
228 const NotificationSource& source, | 228 const NotificationSource& source, |
229 const NotificationDetails& details) { | 229 const NotificationDetails& details) { |
230 DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); | 230 DCHECK(type == NotificationType::CHROME_PLUGIN_UNLOADED); |
231 DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); | 231 DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr()); |
232 DetachPlugin(); | 232 DetachPlugin(); |
233 } | 233 } |
OLD | NEW |