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.h" | 8 #include "content/child/child_thread.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 28 matching lines...) Expand all Loading... |
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 (!MultipartResponseDelegate::ReadContentRanges(response, | 51 if (!MultipartResponseDelegate::ReadContentRanges(response, |
52 &byte_range_lower_bound_, | 52 &byte_range_lower_bound_, |
53 &byte_range_upper_bound, | 53 &byte_range_upper_bound, |
54 &instance_size)) { | 54 &instance_size)) { |
55 NOTREACHED(); | 55 NOTREACHED(); |
56 } | 56 } |
57 } | 57 } |
58 virtual void didReceiveData(blink::WebURLLoader* loader, | 58 virtual void didReceiveData(blink::WebURLLoader* loader, |
59 const char* data, | 59 const char* data, |
60 int data_length, | 60 int data_length, |
61 int encoded_data_length) OVERRIDE { | 61 int encoded_data_length) override { |
62 // TODO(ananta) | 62 // TODO(ananta) |
63 // 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 |
64 // as regular resources requested by plugins to prevent reentrancy. | 64 // as regular resources requested by plugins to prevent reentrancy. |
65 int64 data_offset = byte_range_lower_bound_; | 65 int64 data_offset = byte_range_lower_bound_; |
66 byte_range_lower_bound_ += data_length; | 66 byte_range_lower_bound_ += data_length; |
67 plugin_stream_->DidReceiveData(data, data_length, data_offset); | 67 plugin_stream_->DidReceiveData(data, data_length, data_offset); |
68 // DANGER: this instance may be deleted at this point. | 68 // DANGER: this instance may be deleted at this point. |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 368 } |
369 | 369 |
370 if (error_code == net::OK) { | 370 if (error_code == net::OK) { |
371 plugin_stream_->DidFinishLoading(resource_id_); | 371 plugin_stream_->DidFinishLoading(resource_id_); |
372 } else { | 372 } else { |
373 plugin_stream_->DidFail(resource_id_); | 373 plugin_stream_->DidFail(resource_id_); |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 } // namespace content | 377 } // namespace content |
OLD | NEW |