Chromium Code Reviews| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 const GURL& url, | 73 const GURL& url, |
| 74 const GURL& first_party_for_cookies, | 74 const GURL& first_party_for_cookies, |
| 75 const std::string& method, | 75 const std::string& method, |
| 76 const char* buf, | 76 const char* buf, |
| 77 unsigned int len, | 77 unsigned int len, |
| 78 const GURL& referrer, | 78 const GURL& referrer, |
| 79 bool notify_redirects, | 79 bool notify_redirects, |
| 80 bool is_plugin_src_load, | 80 bool is_plugin_src_load, |
| 81 int origin_pid, | 81 int origin_pid, |
| 82 int render_frame_id, | 82 int render_frame_id, |
| 83 unsigned long resource_id) | 83 unsigned long resource_id, |
| 84 bool copy_stream_data) | |
| 84 : plugin_stream_(plugin_stream), | 85 : plugin_stream_(plugin_stream), |
| 85 url_(url), | 86 url_(url), |
| 86 first_party_for_cookies_(first_party_for_cookies), | 87 first_party_for_cookies_(first_party_for_cookies), |
| 87 method_(method), | 88 method_(method), |
| 88 referrer_(referrer), | 89 referrer_(referrer), |
| 89 notify_redirects_(notify_redirects), | 90 notify_redirects_(notify_redirects), |
| 90 is_plugin_src_load_(is_plugin_src_load), | 91 is_plugin_src_load_(is_plugin_src_load), |
| 91 resource_id_(resource_id), | 92 resource_id_(resource_id), |
| 93 copy_stream_data_(copy_stream_data), | |
| 92 data_offset_(0), | 94 data_offset_(0), |
| 93 pending_failure_notification_(false) { | 95 pending_failure_notification_(false) { |
| 94 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; | 96 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; |
| 95 request_info.method = method; | 97 request_info.method = method; |
| 96 request_info.url = url; | 98 request_info.url = url; |
| 97 request_info.first_party_for_cookies = first_party_for_cookies; | 99 request_info.first_party_for_cookies = first_party_for_cookies; |
| 98 request_info.referrer = referrer; | 100 request_info.referrer = referrer; |
| 99 request_info.load_flags = net::LOAD_NORMAL; | 101 request_info.load_flags = net::LOAD_NORMAL; |
| 100 request_info.requestor_pid = origin_pid; | 102 request_info.requestor_pid = origin_pid; |
| 101 request_info.request_type = ResourceType::OBJECT; | 103 request_info.request_type = ResourceType::OBJECT; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 } | 296 } |
| 295 | 297 |
| 296 void PluginURLFetcher::OnReceivedData(const char* data, | 298 void PluginURLFetcher::OnReceivedData(const char* data, |
| 297 int data_length, | 299 int data_length, |
| 298 int encoded_data_length) { | 300 int encoded_data_length) { |
| 299 if (multipart_delegate_) { | 301 if (multipart_delegate_) { |
| 300 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); | 302 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); |
| 301 } else { | 303 } else { |
| 302 int64 offset = data_offset_; | 304 int64 offset = data_offset_; |
| 303 data_offset_ += data_length; | 305 data_offset_ += data_length; |
| 304 plugin_stream_->DidReceiveData(data, data_length, offset); | 306 |
| 307 if (copy_stream_data_) { | |
| 308 // QuickTime writes to this memory, and since we got it from | |
| 309 // ResourceDispatcher it's not mapped for write access in this process. | |
| 310 // http://crbug.com/308466. | |
| 311 char* data_copy = new char[data_length]; | |
|
ananta
2014/01/17 18:51:02
scoped_ptr?
jam
2014/01/17 19:09:17
Done.
| |
| 312 memcpy(data_copy, data, data_length); | |
| 313 plugin_stream_->DidReceiveData(data_copy, data_length, offset); | |
| 314 delete [] data_copy; | |
| 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 |