summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-29 15:45:07 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-29 15:45:07 +0000
commit90c4f7c8004e10e66f585b9cc1c4fe3a48651bbf (patch)
tree43075ead29177b4a015f2f7968a6d8fc1f8a4d59 /ppapi/proxy
parent93b4301bca3f780a23779c52214a1de31d382f7b (diff)
downloadchromium_src-90c4f7c8004e10e66f585b9cc1c4fe3a48651bbf.zip
chromium_src-90c4f7c8004e10e66f585b9cc1c4fe3a48651bbf.tar.gz
chromium_src-90c4f7c8004e10e66f585b9cc1c4fe3a48651bbf.tar.bz2
Hook up status notifications in the Proxy.
TEST=manual BUG=none Review URL: http://codereview.chromium.org/6724042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.cc51
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.h16
-rw-r--r--ppapi/proxy/ppp_instance_proxy.cc14
3 files changed, 74 insertions, 7 deletions
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc
index 7f06b46..b338605 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.cc
+++ b/ppapi/proxy/ppb_url_loader_proxy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -296,6 +296,27 @@ InterfaceProxy* CreateURLLoaderTrustedProxy(Dispatcher* dispatcher,
return new PPB_URLLoaderTrusted_Proxy(dispatcher, target_interface);
}
+// Called in the renderer when the byte counts have changed. We send a message
+// to the plugin to synchronize its counts so it can respond to status polls
+// from the plugin.
+void UpdateResourceLoadStatus(PP_Instance pp_instance,
+ PP_Resource pp_resource,
+ int64 bytes_sent,
+ int64 total_bytes_to_be_sent,
+ int64 bytes_received,
+ int64 total_bytes_to_be_received) {
+ Dispatcher* dispatcher = HostDispatcher::GetForInstance(pp_instance);
+ PPBURLLoader_UpdateProgress_Params params;
+ params.instance = pp_instance;
+ params.resource.SetHostResource(pp_instance, pp_resource);
+ params.bytes_sent = bytes_sent;
+ params.total_bytes_to_be_sent = total_bytes_to_be_sent;
+ params.bytes_received = bytes_received;
+ params.total_bytes_to_be_received = total_bytes_to_be_received;
+ dispatcher->Send(new PpapiMsg_PPBURLLoader_UpdateProgress(
+ INTERFACE_ID_PPB_URL_LOADER, params));
+}
+
} // namespace
// PPB_URLLoader_Proxy ---------------------------------------------------------
@@ -308,7 +329,8 @@ struct PPB_URLLoader_Proxy::ReadCallbackInfo {
PPB_URLLoader_Proxy::PPB_URLLoader_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ host_urlloader_trusted_interface_(NULL) {
}
PPB_URLLoader_Proxy::~PPB_URLLoader_Proxy() {
@@ -361,9 +383,17 @@ bool PPB_URLLoader_Proxy::OnMessageReceived(const IPC::Message& msg) {
return handled;
}
+void PPB_URLLoader_Proxy::PrepareURLLoaderForSendingToPlugin(
+ PP_Resource resource) {
+ // So the plugin can query load status, we need to register our status
+ // callback before sending any URLLoader to the plugin.
+ RegisterStatusCallback(resource);
+}
+
void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance,
HostResource* result) {
result->SetHostResource(instance, ppb_url_loader_target()->Create(instance));
+ PrepareURLLoaderForSendingToPlugin(result->host_resource());
}
void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader,
@@ -490,6 +520,23 @@ void PPB_URLLoader_Proxy::OnMsgReadResponseBodyAck(
PP_RunCompletionCallback(&temp_callback, result);
}
+void PPB_URLLoader_Proxy::RegisterStatusCallback(PP_Resource resource) {
+ DCHECK(!dispatcher()->IsPlugin());
+ if (!host_urlloader_trusted_interface_) {
+ host_urlloader_trusted_interface_ =
+ static_cast<const PPB_URLLoaderTrusted*>(
+ dispatcher()->GetLocalInterface(PPB_URLLOADERTRUSTED_INTERFACE));
+ if (!host_urlloader_trusted_interface_) {
+ NOTREACHED();
+ return;
+ }
+ }
+
+ host_urlloader_trusted_interface_->RegisterStatusCallback(
+ resource,
+ &UpdateResourceLoadStatus);
+}
+
void PPB_URLLoader_Proxy::OnReadCallback(int32_t result,
ReadCallbackInfo* info) {
int32_t bytes_read = 0;
diff --git a/ppapi/proxy/ppb_url_loader_proxy.h b/ppapi/proxy/ppb_url_loader_proxy.h
index 523488b..b2a57e5 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.h
+++ b/ppapi/proxy/ppb_url_loader_proxy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -45,6 +45,12 @@ class PPB_URLLoader_Proxy : public InterfaceProxy {
// InterfaceProxy implementation.
virtual bool OnMessageReceived(const IPC::Message& msg);
+ // URLLoader objects are sent from places other than just URLLoader.Create,
+ // in particular when doing a full-frame plugin. This function does the
+ // necessary setup in the host before the resource is sent. Call this any
+ // time you're sending a new URLLoader that the plugin hasn't seen yet.
+ void PrepareURLLoaderForSendingToPlugin(PP_Resource resource);
+
private:
// Data associated with callbacks for ReadResponseBody.
struct ReadCallbackInfo;
@@ -72,12 +78,20 @@ class PPB_URLLoader_Proxy : public InterfaceProxy {
int32_t result,
const std::string& data);
+ // Hooks the given URLLoader resource up in the host for receiving download
+ // and upload status callbacks.
+ void RegisterStatusCallback(PP_Resource resource);
+
// Handles callbacks for read complete messages. Takes ownership of the info
// pointer.
void OnReadCallback(int32_t result, ReadCallbackInfo* info);
CompletionCallbackFactory<PPB_URLLoader_Proxy,
ProxyNonThreadSafeRefCount> callback_factory_;
+
+ // Valid only in the host, this lazily-initialized pointer indicates the
+ // URLLoaderTrusted interface.
+ const PPB_URLLoaderTrusted* host_urlloader_trusted_interface_;
};
class PPB_URLLoaderTrusted_Proxy : public InterfaceProxy {
diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc
index 61c97f4..bb0ad79 100644
--- a/ppapi/proxy/ppp_instance_proxy.cc
+++ b/ppapi/proxy/ppp_instance_proxy.cc
@@ -73,12 +73,18 @@ PP_Bool HandleInputEvent(PP_Instance instance,
PP_Bool HandleDocumentLoad(PP_Instance instance,
PP_Resource url_loader) {
PP_Bool result = PP_FALSE;
+ HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
+
+ // Set up the URLLoader for proxying.
+
+ PPB_URLLoader_Proxy* url_loader_proxy = static_cast<PPB_URLLoader_Proxy*>(
+ dispatcher->GetOrCreatePPBInterfaceProxy(INTERFACE_ID_PPB_URL_LOADER));
+ url_loader_proxy->PrepareURLLoaderForSendingToPlugin(url_loader);
+
HostResource serialized_loader;
serialized_loader.SetHostResource(instance, url_loader);
- HostDispatcher::GetForInstance(instance)->Send(
- new PpapiMsg_PPPInstance_HandleDocumentLoad(INTERFACE_ID_PPP_INSTANCE,
- instance, serialized_loader,
- &result));
+ dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
+ INTERFACE_ID_PPP_INSTANCE, instance, serialized_loader, &result));
return result;
}