| 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 "content/child/child_thread.h" | 8 #include "content/child/child_thread.h" |
| 8 #include "content/child/npapi/webplugin.h" | 9 #include "content/child/npapi/webplugin.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_resource_client.h" | 13 #include "content/child/npapi/webplugin_resource_client.h" |
| 13 #include "content/child/plugin_messages.h" | 14 #include "content/child/plugin_messages.h" |
| 14 #include "content/child/resource_dispatcher.h" | 15 #include "content/child/resource_dispatcher.h" |
| 15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 const GURL& url, | 74 const GURL& url, |
| 74 const GURL& first_party_for_cookies, | 75 const GURL& first_party_for_cookies, |
| 75 const std::string& method, | 76 const std::string& method, |
| 76 const char* buf, | 77 const char* buf, |
| 77 unsigned int len, | 78 unsigned int len, |
| 78 const GURL& referrer, | 79 const GURL& referrer, |
| 79 bool notify_redirects, | 80 bool notify_redirects, |
| 80 bool is_plugin_src_load, | 81 bool is_plugin_src_load, |
| 81 int origin_pid, | 82 int origin_pid, |
| 82 int render_view_id, | 83 int render_view_id, |
| 83 unsigned long resource_id) | 84 unsigned long resource_id, |
| 85 bool copy_stream_data) |
| 84 : plugin_stream_(plugin_stream), | 86 : plugin_stream_(plugin_stream), |
| 85 url_(url), | 87 url_(url), |
| 86 first_party_for_cookies_(first_party_for_cookies), | 88 first_party_for_cookies_(first_party_for_cookies), |
| 87 method_(method), | 89 method_(method), |
| 88 referrer_(referrer), | 90 referrer_(referrer), |
| 89 notify_redirects_(notify_redirects), | 91 notify_redirects_(notify_redirects), |
| 90 is_plugin_src_load_(is_plugin_src_load), | 92 is_plugin_src_load_(is_plugin_src_load), |
| 91 resource_id_(resource_id), | 93 resource_id_(resource_id), |
| 94 copy_stream_data_(copy_stream_data), |
| 92 data_offset_(0), | 95 data_offset_(0), |
| 93 pending_failure_notification_(false) { | 96 pending_failure_notification_(false) { |
| 94 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; | 97 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; |
| 95 request_info.method = method; | 98 request_info.method = method; |
| 96 request_info.url = url; | 99 request_info.url = url; |
| 97 request_info.first_party_for_cookies = first_party_for_cookies; | 100 request_info.first_party_for_cookies = first_party_for_cookies; |
| 98 request_info.referrer = referrer; | 101 request_info.referrer = referrer; |
| 99 request_info.load_flags = net::LOAD_NORMAL; | 102 request_info.load_flags = net::LOAD_NORMAL; |
| 100 request_info.requestor_pid = origin_pid; | 103 request_info.requestor_pid = origin_pid; |
| 101 request_info.request_type = ResourceType::OBJECT; | 104 request_info.request_type = ResourceType::OBJECT; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 297 } |
| 295 | 298 |
| 296 void PluginURLFetcher::OnReceivedData(const char* data, | 299 void PluginURLFetcher::OnReceivedData(const char* data, |
| 297 int data_length, | 300 int data_length, |
| 298 int encoded_data_length) { | 301 int encoded_data_length) { |
| 299 if (multipart_delegate_) { | 302 if (multipart_delegate_) { |
| 300 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); | 303 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); |
| 301 } else { | 304 } else { |
| 302 int64 offset = data_offset_; | 305 int64 offset = data_offset_; |
| 303 data_offset_ += data_length; | 306 data_offset_ += data_length; |
| 304 plugin_stream_->DidReceiveData(data, data_length, offset); | 307 |
| 308 if (copy_stream_data_) { |
| 309 // QuickTime writes to this memory, and since we got it from |
| 310 // ResourceDispatcher it's not mapped for write access in this process. |
| 311 // http://crbug.com/308466. |
| 312 scoped_ptr<char[]> data_copy(new char[data_length]); |
| 313 memcpy(data_copy.get(), data, data_length); |
| 314 plugin_stream_->DidReceiveData(data_copy.get(), data_length, offset); |
| 315 } else { |
| 316 plugin_stream_->DidReceiveData(data, data_length, offset); |
| 317 } |
| 305 // DANGER: this instance may be deleted at this point. | 318 // DANGER: this instance may be deleted at this point. |
| 306 } | 319 } |
| 307 } | 320 } |
| 308 | 321 |
| 309 void PluginURLFetcher::OnCompletedRequest( | 322 void PluginURLFetcher::OnCompletedRequest( |
| 310 int error_code, | 323 int error_code, |
| 311 bool was_ignored_by_handler, | 324 bool was_ignored_by_handler, |
| 312 const std::string& security_info, | 325 const std::string& security_info, |
| 313 const base::TimeTicks& completion_time) { | 326 const base::TimeTicks& completion_time) { |
| 314 if (multipart_delegate_) { | 327 if (multipart_delegate_) { |
| 315 multipart_delegate_->OnCompletedRequest(); | 328 multipart_delegate_->OnCompletedRequest(); |
| 316 multipart_delegate_.reset(); | 329 multipart_delegate_.reset(); |
| 317 } | 330 } |
| 318 | 331 |
| 319 if (error_code == net::OK) { | 332 if (error_code == net::OK) { |
| 320 plugin_stream_->DidFinishLoading(resource_id_); | 333 plugin_stream_->DidFinishLoading(resource_id_); |
| 321 } else { | 334 } else { |
| 322 plugin_stream_->DidFail(resource_id_); | 335 plugin_stream_->DidFail(resource_id_); |
| 323 } | 336 } |
| 324 } | 337 } |
| 325 | 338 |
| 326 } // namespace content | 339 } // namespace content |
| OLD | NEW |