| 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "content/child/child_thread_impl.h" | 8 #include "content/child/child_thread_impl.h" |
| 9 #include "content/child/multipart_response_delegate.h" | 9 #include "content/child/multipart_response_delegate.h" |
| 10 #include "content/child/npapi/plugin_host.h" | 10 #include "content/child/npapi/plugin_host.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // specified in the response header. | 36 // specified in the response header. |
| 37 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc, | 37 // TODO(jam): this is similar to MultiPartResponseClient in webplugin_impl.cc, |
| 38 // we should remove that other class once we switch to loading from the plugin | 38 // we should remove that other class once we switch to loading from the plugin |
| 39 // process by default. | 39 // process by default. |
| 40 class MultiPartResponseClient : public blink::WebURLLoaderClient { | 40 class MultiPartResponseClient : public blink::WebURLLoaderClient { |
| 41 public: | 41 public: |
| 42 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream) | 42 explicit MultiPartResponseClient(PluginStreamUrl* plugin_stream) |
| 43 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {} | 43 : byte_range_lower_bound_(0), plugin_stream_(plugin_stream) {} |
| 44 | 44 |
| 45 // blink::WebURLLoaderClient implementation: | 45 // blink::WebURLLoaderClient implementation: |
| 46 virtual void didReceiveResponse( | 46 void didReceiveResponse(blink::WebURLLoader* loader, |
| 47 blink::WebURLLoader* loader, | 47 const blink::WebURLResponse& response) override { |
| 48 const blink::WebURLResponse& response) override { | |
| 49 int64 byte_range_upper_bound, instance_size; | 48 int64 byte_range_upper_bound, instance_size; |
| 50 if (!MultipartResponseDelegate::ReadContentRanges(response, | 49 if (!MultipartResponseDelegate::ReadContentRanges(response, |
| 51 &byte_range_lower_bound_, | 50 &byte_range_lower_bound_, |
| 52 &byte_range_upper_bound, | 51 &byte_range_upper_bound, |
| 53 &instance_size)) { | 52 &instance_size)) { |
| 54 NOTREACHED(); | 53 NOTREACHED(); |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 virtual void didReceiveData(blink::WebURLLoader* loader, | 56 void didReceiveData(blink::WebURLLoader* loader, |
| 58 const char* data, | 57 const char* data, |
| 59 int data_length, | 58 int data_length, |
| 60 int encoded_data_length) override { | 59 int encoded_data_length) override { |
| 61 // TODO(ananta) | 60 // TODO(ananta) |
| 62 // We should defer further loads on multipart resources on the same lines | 61 // We should defer further loads on multipart resources on the same lines |
| 63 // as regular resources requested by plugins to prevent reentrancy. | 62 // as regular resources requested by plugins to prevent reentrancy. |
| 64 int64 data_offset = byte_range_lower_bound_; | 63 int64 data_offset = byte_range_lower_bound_; |
| 65 byte_range_lower_bound_ += data_length; | 64 byte_range_lower_bound_ += data_length; |
| 66 plugin_stream_->DidReceiveData(data, data_length, data_offset); | 65 plugin_stream_->DidReceiveData(data, data_length, data_offset); |
| 67 // DANGER: this instance may be deleted at this point. | 66 // DANGER: this instance may be deleted at this point. |
| 68 } | 67 } |
| 69 | 68 |
| 70 private: | 69 private: |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 369 } |
| 371 | 370 |
| 372 if (error_code == net::OK) { | 371 if (error_code == net::OK) { |
| 373 plugin_stream_->DidFinishLoading(resource_id_); | 372 plugin_stream_->DidFinishLoading(resource_id_); |
| 374 } else { | 373 } else { |
| 375 plugin_stream_->DidFail(resource_id_); | 374 plugin_stream_->DidFail(resource_id_); |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 | 377 |
| 379 } // namespace content | 378 } // namespace content |
| OLD | NEW |