summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc5
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h11
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc2
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc105
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h58
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc36
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.h1
-rw-r--r--webkit/plugins/ppapi/ppb_proxy_impl.cc9
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc550
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h176
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc12
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h3
-rw-r--r--webkit/plugins/ppapi/url_response_info_util.h3
-rw-r--r--webkit/plugins/webkit_plugins.gypi2
15 files changed, 187 insertions, 788 deletions
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 80cf90b..feccd2f 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -418,5 +418,10 @@ bool MockPluginDelegate::IsRunningInProcess(PP_Instance instance) const {
return false;
}
+void MockPluginDelegate::HandleDocumentLoad(
+ PluginInstance* instance,
+ const WebKit::WebURLResponse& response) {
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index a059aa1..d343c2a 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -181,6 +181,8 @@ class MockPluginDelegate : public PluginDelegate {
base::ProcessId target_process_id,
bool should_close_source) const;
virtual bool IsRunningInProcess(PP_Instance instance) const;
+ virtual void HandleDocumentLoad(PluginInstance* instance,
+ const WebKit::WebURLResponse& response);
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index ec0c922..f48e94e 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -84,6 +84,9 @@ class WebGamepads;
class WebPlugin;
struct WebCompositionUnderline;
struct WebCursorInfo;
+struct WebURLError;
+class WebURLLoaderClient;
+class WebURLResponse;
}
namespace webkit_glue {
@@ -675,6 +678,14 @@ class PluginDelegate {
// Returns true if running in process.
virtual bool IsRunningInProcess(PP_Instance instance) const = 0;
+
+ // Notifies the plugin of the document load. This should initiate the call to
+ // PPP_Instance.HandleDocumentLoad.
+ //
+ // The loader object should set itself on the PluginInstance as the document
+ // loader using set_document_loader.
+ virtual void HandleDocumentLoad(PluginInstance* instance,
+ const WebKit::WebURLResponse& response) = 0;
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 82d853e..75cead2 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -346,8 +346,6 @@ const void* InternalGetInterface(const char* name) {
return PPB_Proxy_Impl::GetInterface();
if (strcmp(name, PPB_UMA_PRIVATE_INTERFACE) == 0)
return PPB_UMA_Private_Impl::GetInterface();
- if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE_0_3) == 0)
- return ::ppapi::thunk::GetPPB_URLLoaderTrusted_0_3_Thunk();
if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0)
return PPB_Var_Deprecated_Impl::GetVarDeprecatedInterface();
if (strcmp(name, PPB_VAR_INTERFACE_1_0) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 565478c..0bd76f4 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -40,6 +40,7 @@
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/shared_impl/time_conversion.h"
+#include "ppapi/shared_impl/url_request_info_data.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_buffer_api.h"
@@ -50,6 +51,7 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
@@ -84,7 +86,6 @@
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
-#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppp_pdf.h"
#include "webkit/plugins/ppapi/url_request_info_util.h"
#include "webkit/plugins/sad_plugin.h"
@@ -134,7 +135,11 @@ using WebKit::WebPrintParams;
using WebKit::WebPrintScalingOption;
using WebKit::WebScopedUserGesture;
using WebKit::WebString;
+using WebKit::WebURLError;
+using WebKit::WebURLLoader;
+using WebKit::WebURLLoaderClient;
using WebKit::WebURLRequest;
+using WebKit::WebURLResponse;
using WebKit::WebUserGestureIndicator;
using WebKit::WebUserGestureToken;
using WebKit::WebView;
@@ -319,6 +324,51 @@ PluginInstance* PluginInstance::Create(PluginDelegate* delegate,
plugin_url);
}
+PluginInstance::NaClDocumentLoader::NaClDocumentLoader()
+ : finished_loading_(false) {
+}
+
+PluginInstance::NaClDocumentLoader::~NaClDocumentLoader(){
+}
+
+void PluginInstance::NaClDocumentLoader::ReplayReceivedData(
+ WebURLLoaderClient* document_loader) {
+ for (std::list<std::string>::iterator it = data_.begin();
+ it != data_.end(); ++it) {
+ document_loader->didReceiveData(NULL, it->c_str(), it->length(),
+ 0 /* encoded_data_length */);
+ }
+ if (finished_loading_) {
+ document_loader->didFinishLoading(NULL,
+ 0 /* finish_time */);
+ }
+ if (error_.get()) {
+ document_loader->didFail(NULL, *error_);
+ }
+}
+
+void PluginInstance::NaClDocumentLoader::didReceiveData(
+ WebURLLoader* loader,
+ const char* data,
+ int data_length,
+ int encoded_data_length) {
+ data_.push_back(std::string(data, data_length));
+}
+
+void PluginInstance::NaClDocumentLoader::didFinishLoading(
+ WebURLLoader* loader,
+ double finish_time) {
+ DCHECK(!finished_loading_);
+ finished_loading_ = true;
+}
+
+void PluginInstance::NaClDocumentLoader::didFail(
+ WebURLLoader* loader,
+ const WebURLError& error) {
+ DCHECK(!error_.get());
+ error_.reset(new WebURLError(error));
+}
+
PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate)
: Resource(::ppapi::Resource::Untracked()),
delegate_(delegate) {
@@ -385,7 +435,9 @@ PluginInstance::PluginInstance(
text_input_caret_set_(false),
selection_caret_(0),
selection_anchor_(0),
- pending_user_gesture_(0.0) {
+ pending_user_gesture_(0.0),
+ document_loader_(NULL),
+ nacl_document_load_(false) {
pp_instance_ = HostGlobals::Get()->AddInstance(this);
memset(&current_print_settings_, 0, sizeof(current_print_settings_));
@@ -397,6 +449,12 @@ PluginInstance::PluginInstance(
view_data_.is_page_visible = delegate->IsPageVisible();
resource_creation_ = delegate_->CreateResourceCreationAPI(this);
+
+ // TODO(bbudge) remove this when the trusted NaCl plugin has been removed.
+ // We must defer certain plugin events for NaCl instances since we switch
+ // from the in-process to the out-of-process proxy after instantiating them.
+ if (module->name() == "Native Client")
+ nacl_document_load_ = true;
}
PluginInstance::~PluginInstance() {
@@ -596,13 +654,27 @@ bool PluginInstance::Initialize(const std::vector<std::string>& arg_names,
return success;
}
-bool PluginInstance::HandleDocumentLoad(PPB_URLLoader_Impl* loader) {
- if (!document_loader_)
- document_loader_ = loader;
- DCHECK(loader == document_loader_.get());
-
- return PP_ToBool(instance_interface_->HandleDocumentLoad(
- pp_instance(), loader->pp_resource()));
+bool PluginInstance::HandleDocumentLoad(
+ const WebKit::WebURLResponse& response) {
+ DCHECK(!document_loader_);
+ if (!nacl_document_load_) {
+ if (module()->is_crashed()) {
+ // Don't create a resource for a crashed plugin.
+ container()->element().document().frame()->stopLoading();
+ return false;
+ }
+ delegate()->HandleDocumentLoad(this, response);
+ // If the load was not abandoned, document_loader_ will now be set. It's
+ // possible that the load was canceled by now and document_loader_ was
+ // already nulled out.
+ } else {
+ // The NaCl proxy isn't available, so save the response and record document
+ // load notifications for later replay.
+ nacl_document_response_ = response;
+ nacl_document_loader_.reset(new NaClDocumentLoader());
+ document_loader_ = nacl_document_loader_.get();
+ }
+ return true;
}
bool PluginInstance::SendCompositionEventToPlugin(PP_InputEvent_Type type,
@@ -2452,9 +2524,18 @@ PP_NaClResult PluginInstance::ResetAsProxied(
view_change_weak_ptr_factory_.InvalidateWeakPtrs();
SendDidChangeView();
- // If we received HandleDocumentLoad, re-send it now via the proxy.
- if (document_loader_)
- HandleDocumentLoad(document_loader_.get());
+ DCHECK(nacl_document_load_);
+ nacl_document_load_ = false;
+ if (!nacl_document_response_.isNull()) {
+ document_loader_ = NULL;
+ // Pass the response to the new proxy.
+ HandleDocumentLoad(nacl_document_response_);
+ nacl_document_response_ = WebKit::WebURLResponse();
+ // Replay any document load events we've received to the real loader.
+ nacl_document_loader_->ReplayReceivedData(document_loader_);
+ nacl_document_loader_.reset(NULL);
+ }
+
return PP_NACL_OK;
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 281b8d4..ae1da17 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -46,6 +46,8 @@
#include "ppapi/thunk/resource_creation_api.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCanvas.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureToken.h"
#include "third_party/skia/include/core/SkRefCnt.h"
@@ -65,8 +67,11 @@ class WebInputEvent;
class WebLayer;
class WebMouseEvent;
class WebPluginContainer;
+class WebURLLoader;
+class WebURLResponse;
struct WebCompositionUnderline;
struct WebCursorInfo;
+struct WebURLError;
struct WebPrintParams;
}
@@ -131,6 +136,10 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// nonzero.
PP_Instance pp_instance() const { return pp_instance_; }
+ ::ppapi::PPP_Instance_Combined* instance_interface() const {
+ return instance_interface_.get();
+ }
+
::ppapi::thunk::ResourceCreationAPI& resource_creation() {
return *resource_creation_.get();
}
@@ -173,11 +182,11 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
bool full_frame() const { return full_frame_; }
const ::ppapi::ViewData& view_data() const { return view_data_; }
- // PPP_Instance and PPP_Instance_Private pass-through.
+ // PPP_Instance and PPP_Instance_Private.
bool Initialize(const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
bool full_frame);
- bool HandleDocumentLoad(PPB_URLLoader_Impl* loader);
+ bool HandleDocumentLoad(const WebKit::WebURLResponse& response);
bool HandleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo* cursor_info);
PP_Var GetInstanceObject();
@@ -352,6 +361,17 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
void SimulateImeSetCompositionEvent(
const ::ppapi::InputEventData& input_event);
+ // The document loader is valid when the plugin is "full-frame" and in this
+ // case is non-NULL as long as the corresponding loader resource is alive.
+ // This pointer is non-owning, so the loader must use set_document_loader to
+ // clear itself when it is destroyed.
+ WebKit::WebURLLoaderClient* document_loader() const {
+ return document_loader_;
+ }
+ void set_document_loader(WebKit::WebURLLoaderClient* loader) {
+ document_loader_ = loader;
+ }
+
ContentDecryptorDelegate* GetContentDecryptorDelegate();
// PPB_Instance_API implementation.
@@ -485,6 +505,31 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
private:
friend class PpapiUnittest;
+ // Class to record document load notifications and play them back once the
+ // real document loader becomes available. Used only by NaCl instances.
+ class NaClDocumentLoader : public WebKit::WebURLLoaderClient {
+ public:
+ NaClDocumentLoader();
+ virtual ~NaClDocumentLoader();
+
+ void ReplayReceivedData(WebURLLoaderClient* document_loader);
+
+ // WebKit::WebURLLoaderClient implementation.
+ virtual void didReceiveData(WebKit::WebURLLoader* loader,
+ const char* data,
+ int data_length,
+ int encoded_data_length);
+ virtual void didFinishLoading(WebKit::WebURLLoader* loader,
+ double finish_time);
+ virtual void didFail(WebKit::WebURLLoader* loader,
+ const WebKit::WebURLError& error);
+
+ private:
+ std::list<std::string> data_;
+ bool finished_loading_;
+ scoped_ptr<WebKit::WebURLError> error_;
+ };
+
// Implements PPB_Gamepad_API. This is just to avoid having an excessive
// number of interfaces implemented by PluginInstance.
class GamepadImpl : public ::ppapi::thunk::PPB_Gamepad_API,
@@ -778,9 +823,12 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
std::vector<std::string> argn_;
std::vector<std::string> argv_;
- // This is NULL unless HandleDocumentLoad has called. In that case, we store
- // the pointer so we can re-send it later if we are reset to talk to NaCl.
- scoped_refptr<PPB_URLLoader_Impl> document_loader_;
+ // Non-owning pointer to the document loader, if any.
+ WebKit::WebURLLoaderClient* document_loader_;
+ // State for deferring document loads. Used only by NaCl instances.
+ WebKit::WebURLResponse nacl_document_response_;
+ scoped_ptr<NaClDocumentLoader> nacl_document_loader_;
+ bool nacl_document_load_;
// The ContentDecryptorDelegate forwards PPP_ContentDecryptor_Private
// calls and handles PPB_ContentDecryptor_Private calls.
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index 7257f2e..30820fb 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -14,6 +14,7 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
@@ -27,7 +28,6 @@
#include "webkit/plugins/ppapi/npobject_var.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
using ppapi::NPObjectVar;
using WebKit::WebCanvas;
@@ -191,38 +191,26 @@ bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
void WebPluginImpl::didReceiveResponse(
const WebKit::WebURLResponse& response) {
- DCHECK(!document_loader_);
-
- if (instance_->module()->is_crashed()) {
- // Don't create a resource for a crashed plugin.
- instance_->container()->element().document().frame()->stopLoading();
- return;
- }
-
- document_loader_ = new PPB_URLLoader_Impl(instance_->pp_instance(), true);
- document_loader_->didReceiveResponse(NULL, response);
-
- if (!instance_->HandleDocumentLoad(document_loader_))
- document_loader_ = NULL;
+ DCHECK(!instance_->document_loader());
+ instance_->HandleDocumentLoad(response);
}
void WebPluginImpl::didReceiveData(const char* data, int data_length) {
- if (document_loader_)
- document_loader_->didReceiveData(NULL, data, data_length, data_length);
+ WebKit::WebURLLoaderClient* document_loader = instance_->document_loader();
+ if (document_loader)
+ document_loader->didReceiveData(NULL, data, data_length, 0);
}
void WebPluginImpl::didFinishLoading() {
- if (document_loader_) {
- document_loader_->didFinishLoading(NULL, 0);
- document_loader_ = NULL;
- }
+ WebKit::WebURLLoaderClient* document_loader = instance_->document_loader();
+ if (document_loader)
+ document_loader->didFinishLoading(NULL, 0.0);
}
void WebPluginImpl::didFailLoading(const WebKit::WebURLError& error) {
- if (document_loader_) {
- document_loader_->didFail(NULL, error);
- document_loader_ = NULL;
- }
+ WebKit::WebURLLoaderClient* document_loader = instance_->document_loader();
+ if (document_loader)
+ document_loader->didFail(NULL, error);
}
void WebPluginImpl::didFinishLoadingFrameRequest(const WebKit::WebURL& url,
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.h b/webkit/plugins/ppapi/ppapi_webplugin_impl.h
index 0ea0080..11bcf89 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.h
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.h
@@ -96,7 +96,6 @@ class WebPluginImpl : public WebKit::WebPlugin {
// being an embedded resource.
bool full_frame_;
scoped_refptr<PluginInstance> instance_;
- scoped_refptr<PPB_URLLoader_Impl> document_loader_;
gfx::Rect plugin_rect_;
PP_Var instance_object_;
WebKit::WebPluginContainer* container_;
diff --git a/webkit/plugins/ppapi/ppb_proxy_impl.cc b/webkit/plugins/ppapi/ppb_proxy_impl.cc
index 070aa7a..2910045 100644
--- a/webkit/plugins/ppapi/ppb_proxy_impl.cc
+++ b/webkit/plugins/ppapi/ppb_proxy_impl.cc
@@ -10,7 +10,6 @@
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
using ppapi::PpapiGlobals;
using ppapi::thunk::EnterResource;
@@ -42,13 +41,6 @@ void SetReserveInstanceIDCallback(PP_Module module,
plugin_module->SetReserveInstanceIDCallback(reserve);
}
-int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) {
- EnterResource<PPB_URLLoader_API> enter(url_loader, true);
- if (enter.succeeded())
- return static_cast<PPB_URLLoader_Impl*>(enter.object())->buffer_size();
- return 0;
-}
-
void AddRefModule(PP_Module module) {
PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
@@ -72,7 +64,6 @@ const PPB_Proxy_Private ppb_proxy = {
&PluginCrashed,
&GetInstanceForResource,
&SetReserveInstanceIDCallback,
- &GetURLLoaderBufferedBytes,
&AddRefModule,
&ReleaseModule,
&IsInModuleDestructor
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
deleted file mode 100644
index 0b0869d..0000000
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ /dev/null
@@ -1,550 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
-
-#include "base/logging.h"
-#include "net/base/net_errors.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
-#include "ppapi/shared_impl/ppapi_globals.h"
-#include "ppapi/shared_impl/url_response_info_data.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/ppb_url_request_info_api.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoader.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h"
-#include "webkit/appcache/web_application_cache_host_impl.h"
-#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/plugin_module.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/resource_helper.h"
-#include "webkit/plugins/ppapi/url_request_info_util.h"
-#include "webkit/plugins/ppapi/url_response_info_util.h"
-
-using appcache::WebApplicationCacheHostImpl;
-using ppapi::Resource;
-using ppapi::thunk::EnterResourceNoLock;
-using ppapi::thunk::PPB_URLLoader_API;
-using ppapi::thunk::PPB_URLRequestInfo_API;
-using ppapi::TrackedCallback;
-using WebKit::WebFrame;
-using WebKit::WebString;
-using WebKit::WebURL;
-using WebKit::WebURLError;
-using WebKit::WebURLLoader;
-using WebKit::WebURLLoaderOptions;
-using WebKit::WebURLRequest;
-using WebKit::WebURLResponse;
-
-#ifdef _MSC_VER
-// Do not warn about use of std::copy with raw pointers.
-#pragma warning(disable : 4996)
-#endif
-
-namespace webkit {
-namespace ppapi {
-
-namespace {
-
-WebFrame* GetFrameForResource(const Resource* resource) {
- PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(resource);
- if (!plugin_instance)
- return NULL;
- return plugin_instance->container()->element().document().frame();
-}
-
-} // namespace
-
-PPB_URLLoader_Impl::PPB_URLLoader_Impl(PP_Instance instance,
- bool main_document_loader)
- : Resource(::ppapi::OBJECT_IS_IMPL, instance),
- main_document_loader_(main_document_loader),
- pending_callback_(),
- bytes_sent_(0),
- total_bytes_to_be_sent_(-1),
- bytes_received_(0),
- total_bytes_to_be_received_(-1),
- user_buffer_(NULL),
- user_buffer_size_(0),
- done_status_(PP_OK_COMPLETIONPENDING),
- is_streaming_to_file_(false),
- is_asynchronous_load_suspended_(false),
- has_universal_access_(false),
- status_callback_(NULL) {
-}
-
-PPB_URLLoader_Impl::~PPB_URLLoader_Impl() {
- // Removes the resource from the ResourceTracker's tables. This normally
- // happens as part of Resource destruction, but if a subclass destructor
- // has a risk of re-entering destruction via the ResourceTracker, it can
- // call this explicitly to get rid of the table entry before continuing
- // with the destruction. If the resource is not in the ResourceTracker's
- // tables, silently does nothing. See http://crbug.com/159429.
- RemoveFromResourceTracker();
-}
-
-PPB_URLLoader_API* PPB_URLLoader_Impl::AsPPB_URLLoader_API() {
- return this;
-}
-
-void PPB_URLLoader_Impl::InstanceWasDeleted() {
- loader_.reset();
-}
-
-int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
- scoped_refptr<TrackedCallback> callback) {
- EnterResourceNoLock<PPB_URLRequestInfo_API> enter_request(request_id, true);
- if (enter_request.failed()) {
- Log(PP_LOGLEVEL_ERROR,
- "PPB_URLLoader.Open: invalid request resource ID. (Hint to C++ wrapper"
- " users: use the ResourceRequest constructor that takes an instance or"
- " else the request will be null.)");
- return PP_ERROR_BADARGUMENT;
- }
- return Open(enter_request.object()->GetData(), 0, callback);
-}
-
-int32_t PPB_URLLoader_Impl::Open(
- const ::ppapi::URLRequestInfoData& request_data,
- int requestor_pid,
- scoped_refptr<TrackedCallback> callback) {
- // Main document loads are already open, so don't allow people to open them
- // again.
- if (main_document_loader_)
- return PP_ERROR_INPROGRESS;
-
- int32_t rv = ValidateCallback(callback);
- if (rv != PP_OK)
- return rv;
-
- // Create a copy of the request data since CreateWebURLRequest will populate
- // the file refs.
- ::ppapi::URLRequestInfoData filled_in_request_data = request_data;
-
- if (URLRequestRequiresUniversalAccess(filled_in_request_data) &&
- !has_universal_access_) {
- Log(PP_LOGLEVEL_ERROR, "PPB_URLLoader.Open: The URL you're requesting is "
- " on a different security origin than your plugin. To request "
- " cross-origin resources, see "
- " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS.");
- return PP_ERROR_NOACCESS;
- }
-
- if (loader_)
- return PP_ERROR_INPROGRESS;
-
- WebFrame* frame = GetFrameForResource(this);
- if (!frame)
- return PP_ERROR_FAILED;
- WebURLRequest web_request;
- if (!CreateWebURLRequest(&filled_in_request_data, frame, &web_request))
- return PP_ERROR_FAILED;
- web_request.setRequestorProcessID(requestor_pid);
-
- // Save a copy of the request info so the plugin can continue to use and
- // change it while we're doing the request without affecting us. We must do
- // this after CreateWebURLRequest since that fills out the file refs.
- request_data_ = filled_in_request_data;
-
- WebURLLoaderOptions options;
- if (has_universal_access_) {
- options.allowCredentials = true;
- options.crossOriginRequestPolicy =
- WebURLLoaderOptions::CrossOriginRequestPolicyAllow;
- } else {
- // All other HTTP requests are untrusted.
- options.untrustedHTTP = true;
- if (request_data_.allow_cross_origin_requests) {
- // Allow cross-origin requests with access control. The request specifies
- // if credentials are to be sent.
- options.allowCredentials = request_data_.allow_credentials;
- options.crossOriginRequestPolicy =
- WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl;
- } else {
- // Same-origin requests can always send credentials.
- options.allowCredentials = true;
- }
- }
-
- is_asynchronous_load_suspended_ = false;
- loader_.reset(frame->createAssociatedURLLoader(options));
- if (!loader_)
- return PP_ERROR_FAILED;
-
- loader_->loadAsynchronously(web_request, this);
-
- // Notify completion when we receive a redirect or response headers.
- RegisterCallback(callback);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PPB_URLLoader_Impl::FollowRedirect(
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = ValidateCallback(callback);
- if (rv != PP_OK)
- return rv;
-
- SetDefersLoading(false); // Allow the redirect to continue.
- RegisterCallback(callback);
- return PP_OK_COMPLETIONPENDING;
-}
-
-PP_Bool PPB_URLLoader_Impl::GetUploadProgress(int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) {
- if (!RecordUploadProgress()) {
- *bytes_sent = 0;
- *total_bytes_to_be_sent = 0;
- return PP_FALSE;
- }
- *bytes_sent = bytes_sent_;
- *total_bytes_to_be_sent = total_bytes_to_be_sent_;
- return PP_TRUE;
-}
-
-PP_Bool PPB_URLLoader_Impl::GetDownloadProgress(
- int64_t* bytes_received,
- int64_t* total_bytes_to_be_received) {
- if (!RecordDownloadProgress()) {
- *bytes_received = 0;
- *total_bytes_to_be_received = 0;
- return PP_FALSE;
- }
- *bytes_received = bytes_received_;
- *total_bytes_to_be_received = total_bytes_to_be_received_;
- return PP_TRUE;
-}
-
-PP_Resource PPB_URLLoader_Impl::GetResponseInfo() {
- ::ppapi::thunk::EnterResourceCreationNoLock enter(pp_instance());
- if (enter.failed() || !response_info_)
- return 0;
-
- // Since we're the "host" the process-local resource for the file ref is
- // the same as the host resource. We pass a ref to the file ref.
- if (!response_info_->body_as_file_ref.resource.is_null()) {
- ::ppapi::PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(
- response_info_->body_as_file_ref.resource.host_resource());
- }
- return enter.functions()->CreateURLResponseInfo(
- pp_instance(),
- *response_info_,
- response_info_->body_as_file_ref.resource.host_resource());
-}
-
-int32_t PPB_URLLoader_Impl::ReadResponseBody(
- void* buffer,
- int32_t bytes_to_read,
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = ValidateCallback(callback);
- if (rv != PP_OK)
- return rv;
- if (!response_info_.get() ||
- !response_info_->body_as_file_ref.resource.is_null())
- return PP_ERROR_FAILED;
- if (bytes_to_read <= 0 || !buffer)
- return PP_ERROR_BADARGUMENT;
-
- user_buffer_ = static_cast<char*>(buffer);
- user_buffer_size_ = bytes_to_read;
-
- if (!buffer_.empty())
- return FillUserBuffer();
-
- // We may have already reached EOF.
- if (done_status_ != PP_OK_COMPLETIONPENDING) {
- user_buffer_ = NULL;
- user_buffer_size_ = 0;
- return done_status_;
- }
-
- RegisterCallback(callback);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
- scoped_refptr<TrackedCallback> callback) {
- int32_t rv = ValidateCallback(callback);
- if (rv != PP_OK)
- return rv;
- if (!response_info_.get() ||
- response_info_->body_as_file_ref.resource.is_null())
- return PP_ERROR_FAILED;
-
- // We may have already reached EOF.
- if (done_status_ != PP_OK_COMPLETIONPENDING)
- return done_status_;
-
- is_streaming_to_file_ = true;
- if (is_asynchronous_load_suspended_)
- SetDefersLoading(false);
-
- // Wait for didFinishLoading / didFail.
- RegisterCallback(callback);
- return PP_OK_COMPLETIONPENDING;
-}
-
-void PPB_URLLoader_Impl::Close() {
- if (loader_)
- loader_->cancel();
- else if (main_document_loader_)
- GetFrameForResource(this)->stopLoading();
-
- // We must not access the buffer provided by the caller from this point on.
- user_buffer_ = NULL;
- user_buffer_size_ = 0;
- if (TrackedCallback::IsPending(pending_callback_))
- pending_callback_->PostAbort();
-}
-
-void PPB_URLLoader_Impl::GrantUniversalAccess() {
- has_universal_access_ = true;
-}
-
-void PPB_URLLoader_Impl::RegisterStatusCallback(
- PP_URLLoaderTrusted_StatusCallback cb) {
- status_callback_ = cb;
-}
-
-bool PPB_URLLoader_Impl::GetResponseInfoData(
- ::ppapi::URLResponseInfoData* data) {
- if (!response_info_)
- return false;
-
- *data = *response_info_;
-
- // We transfer one plugin reference to the FileRef to the caller.
- if (!response_info_->body_as_file_ref.resource.is_null()) {
- ::ppapi::PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(
- response_info_->body_as_file_ref.resource.host_resource());
- }
- return true;
-}
-
-void PPB_URLLoader_Impl::willSendRequest(
- WebURLLoader* loader,
- WebURLRequest& new_request,
- const WebURLResponse& redirect_response) {
- if (!request_data_.follow_redirects) {
- SaveResponse(redirect_response);
- SetDefersLoading(true);
- RunCallback(PP_OK);
- }
-}
-
-void PPB_URLLoader_Impl::didSendData(
- WebURLLoader* loader,
- unsigned long long bytes_sent,
- unsigned long long total_bytes_to_be_sent) {
- // TODO(darin): Bounds check input?
- bytes_sent_ = static_cast<int64_t>(bytes_sent);
- total_bytes_to_be_sent_ = static_cast<int64_t>(total_bytes_to_be_sent);
- UpdateStatus();
-}
-
-void PPB_URLLoader_Impl::didReceiveResponse(WebURLLoader* loader,
- const WebURLResponse& response) {
- SaveResponse(response);
-
- // Sets -1 if the content length is unknown.
- total_bytes_to_be_received_ = response.expectedContentLength();
- UpdateStatus();
-
- RunCallback(PP_OK);
-}
-
-void PPB_URLLoader_Impl::didDownloadData(WebURLLoader* loader,
- int data_length) {
- bytes_received_ += data_length;
- UpdateStatus();
-}
-
-void PPB_URLLoader_Impl::didReceiveData(WebURLLoader* loader,
- const char* data,
- int data_length,
- int encoded_data_length) {
- // Note that |loader| will be NULL for document loads.
- bytes_received_ += data_length;
- UpdateStatus();
-
- buffer_.insert(buffer_.end(), data, data + data_length);
-
- // To avoid letting the network stack download an entire stream all at once,
- // defer loading when we have enough buffer.
- // Check for this before we run the callback, even though that could move
- // data out of the buffer. Doing anything after the callback is unsafe.
- DCHECK(request_data_.prefetch_buffer_lower_threshold <
- request_data_.prefetch_buffer_upper_threshold);
- if (!is_streaming_to_file_ &&
- !is_asynchronous_load_suspended_ &&
- (buffer_.size() >= static_cast<size_t>(
- request_data_.prefetch_buffer_upper_threshold))) {
- DVLOG(1) << "Suspending async load - buffer size: " << buffer_.size();
- SetDefersLoading(true);
- }
-
- if (user_buffer_) {
- RunCallback(FillUserBuffer());
- } else {
- DCHECK(!TrackedCallback::IsPending(pending_callback_));
- }
-}
-
-void PPB_URLLoader_Impl::didFinishLoading(WebURLLoader* loader,
- double finish_time) {
- FinishLoading(PP_OK);
-}
-
-void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
- const WebURLError& error) {
- int32_t pp_error = PP_ERROR_FAILED;
- if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain))) {
- // TODO(bbudge): Extend pp_errors.h to cover interesting network errors
- // from the net error domain.
- switch (error.reason) {
- case net::ERR_ABORTED:
- pp_error = PP_ERROR_ABORTED;
- break;
- case net::ERR_ACCESS_DENIED:
- case net::ERR_NETWORK_ACCESS_DENIED:
- pp_error = PP_ERROR_NOACCESS;
- break;
- }
- } else {
- // It's a WebKit error.
- pp_error = PP_ERROR_NOACCESS;
- }
-
- FinishLoading(pp_error);
-}
-
-void PPB_URLLoader_Impl::SetDefersLoading(bool defers_loading) {
- if (loader_) {
- loader_->setDefersLoading(defers_loading);
- is_asynchronous_load_suspended_ = defers_loading;
- }
-
- // TODO(brettw) bug 96770: We need a way to set the defers loading flag on
- // main document loads (when the loader_ is null).
-}
-
-void PPB_URLLoader_Impl::FinishLoading(int32_t done_status) {
- done_status_ = done_status;
- user_buffer_ = NULL;
- user_buffer_size_ = 0;
- // If the client hasn't called any function that takes a callback since
- // the initial call to Open, or called ReadResponseBody and got a
- // synchronous return, then the callback will be NULL.
- if (TrackedCallback::IsPending(pending_callback_))
- RunCallback(done_status_);
-}
-
-int32_t PPB_URLLoader_Impl::ValidateCallback(
- scoped_refptr<TrackedCallback> callback) {
- DCHECK(callback);
-
- if (TrackedCallback::IsPending(pending_callback_))
- return PP_ERROR_INPROGRESS;
-
- return PP_OK;
-}
-
-void PPB_URLLoader_Impl::RegisterCallback(
- scoped_refptr<TrackedCallback> callback) {
- DCHECK(!TrackedCallback::IsPending(pending_callback_));
-
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
- if (!plugin_module)
- return;
-
- pending_callback_ = callback;
-}
-
-void PPB_URLLoader_Impl::RunCallback(int32_t result) {
- // This may be null only when this is a main document loader.
- if (!pending_callback_) {
- CHECK(main_document_loader_);
- return;
- }
-
- // If |user_buffer_| was set as part of registering a callback, the paths
- // which trigger that callack must have cleared it since the callback is now
- // free to delete it.
- DCHECK(!user_buffer_);
-
- // As a second line of defense, clear the |user_buffer_| in case the
- // callbacks get called in an unexpected order.
- user_buffer_ = NULL;
- user_buffer_size_ = 0;
- pending_callback_->Run(result);
-}
-
-size_t PPB_URLLoader_Impl::FillUserBuffer() {
- DCHECK(user_buffer_);
- DCHECK(user_buffer_size_);
-
- size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_);
- std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_);
- buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy);
-
- // If the buffer is getting too empty, resume asynchronous loading.
- if (is_asynchronous_load_suspended_ &&
- buffer_.size() <= static_cast<size_t>(
- request_data_.prefetch_buffer_lower_threshold)) {
- DVLOG(1) << "Resuming async load - buffer size: " << buffer_.size();
- SetDefersLoading(false);
- }
-
- // Reset for next time.
- user_buffer_ = NULL;
- user_buffer_size_ = 0;
- return bytes_to_copy;
-}
-
-void PPB_URLLoader_Impl::SaveResponse(const WebURLResponse& response) {
- // DataFromWebURLResponse returns a file ref with one reference to it, which
- // we take over via our ScopedPPResource.
- response_info_.reset(new ::ppapi::URLResponseInfoData(
- DataFromWebURLResponse(pp_instance(), response)));
- response_info_file_ref_ = ::ppapi::ScopedPPResource(
- ::ppapi::ScopedPPResource::PassRef(),
- response_info_->body_as_file_ref.resource.host_resource());
-}
-
-void PPB_URLLoader_Impl::UpdateStatus() {
- if (status_callback_ &&
- (RecordDownloadProgress() || RecordUploadProgress())) {
- // Here we go through some effort to only send the exact information that
- // the requestor wanted in the request flags. It would be just as
- // efficient to send all of it, but we don't want people to rely on
- // getting download progress when they happen to set the upload progress
- // flag.
- status_callback_(
- pp_instance(), pp_resource(),
- RecordUploadProgress() ? bytes_sent_ : -1,
- RecordUploadProgress() ? total_bytes_to_be_sent_ : -1,
- RecordDownloadProgress() ? bytes_received_ : -1,
- RecordDownloadProgress() ? total_bytes_to_be_received_ : -1);
- }
-}
-
-bool PPB_URLLoader_Impl::RecordDownloadProgress() const {
- return request_data_.record_download_progress;
-}
-
-bool PPB_URLLoader_Impl::RecordUploadProgress() const {
- return request_data_.record_upload_progress;
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
deleted file mode 100644
index bb4ea3a..0000000
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.h
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
-
-#include <deque>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/scoped_pp_resource.h"
-#include "ppapi/shared_impl/tracked_callback.h"
-#include "ppapi/shared_impl/url_request_info_data.h"
-#include "ppapi/thunk/ppb_url_loader_api.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-
-namespace WebKit {
-class WebURL;
-}
-
-namespace webkit {
-namespace ppapi {
-
-class PPB_URLLoader_Impl : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_URLLoader_API,
- public WebKit::WebURLLoaderClient {
- public:
- PPB_URLLoader_Impl(PP_Instance instance, bool main_document_loader);
- virtual ~PPB_URLLoader_Impl();
-
- // Resource overrides.
- virtual ::ppapi::thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE;
- virtual void InstanceWasDeleted() OVERRIDE;
-
- // PPB_URLLoader_API implementation.
- virtual int32_t Open(
- PP_Resource request_id,
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual int32_t Open(
- const ::ppapi::URLRequestInfoData& data,
- int requestor_pid,
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual int32_t FollowRedirect(
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) OVERRIDE;
- virtual PP_Bool GetDownloadProgress(
- int64_t* bytes_received,
- int64_t* total_bytes_to_be_received) OVERRIDE;
- virtual PP_Resource GetResponseInfo() OVERRIDE;
- virtual int32_t ReadResponseBody(
- void* buffer,
- int32_t bytes_to_read,
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual int32_t FinishStreamingToFile(
- scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
- virtual void Close() OVERRIDE;
- virtual void GrantUniversalAccess() OVERRIDE;
- virtual void RegisterStatusCallback(
- PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
- virtual bool GetResponseInfoData(
- ::ppapi::URLResponseInfoData* data) OVERRIDE;
-
- // WebKit::WebURLLoaderClient implementation.
- virtual void willSendRequest(WebKit::WebURLLoader* loader,
- WebKit::WebURLRequest& new_request,
- const WebKit::WebURLResponse& redir_response);
- virtual void didSendData(WebKit::WebURLLoader* loader,
- unsigned long long bytes_sent,
- unsigned long long total_bytes_to_be_sent);
- virtual void didReceiveResponse(WebKit::WebURLLoader* loader,
- const WebKit::WebURLResponse& response);
- virtual void didDownloadData(WebKit::WebURLLoader* loader,
- int data_length);
-
- virtual void didReceiveData(WebKit::WebURLLoader* loader,
- const char* data,
- int data_length,
- int encoded_data_length);
- virtual void didFinishLoading(WebKit::WebURLLoader* loader,
- double finish_time);
- virtual void didFail(WebKit::WebURLLoader* loader,
- const WebKit::WebURLError& error);
-
- // Returns the number of bytes currently available for synchronous reading
- // in the loader.
- int32_t buffer_size() const { return buffer_.size(); }
-
- private:
- // Check that |callback| is valid (only non-blocking operation is supported)
- // and that no callback is already pending. Returns |PP_OK| if okay, else
- // |PP_ERROR_...| to be returned to the plugin.
- int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
-
- // Sets up |callback| as the pending callback. This should only be called once
- // it is certain that |PP_OK_COMPLETIONPENDING| will be returned.
- void RegisterCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
-
- void RunCallback(int32_t result);
-
- size_t FillUserBuffer();
-
- // Converts a WebURLResponse to a URLResponseInfo and saves it.
- void SaveResponse(const WebKit::WebURLResponse& response);
-
- // Calls the status_callback_ (if any) with the current upload and download
- // progress. Call this function if you update any of these values to
- // synchronize an out-of-process plugin's state.
- void UpdateStatus();
-
- // Returns true if the plugin has requested we record download or upload
- // progress. When false, we don't need to update the counters. We go out of
- // our way not to allow access to this information unless it's requested,
- // even when it would be easier just to return it and not check, so that
- // plugins don't depend on access without setting the flag.
- bool RecordDownloadProgress() const;
- bool RecordUploadProgress() const;
-
- // Calls SetDefersLoading on the current load. This encapsulates the logic
- // differences between document loads and regular ones.
- void SetDefersLoading(bool defers_loading);
-
- void FinishLoading(int32_t done_status);
-
- // If true, then the plugin instance is a full-frame plugin and we're just
- // wrapping the main document's loader (i.e. loader_ is null).
- bool main_document_loader_;
-
- // Keep a copy of the request data. We specifically do this instead of
- // keeping a reference to the request resource, because the plugin might
- // change the request info resource out from under us.
- ::ppapi::URLRequestInfoData request_data_;
-
- // The loader associated with this request. MAY BE NULL.
- //
- // This will be NULL if the load hasn't been opened yet, or if this is a main
- // document loader (when registered as a mime type). Therefore, you should
- // always NULL check this value before using it. In the case of a main
- // document load, you would call the functions on the document to cancel the
- // load, etc. since there is no loader.
- scoped_ptr<WebKit::WebURLLoader> loader_;
-
- scoped_refptr< ::ppapi::TrackedCallback> pending_callback_;
- std::deque<char> buffer_;
- int64_t bytes_sent_;
- int64_t total_bytes_to_be_sent_;
- int64_t bytes_received_;
- int64_t total_bytes_to_be_received_;
- char* user_buffer_;
- size_t user_buffer_size_;
- int32_t done_status_;
- bool is_streaming_to_file_;
- bool is_asynchronous_load_suspended_;
-
- bool has_universal_access_;
-
- PP_URLLoaderTrusted_StatusCallback status_callback_;
-
- // When the response info is received, this stores the data. The
- // ScopedResource maintains the reference to the file ref (if any) in the
- // data object so we don't forget to dereference it.
- scoped_ptr< ::ppapi::URLResponseInfoData > response_info_;
- ::ppapi::ScopedPPResource response_info_file_ref_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index f091a38..94e6e83 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -21,7 +21,6 @@
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
#include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
#include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
-#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "webkit/plugins/ppapi/ppb_x509_certificate_private_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
@@ -84,6 +83,13 @@ PP_Resource ResourceCreationImpl::CreateFileRef(
return res ? res->GetReference() : 0;
}
+PP_Resource ResourceCreationImpl::CreateFileRef(
+ const ::ppapi::PPB_FileRef_CreateInfo& serialized) {
+ // When we're in-process, the host resource in the create info *is* the
+ // resource, so we don't need to do anything.
+ return serialized.resource.host_resource();
+}
+
PP_Resource ResourceCreationImpl::CreateFlashDeviceID(PP_Instance instance) {
return 0; // Not supported in-process.
}
@@ -233,10 +239,6 @@ PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) {
return 0; // Not supported in-process.
}
-PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) {
- return (new PPB_URLLoader_Impl(instance, false))->GetReference();
-}
-
PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) {
return 0; // VideoCapture is not supported in process now.
}
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index da48bc8..9ccc4be 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -41,6 +41,8 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl
virtual PP_Resource CreateFileRef(PP_Instance instance,
PP_Resource file_system,
const char* path) OVERRIDE;
+ virtual PP_Resource CreateFileRef(
+ const ::ppapi::PPB_FileRef_CreateInfo& serialized) OVERRIDE;
virtual PP_Resource CreateFlashDeviceID(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateFlashFontFile(
PP_Instance instance,
@@ -110,7 +112,6 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl
PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE;
- virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoder(
PP_Instance instance,
diff --git a/webkit/plugins/ppapi/url_response_info_util.h b/webkit/plugins/ppapi/url_response_info_util.h
index ff805db..346ede6 100644
--- a/webkit/plugins/ppapi/url_response_info_util.h
+++ b/webkit/plugins/ppapi/url_response_info_util.h
@@ -7,6 +7,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/shared_impl/url_response_info_data.h"
+#include "webkit/plugins/webkit_plugins_export.h"
namespace WebKit {
class WebURLResponse;
@@ -18,7 +19,7 @@ namespace ppapi {
// The returned object will have one plugin reference to the "body_as_file_ref"
// if it's non-null. It's expected that the result of this function will be
// passed to the plugin.
-::ppapi::URLResponseInfoData DataFromWebURLResponse(
+WEBKIT_PLUGINS_EXPORT ::ppapi::URLResponseInfoData DataFromWebURLResponse(
PP_Instance pp_instance,
const WebKit::WebURLResponse& response);
diff --git a/webkit/plugins/webkit_plugins.gypi b/webkit/plugins/webkit_plugins.gypi
index 69a52b7..f14a1f5 100644
--- a/webkit/plugins/webkit_plugins.gypi
+++ b/webkit/plugins/webkit_plugins.gypi
@@ -181,8 +181,6 @@
'../plugins/ppapi/ppb_tcp_socket_private_impl.h',
'../plugins/ppapi/ppb_uma_private_impl.cc',
'../plugins/ppapi/ppb_uma_private_impl.h',
- '../plugins/ppapi/ppb_url_loader_impl.cc',
- '../plugins/ppapi/ppb_url_loader_impl.h',
'../plugins/ppapi/ppb_var_deprecated_impl.cc',
'../plugins/ppapi/ppb_var_deprecated_impl.h',
'../plugins/ppapi/ppb_video_decoder_impl.cc',