| OLD | NEW |
| 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 "content/child/child_thread.h" | 7 #include "content/child/child_thread.h" |
| 8 #include "content/child/npapi/webplugin.h" | 8 #include "content/child/npapi/webplugin.h" |
| 9 #include "content/child/npapi/plugin_host.h" | 9 #include "content/child/npapi/plugin_host.h" |
| 10 #include "content/child/npapi/plugin_instance.h" | 10 #include "content/child/npapi/plugin_instance.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace content { | 24 namespace content { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // This class handles individual multipart responses. It is instantiated when | 27 // This class handles individual multipart responses. It is instantiated when |
| 28 // we receive HTTP status code 206 in the HTTP response. This indicates | 28 // we receive HTTP status code 206 in the HTTP response. This indicates |
| 29 // that the response could have multiple parts each separated by a boundary | 29 // that the response could have multiple parts each separated by a boundary |
| 30 // specified in the response header. | 30 // specified in the response header. |
| 31 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc, | 31 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc, |
| 32 // we should remove that other class once we switch to loading from the plugin | 32 // we should remove that other class once we switch to loading from the plugin |
| 33 // process by default. | 33 // process by default. |
| 34 class MultiPartResponseClient : public WebKit::WebURLLoaderClient { | 34 class MultiPartResponseClient : public blink::WebURLLoaderClient { |
| 35 public: | 35 public: |
| 36 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream) | 36 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream) |
| 37 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {} | 37 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {} |
| 38 | 38 |
| 39 // WebKit::WebURLLoaderClient implementation: | 39 // blink::WebURLLoaderClient implementation: |
| 40 virtual void didReceiveResponse( | 40 virtual void didReceiveResponse( |
| 41 WebKit::WebURLLoader* loader, | 41 blink::WebURLLoader* loader, |
| 42 const WebKit::WebURLResponse& response) OVERRIDE { | 42 const blink::WebURLResponse& response) OVERRIDE { |
| 43 int64 byte_range_upper_bound, instance_size; | 43 int64 byte_range_upper_bound, instance_size; |
| 44 if (!webkit_glue::MultipartResponseDelegate::ReadContentRanges( | 44 if (!webkit_glue::MultipartResponseDelegate::ReadContentRanges( |
| 45 response, &byte_range_lower_bound_, &byte_range_upper_bound, | 45 response, &byte_range_lower_bound_, &byte_range_upper_bound, |
| 46 &instance_size)) { | 46 &instance_size)) { |
| 47 NOTREACHED(); | 47 NOTREACHED(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 virtual void didReceiveData(WebKit::WebURLLoader* loader, | 50 virtual void didReceiveData(blink::WebURLLoader* loader, |
| 51 const char* data, | 51 const char* data, |
| 52 int data_length, | 52 int data_length, |
| 53 int encoded_data_length) OVERRIDE { | 53 int encoded_data_length) OVERRIDE { |
| 54 // TODO(ananta) | 54 // TODO(ananta) |
| 55 // We should defer further loads on multipart resources on the same lines | 55 // We should defer further loads on multipart resources on the same lines |
| 56 // as regular resources requested by plugins to prevent reentrancy. | 56 // as regular resources requested by plugins to prevent reentrancy. |
| 57 int64 data_offset = byte_range_lower_bound_; | 57 int64 data_offset = byte_range_lower_bound_; |
| 58 byte_range_lower_bound_ += data_length; | 58 byte_range_lower_bound_ += data_length; |
| 59 plugin_stream_->DidReceiveData(data, data_length, data_offset); | 59 plugin_stream_->DidReceiveData(data, data_length, data_offset); |
| 60 // DANGER: this instance may be deleted at this point. | 60 // DANGER: this instance may be deleted at this point. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 const webkit_glue::ResourceResponseInfo& info) { | 206 const webkit_glue::ResourceResponseInfo& info) { |
| 207 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::didReceiveResponse | 207 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::didReceiveResponse |
| 208 // GetAllHeaders, and GetResponseInfo until kDirectNPAPIRequests is the | 208 // GetAllHeaders, and GetResponseInfo until kDirectNPAPIRequests is the |
| 209 // default and we can remove the old path there. | 209 // default and we can remove the old path there. |
| 210 | 210 |
| 211 bool request_is_seekable = true; | 211 bool request_is_seekable = true; |
| 212 DCHECK(!multipart_delegate_.get()); | 212 DCHECK(!multipart_delegate_.get()); |
| 213 if (plugin_stream_->seekable()) { | 213 if (plugin_stream_->seekable()) { |
| 214 int response_code = info.headers->response_code(); | 214 int response_code = info.headers->response_code(); |
| 215 if (response_code == 206) { | 215 if (response_code == 206) { |
| 216 WebKit::WebURLResponse response; | 216 blink::WebURLResponse response; |
| 217 response.initialize(); | 217 response.initialize(); |
| 218 webkit_glue::WebURLLoaderImpl::PopulateURLResponse(url_, info, &response); | 218 webkit_glue::WebURLLoaderImpl::PopulateURLResponse(url_, info, &response); |
| 219 | 219 |
| 220 std::string multipart_boundary; | 220 std::string multipart_boundary; |
| 221 if (webkit_glue::MultipartResponseDelegate::ReadMultipartBoundary( | 221 if (webkit_glue::MultipartResponseDelegate::ReadMultipartBoundary( |
| 222 response, &multipart_boundary)) { | 222 response, &multipart_boundary)) { |
| 223 plugin_stream_->instance()->webplugin()->DidStartLoading(); | 223 plugin_stream_->instance()->webplugin()->DidStartLoading(); |
| 224 | 224 |
| 225 MultiPartResponseClient* multi_part_response_client = | 225 MultiPartResponseClient* multi_part_response_client = |
| 226 new MultiPartResponseClient(plugin_stream_); | 226 new MultiPartResponseClient(plugin_stream_); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (error_code == net::OK) { | 319 if (error_code == net::OK) { |
| 320 plugin_stream_->DidFinishLoading(resource_id_); | 320 plugin_stream_->DidFinishLoading(resource_id_); |
| 321 } else { | 321 } else { |
| 322 plugin_stream_->DidFail(resource_id_); | 322 plugin_stream_->DidFail(resource_id_); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace content | 326 } // namespace content |
| OLD | NEW |