| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 using blink::WebFrame; | 165 using blink::WebFrame; |
| 166 using blink::WebInputEvent; | 166 using blink::WebInputEvent; |
| 167 using blink::WebLocalFrame; | 167 using blink::WebLocalFrame; |
| 168 using blink::WebPlugin; | 168 using blink::WebPlugin; |
| 169 using blink::WebPluginContainer; | 169 using blink::WebPluginContainer; |
| 170 using blink::WebPrintParams; | 170 using blink::WebPrintParams; |
| 171 using blink::WebPrintScalingOption; | 171 using blink::WebPrintScalingOption; |
| 172 using blink::WebScopedUserGesture; | 172 using blink::WebScopedUserGesture; |
| 173 using blink::WebString; | 173 using blink::WebString; |
| 174 using blink::WebURLError; | 174 using blink::WebURLError; |
| 175 using blink::WebURLLoader; | 175 using blink::WebAssociatedURLLoaderClient; |
| 176 using blink::WebURLLoaderClient; | |
| 177 using blink::WebURLRequest; | 176 using blink::WebURLRequest; |
| 178 using blink::WebURLResponse; | 177 using blink::WebURLResponse; |
| 179 using blink::WebUserGestureIndicator; | 178 using blink::WebUserGestureIndicator; |
| 180 using blink::WebUserGestureToken; | 179 using blink::WebUserGestureToken; |
| 181 using blink::WebView; | 180 using blink::WebView; |
| 182 using blink::WebWidget; | 181 using blink::WebWidget; |
| 183 | 182 |
| 184 namespace content { | 183 namespace content { |
| 185 | 184 |
| 186 namespace { | 185 namespace { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 HostGlobals::Get()->GetInstance(instance_id); | 397 HostGlobals::Get()->GetInstance(instance_id); |
| 399 return instance; | 398 return instance; |
| 400 } | 399 } |
| 401 | 400 |
| 402 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() | 401 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() |
| 403 : finished_loading_(false) {} | 402 : finished_loading_(false) {} |
| 404 | 403 |
| 405 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} | 404 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} |
| 406 | 405 |
| 407 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( | 406 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( |
| 408 WebURLLoaderClient* document_loader) { | 407 WebAssociatedURLLoaderClient* document_loader) { |
| 409 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); | 408 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); |
| 410 ++it) { | 409 ++it) { |
| 411 document_loader->didReceiveData(NULL, it->c_str(), it->length(), | 410 document_loader->didReceiveData(it->c_str(), it->length()); |
| 412 0 /* encoded_data_length */, it->length()); | |
| 413 } | 411 } |
| 414 if (finished_loading_) { | 412 if (finished_loading_) { |
| 415 document_loader->didFinishLoading( | 413 document_loader->didFinishLoading(0 /* finish_time */); |
| 416 NULL, | |
| 417 0 /* finish_time */, | |
| 418 blink::WebURLLoaderClient::kUnknownEncodedDataLength); | |
| 419 } else if (error_.get()) { | 414 } else if (error_.get()) { |
| 420 DCHECK(!finished_loading_); | 415 DCHECK(!finished_loading_); |
| 421 document_loader->didFail(NULL, *error_); | 416 document_loader->didFail(*error_); |
| 422 } | 417 } |
| 423 } | 418 } |
| 424 | 419 |
| 425 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData( | 420 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData( |
| 426 WebURLLoader* loader, | |
| 427 const char* data, | 421 const char* data, |
| 428 int data_length, | 422 int data_length) { |
| 429 int encoded_data_length, | |
| 430 int encoded_body_length) { | |
| 431 data_.push_back(std::string(data, data_length)); | 423 data_.push_back(std::string(data, data_length)); |
| 432 } | 424 } |
| 433 | 425 |
| 434 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFinishLoading( | 426 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFinishLoading( |
| 435 WebURLLoader* loader, | 427 double finish_time) { |
| 436 double finish_time, | |
| 437 int64_t total_encoded_data_length) { | |
| 438 DCHECK(!finished_loading_); | 428 DCHECK(!finished_loading_); |
| 439 | 429 |
| 440 if (error_.get()) | 430 if (error_.get()) |
| 441 return; | 431 return; |
| 442 | 432 |
| 443 finished_loading_ = true; | 433 finished_loading_ = true; |
| 444 } | 434 } |
| 445 | 435 |
| 446 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( | 436 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( |
| 447 WebURLLoader* loader, | |
| 448 const WebURLError& error) { | 437 const WebURLError& error) { |
| 449 DCHECK(!error_.get()); | 438 DCHECK(!error_.get()); |
| 450 | 439 |
| 451 if (finished_loading_) | 440 if (finished_loading_) |
| 452 return; | 441 return; |
| 453 | 442 |
| 454 error_.reset(new WebURLError(error)); | 443 error_.reset(new WebURLError(error)); |
| 455 } | 444 } |
| 456 | 445 |
| 457 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() | 446 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 // Create a loader resource host for this load. Note that we have to set | 914 // Create a loader resource host for this load. Note that we have to set |
| 926 // the document_loader before issuing the in-process | 915 // the document_loader before issuing the in-process |
| 927 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly | 916 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly |
| 928 // call into the instance and expect it to be valid. | 917 // call into the instance and expect it to be valid. |
| 929 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 918 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
| 930 PepperURLLoaderHost* loader_host = | 919 PepperURLLoaderHost* loader_host = |
| 931 new PepperURLLoaderHost(host_impl, true, pp_instance(), 0); | 920 new PepperURLLoaderHost(host_impl, true, pp_instance(), 0); |
| 932 // TODO(teravest): Remove set_document_loader() from instance and clean up | 921 // TODO(teravest): Remove set_document_loader() from instance and clean up |
| 933 // this relationship. | 922 // this relationship. |
| 934 set_document_loader(loader_host); | 923 set_document_loader(loader_host); |
| 935 loader_host->didReceiveResponse(NULL, response); | 924 loader_host->didReceiveResponse(response); |
| 936 | 925 |
| 937 // This host will be pending until the resource object attaches to it. | 926 // This host will be pending until the resource object attaches to it. |
| 938 // | 927 // |
| 939 // PpapiHost now owns the pointer to loader_host, so we don't have to worry | 928 // PpapiHost now owns the pointer to loader_host, so we don't have to worry |
| 940 // about managing it. | 929 // about managing it. |
| 941 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( | 930 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( |
| 942 std::unique_ptr<ppapi::host::ResourceHost>(loader_host)); | 931 std::unique_ptr<ppapi::host::ResourceHost>(loader_host)); |
| 943 DCHECK(pending_host_id); | 932 DCHECK(pending_host_id); |
| 944 | 933 |
| 945 DataFromWebURLResponse( | 934 DataFromWebURLResponse( |
| (...skipping 2500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3446 const cc::TextureMailbox& mailbox) const { | 3435 const cc::TextureMailbox& mailbox) const { |
| 3447 auto it = | 3436 auto it = |
| 3448 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), | 3437 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), |
| 3449 [&mailbox](const TextureMailboxRefCount& ref_count) { | 3438 [&mailbox](const TextureMailboxRefCount& ref_count) { |
| 3450 return ref_count.first.mailbox() == mailbox.mailbox(); | 3439 return ref_count.first.mailbox() == mailbox.mailbox(); |
| 3451 }); | 3440 }); |
| 3452 return it != texture_ref_counts_.end(); | 3441 return it != texture_ref_counts_.end(); |
| 3453 } | 3442 } |
| 3454 | 3443 |
| 3455 } // namespace content | 3444 } // namespace content |
| OLD | NEW |