Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/child/npapi/plugin_url_fetcher.cc

Issue 384273003: Move multipart_response_delegate.* from webkit/ to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android_webview fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/npapi/plugin_url_fetcher.h ('k') | content/child/web_url_loader_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/child/npapi/plugin_url_fetcher.h" 5 #include "content/child/npapi/plugin_url_fetcher.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/child/child_thread.h" 8 #include "content/child/child_thread.h"
9 #include "content/child/multipart_response_delegate.h"
9 #include "content/child/npapi/plugin_host.h" 10 #include "content/child/npapi/plugin_host.h"
10 #include "content/child/npapi/plugin_instance.h" 11 #include "content/child/npapi/plugin_instance.h"
11 #include "content/child/npapi/plugin_stream_url.h" 12 #include "content/child/npapi/plugin_stream_url.h"
12 #include "content/child/npapi/webplugin.h" 13 #include "content/child/npapi/webplugin.h"
13 #include "content/child/npapi/webplugin_resource_client.h" 14 #include "content/child/npapi/webplugin_resource_client.h"
14 #include "content/child/plugin_messages.h" 15 #include "content/child/plugin_messages.h"
15 #include "content/child/request_extra_data.h" 16 #include "content/child/request_extra_data.h"
16 #include "content/child/request_info.h" 17 #include "content/child/request_info.h"
17 #include "content/child/resource_dispatcher.h" 18 #include "content/child/resource_dispatcher.h"
18 #include "content/child/web_url_loader_impl.h" 19 #include "content/child/web_url_loader_impl.h"
19 #include "content/common/resource_request_body.h" 20 #include "content/common/resource_request_body.h"
20 #include "content/common/service_worker/service_worker_types.h" 21 #include "content/common/service_worker/service_worker_types.h"
21 #include "content/public/common/resource_response_info.h" 22 #include "content/public/common/resource_response_info.h"
22 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
25 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
26 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 27 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
27 #include "third_party/WebKit/public/platform/WebURLResponse.h" 28 #include "third_party/WebKit/public/platform/WebURLResponse.h"
28 #include "webkit/child/multipart_response_delegate.h"
29 #include "webkit/child/resource_loader_bridge.h" 29 #include "webkit/child/resource_loader_bridge.h"
30 30
31 namespace content { 31 namespace content {
32 namespace { 32 namespace {
33 33
34 // This class handles individual multipart responses. It is instantiated when 34 // This class handles individual multipart responses. It is instantiated when
35 // we receive HTTP status code 206 in the HTTP response. This indicates 35 // we receive HTTP status code 206 in the HTTP response. This indicates
36 // that the response could have multiple parts each separated by a boundary 36 // that the response could have multiple parts each separated by a boundary
37 // specified in the response header. 37 // specified in the response header.
38 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc, 38 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc,
39 // we should remove that other class once we switch to loading from the plugin 39 // we should remove that other class once we switch to loading from the plugin
40 // process by default. 40 // process by default.
41 class MultiPartResponseClient : public blink::WebURLLoaderClient { 41 class MultiPartResponseClient : public blink::WebURLLoaderClient {
42 public: 42 public:
43 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream) 43 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream)
44 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {} 44 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {}
45 45
46 // blink::WebURLLoaderClient implementation: 46 // blink::WebURLLoaderClient implementation:
47 virtual void didReceiveResponse( 47 virtual void didReceiveResponse(
48 blink::WebURLLoader* loader, 48 blink::WebURLLoader* loader,
49 const blink::WebURLResponse& response) OVERRIDE { 49 const blink::WebURLResponse& response) OVERRIDE {
50 int64 byte_range_upper_bound, instance_size; 50 int64 byte_range_upper_bound, instance_size;
51 if (!webkit_glue::MultipartResponseDelegate::ReadContentRanges( 51 if (!MultipartResponseDelegate::ReadContentRanges(response,
52 response, &byte_range_lower_bound_, &byte_range_upper_bound, 52 &byte_range_lower_bound_,
53 &instance_size)) { 53 &byte_range_upper_bound,
54 &instance_size)) {
54 NOTREACHED(); 55 NOTREACHED();
55 } 56 }
56 } 57 }
57 virtual void didReceiveData(blink::WebURLLoader* loader, 58 virtual void didReceiveData(blink::WebURLLoader* loader,
58 const char* data, 59 const char* data,
59 int data_length, 60 int data_length,
60 int encoded_data_length) OVERRIDE { 61 int encoded_data_length) OVERRIDE {
61 // TODO(ananta) 62 // TODO(ananta)
62 // We should defer further loads on multipart resources on the same lines 63 // We should defer further loads on multipart resources on the same lines
63 // as regular resources requested by plugins to prevent reentrancy. 64 // as regular resources requested by plugins to prevent reentrancy.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 bool request_is_seekable = true; 258 bool request_is_seekable = true;
258 DCHECK(!multipart_delegate_.get()); 259 DCHECK(!multipart_delegate_.get());
259 if (plugin_stream_->seekable()) { 260 if (plugin_stream_->seekable()) {
260 int response_code = info.headers->response_code(); 261 int response_code = info.headers->response_code();
261 if (response_code == 206) { 262 if (response_code == 206) {
262 blink::WebURLResponse response; 263 blink::WebURLResponse response;
263 response.initialize(); 264 response.initialize();
264 WebURLLoaderImpl::PopulateURLResponse(url_, info, &response); 265 WebURLLoaderImpl::PopulateURLResponse(url_, info, &response);
265 266
266 std::string multipart_boundary; 267 std::string multipart_boundary;
267 if (webkit_glue::MultipartResponseDelegate::ReadMultipartBoundary( 268 if (MultipartResponseDelegate::ReadMultipartBoundary(
268 response, &multipart_boundary)) { 269 response, &multipart_boundary)) {
269 plugin_stream_->instance()->webplugin()->DidStartLoading(); 270 plugin_stream_->instance()->webplugin()->DidStartLoading();
270 271
271 MultiPartResponseClient* multi_part_response_client = 272 MultiPartResponseClient* multi_part_response_client =
272 new MultiPartResponseClient(plugin_stream_); 273 new MultiPartResponseClient(plugin_stream_);
273 274
274 multipart_delegate_.reset(new webkit_glue::MultipartResponseDelegate( 275 multipart_delegate_.reset(new MultipartResponseDelegate(
275 multi_part_response_client, NULL, response, multipart_boundary)); 276 multi_part_response_client, NULL, response, multipart_boundary));
276 277
277 // Multiple ranges requested, data will be delivered by 278 // Multiple ranges requested, data will be delivered by
278 // MultipartResponseDelegate. 279 // MultipartResponseDelegate.
279 data_offset_ = 0; 280 data_offset_ = 0;
280 return; 281 return;
281 } 282 }
282 283
283 int64 upper_bound = 0, instance_size = 0; 284 int64 upper_bound = 0, instance_size = 0;
284 // Single range requested - go through original processing for 285 // Single range requested - go through original processing for
285 // non-multipart requests, but update data offset. 286 // non-multipart requests, but update data offset.
286 webkit_glue::MultipartResponseDelegate::ReadContentRanges( 287 MultipartResponseDelegate::ReadContentRanges(
287 response, &data_offset_, &upper_bound, &instance_size); 288 response, &data_offset_, &upper_bound, &instance_size);
288 } else if (response_code == 200) { 289 } else if (response_code == 200) {
289 // TODO: should we handle this case? We used to but it's not clear that we 290 // TODO: should we handle this case? We used to but it's not clear that we
290 // still need to. This was bug 5403, fixed in r7139. 291 // still need to. This was bug 5403, fixed in r7139.
291 } 292 }
292 } 293 }
293 294
294 // If the length comes in as -1, then it indicates that it was not 295 // If the length comes in as -1, then it indicates that it was not
295 // read off the HTTP headers. We replicate Safari webkit behavior here, 296 // read off the HTTP headers. We replicate Safari webkit behavior here,
296 // which is to set it to 0. 297 // which is to set it to 0.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 382 }
382 383
383 if (error_code == net::OK) { 384 if (error_code == net::OK) {
384 plugin_stream_->DidFinishLoading(resource_id_); 385 plugin_stream_->DidFinishLoading(resource_id_);
385 } else { 386 } else {
386 plugin_stream_->DidFail(resource_id_); 387 plugin_stream_->DidFail(resource_id_);
387 } 388 }
388 } 389 }
389 390
390 } // namespace content 391 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/plugin_url_fetcher.h ('k') | content/child/web_url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698