summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/api/ppb_gamepad.idl1
-rw-r--r--ppapi/api/ppb_url_loader.idl4
-rw-r--r--ppapi/api/trusted/ppb_url_loader_trusted.idl2
-rwxr-xr-xppapi/generators/idl_thunk.py79
-rw-r--r--ppapi/ppapi_shared.gypi1
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.cc6
-rw-r--r--ppapi/thunk/ppb_gamepad_thunk.cc4
-rw-r--r--ppapi/thunk/ppb_url_loader_api.h3
-rw-r--r--ppapi/thunk/ppb_url_loader_thunk.cc94
-rw-r--r--ppapi/thunk/ppb_url_loader_trusted_thunk.cc48
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h2
12 files changed, 163 insertions, 83 deletions
diff --git a/ppapi/api/ppb_gamepad.idl b/ppapi/api/ppb_gamepad.idl
index c3d0652..1552fd6 100644
--- a/ppapi/api/ppb_gamepad.idl
+++ b/ppapi/api/ppb_gamepad.idl
@@ -90,6 +90,7 @@ interface PPB_Gamepad {
/**
* Samples the current state of the available gamepads.
*/
+ [always_set_output_parameters]
void Sample(
[in] PP_Instance instance,
[out] PP_GamepadsSampleData data);
diff --git a/ppapi/api/ppb_url_loader.idl b/ppapi/api/ppb_url_loader.idl
index d6076bb..6e1a271d 100644
--- a/ppapi/api/ppb_url_loader.idl
+++ b/ppapi/api/ppb_url_loader.idl
@@ -8,6 +8,8 @@
* URLs.
*/
+[generate_thunk]
+
label Chrome {
M14 = 1.0
};
@@ -116,6 +118,7 @@ interface PPB_URLLoader {
* @return <code>PP_TRUE</code> if the upload progress is available,
* <code>PP_FALSE</code> if it is not available.
*/
+ [always_set_output_parameters]
PP_Bool GetUploadProgress(
[in] PP_Resource loader,
[out] int64_t bytes_sent,
@@ -140,6 +143,7 @@ interface PPB_URLLoader {
* @return <code>PP_TRUE</code> if the download progress is available,
* <code>PP_FALSE</code> if it is not available.
*/
+ [always_set_output_parameters]
PP_Bool GetDownloadProgress(
[in] PP_Resource loader,
[out] int64_t bytes_received,
diff --git a/ppapi/api/trusted/ppb_url_loader_trusted.idl b/ppapi/api/trusted/ppb_url_loader_trusted.idl
index 19156f4..bb60291 100644
--- a/ppapi/api/trusted/ppb_url_loader_trusted.idl
+++ b/ppapi/api/trusted/ppb_url_loader_trusted.idl
@@ -5,6 +5,8 @@
/* URL loader trusted interfaces. */
+[generate_thunk]
+
label Chrome {
M14 = 0.3
};
diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py
index 6018753..aa28e9c 100755
--- a/ppapi/generators/idl_thunk.py
+++ b/ppapi/generators/idl_thunk.py
@@ -214,6 +214,30 @@ def _MakeCreateMemberBody(interface, member, args):
return body
+def _GetOutputParams(member, release):
+ """Returns output parameters (and their types) for a member function.
+
+ Args:
+ member - IDLNode for the member function
+ release - Release to get output parameters for
+ Returns:
+ A list of name strings for all output parameters of the member
+ function.
+ """
+ out_params = []
+ callnode = member.GetOneOf('Callspec')
+ if callnode:
+ cgen = CGen()
+ for param in callnode.GetListOf('Param'):
+ mode = cgen.GetParamMode(param)
+ if mode == 'out':
+ # We use the 'store' mode when getting the parameter type, since we
+ # need to call sizeof() for memset().
+ _, pname, _, _ = cgen.GetComponents(param, release, 'store')
+ out_params.append(pname)
+ return out_params
+
+
def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
include_version, meta):
"""Returns the body of a typical function.
@@ -253,42 +277,40 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
call_arglist)
handle_errors = not (member.GetProperty('report_errors') == 'False')
+ out_params = _GetOutputParams(member, release)
if is_callback_func:
+ # TODO(teravest): Reduce code duplication below.
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, args[len(args) - 1][1], meta)
- body += 'if (enter.failed())\n'
value = member.GetProperty('on_failure')
if value is None:
value = 'enter.retval()'
- body += ' return %s;\n' % value
- body += 'return enter.SetResult(%s);' % invocation
+ if member.GetProperty('always_set_output_parameters'):
+ body += 'if (enter.failed()) {\n'
+ for param in out_params:
+ body += ' memset(%s, 0, sizeof(%s));\n' % (param, param)
+ body += ' return %s;\n' % value
+ body += '}\n'
+ body += 'return enter.SetResult(%s);' % invocation
+ meta.AddBuiltinInclude('string.h')
+ else:
+ body += 'if (enter.failed())\n'
+ body += ' return %s;\n' % value
+ body += 'return enter.SetResult(%s);' % invocation
elif rtype == 'void':
- # On failure, zero out all output parameters.
- out_params = []
- callnode = member.GetOneOf('Callspec')
- if callnode:
- cgen = CGen()
- for param in callnode.GetListOf('Param'):
- mode = cgen.GetParamMode(param)
- if mode == 'out':
- # We use the 'store' mode when getting the parameter type, since we
- # need to call sizeof() for memset().
- ptype, pname, _, _ = cgen.GetComponents(param, release, 'store')
- out_params.append((pname, ptype))
-
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, None, meta)
- if not out_params:
- body += 'if (enter.succeeded())\n'
- body += ' %s;' % invocation
- else:
+ if member.GetProperty('always_set_output_parameters'):
body += 'if (enter.succeeded()) {\n'
body += ' %s;\n' % invocation
body += ' return;\n'
body += '}'
for param in out_params:
- body += '\nmemset(%s, 0, sizeof(%s));' % param
+ body += '\nmemset(%s, 0, sizeof(%s));' % (param, param)
meta.AddBuiltinInclude('string.h')
+ else:
+ body += 'if (enter.succeeded())\n'
+ body += ' %s;' % invocation
else:
value = member.GetProperty('on_failure')
@@ -299,9 +321,18 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, None, meta)
- body += 'if (enter.failed())\n'
- body += ' return %s;\n' % value
- body += 'return %s;' % invocation
+ if member.GetProperty('always_set_output_parameters'):
+ body += 'if (enter.failed()) {\n'
+ for param in out_params:
+ body += ' memset(%s, 0, sizeof(%s));\n' % (param, param)
+ body += ' return %s;\n' % value
+ body += '}\n'
+ body += 'return %s;' % invocation
+ meta.AddBuiltinInclude('string.h')
+ else:
+ body += 'if (enter.failed())\n'
+ body += ' return %s;\n' % value
+ body += 'return %s;' % invocation
return body
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 6042294..880f5cd 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -235,6 +235,7 @@
'thunk/ppb_udp_socket_private_thunk.cc',
'thunk/ppb_url_loader_api.h',
'thunk/ppb_url_loader_thunk.cc',
+ 'thunk/ppb_url_loader_trusted_thunk.cc',
'thunk/ppb_url_request_info_api.h',
'thunk/ppb_url_request_info_thunk.cc',
'thunk/ppb_url_response_info_api.h',
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc
index 3293516..60cca40 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.cc
+++ b/ppapi/proxy/ppb_url_loader_proxy.cc
@@ -112,7 +112,7 @@ class URLLoader : public Resource, public PPB_URLLoader_API {
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void GrantUniversalAccess() OVERRIDE;
- virtual void SetStatusCallback(
+ virtual void RegisterStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
virtual bool GetResponseInfoData(URLResponseInfoData* data) OVERRIDE;
@@ -324,7 +324,7 @@ void URLLoader::GrantUniversalAccess() {
API_ID_PPB_URL_LOADER, host_resource()));
}
-void URLLoader::SetStatusCallback(
+void URLLoader::RegisterStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) {
// Not implemented in the proxied version, this is for implementing the
// proxy itself in the host.
@@ -467,7 +467,7 @@ void PPB_URLLoader_Proxy::PrepareURLLoaderForSendingToPlugin(
// callback before sending any URLLoader to the plugin.
EnterResourceNoLock<PPB_URLLoader_API> enter(resource, false);
if (enter.succeeded())
- enter.object()->SetStatusCallback(&UpdateResourceLoadStatus);
+ enter.object()->RegisterStatusCallback(&UpdateResourceLoadStatus);
else
NOTREACHED(); // Only called internally, resource should be valid.
}
diff --git a/ppapi/thunk/ppb_gamepad_thunk.cc b/ppapi/thunk/ppb_gamepad_thunk.cc
index 40ac32f..eeeb1de 100644
--- a/ppapi/thunk/ppb_gamepad_thunk.cc
+++ b/ppapi/thunk/ppb_gamepad_thunk.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// From ppb_gamepad.idl modified Mon Apr 1 08:24:03 2013.
+// From ppb_gamepad.idl modified Wed Apr 17 10:03:38 2013.
#include <string.h>
@@ -27,7 +27,7 @@ void Sample(PP_Instance instance, struct PP_GamepadsSampleData* data) {
enter.functions()->Sample(instance, data);
return;
}
- memset(data, 0, sizeof(struct PP_GamepadsSampleData));
+ memset(data, 0, sizeof(data));
}
const PPB_Gamepad_1_0 g_ppb_gamepad_thunk_1_0 = {
diff --git a/ppapi/thunk/ppb_url_loader_api.h b/ppapi/thunk/ppb_url_loader_api.h
index 0fe8e04..00d4690 100644
--- a/ppapi/thunk/ppb_url_loader_api.h
+++ b/ppapi/thunk/ppb_url_loader_api.h
@@ -47,7 +47,8 @@ class PPB_URLLoader_API {
// Trusted API.
virtual void GrantUniversalAccess() = 0;
- virtual void SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb) = 0;
+ virtual void RegisterStatusCallback(
+ PP_URLLoaderTrusted_StatusCallback cb) = 0;
// Internal function. This will fill in the given response info data and
// return true on sucesss. If the dowbload was to a file, there will be one
diff --git a/ppapi/thunk/ppb_url_loader_thunk.cc b/ppapi/thunk/ppb_url_loader_thunk.cc
index 23113cd..fc38023 100644
--- a/ppapi/thunk/ppb_url_loader_thunk.cc
+++ b/ppapi/thunk/ppb_url_loader_thunk.cc
@@ -2,22 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// From ppb_url_loader.idl modified Wed Apr 17 10:03:38 2013.
+
+#include <string.h>
+
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/ppb_url_loader_api.h"
#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace thunk {
namespace {
-typedef EnterResource<PPB_URLLoader_API> EnterURLLoader;
-
PP_Resource Create(PP_Instance instance) {
+ VLOG(4) << "PPB_URLLoader::Create()";
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
@@ -25,22 +30,25 @@ PP_Resource Create(PP_Instance instance) {
}
PP_Bool IsURLLoader(PP_Resource resource) {
- EnterURLLoader enter(resource, false);
+ VLOG(4) << "PPB_URLLoader::IsURLLoader()";
+ EnterResource<PPB_URLLoader_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
int32_t Open(PP_Resource loader,
- PP_Resource request_id,
- PP_CompletionCallback callback) {
- EnterURLLoader enter(loader, callback, true);
+ PP_Resource request_info,
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_URLLoader::Open()";
+ EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
if (enter.failed())
return enter.retval();
- return enter.SetResult(enter.object()->Open(request_id, enter.callback()));
+ return enter.SetResult(enter.object()->Open(request_info, enter.callback()));
}
int32_t FollowRedirect(PP_Resource loader,
- PP_CompletionCallback callback) {
- EnterURLLoader enter(loader, callback, true);
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_URLLoader::FollowRedirect()";
+ EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->FollowRedirect(enter.callback()));
@@ -49,23 +57,24 @@ int32_t FollowRedirect(PP_Resource loader,
PP_Bool GetUploadProgress(PP_Resource loader,
int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent) {
- EnterURLLoader enter(loader, true);
+ VLOG(4) << "PPB_URLLoader::GetUploadProgress()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed()) {
- *bytes_sent = 0;
- *total_bytes_to_be_sent = 0;
+ memset(bytes_sent, 0, sizeof(bytes_sent));
+ memset(total_bytes_to_be_sent, 0, sizeof(total_bytes_to_be_sent));
return PP_FALSE;
}
- return enter.object()->GetUploadProgress(bytes_sent,
- total_bytes_to_be_sent);
+ return enter.object()->GetUploadProgress(bytes_sent, total_bytes_to_be_sent);
}
PP_Bool GetDownloadProgress(PP_Resource loader,
int64_t* bytes_received,
int64_t* total_bytes_to_be_received) {
- EnterURLLoader enter(loader, true);
+ VLOG(4) << "PPB_URLLoader::GetDownloadProgress()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed()) {
- *bytes_received = 0;
- *total_bytes_to_be_received = 0;
+ memset(bytes_received, 0, sizeof(bytes_received));
+ memset(total_bytes_to_be_received, 0, sizeof(total_bytes_to_be_received));
return PP_FALSE;
}
return enter.object()->GetDownloadProgress(bytes_received,
@@ -73,7 +82,8 @@ PP_Bool GetDownloadProgress(PP_Resource loader,
}
PP_Resource GetResponseInfo(PP_Resource loader) {
- EnterURLLoader enter(loader, true);
+ VLOG(4) << "PPB_URLLoader::GetResponseInfo()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed())
return 0;
return enter.object()->GetResponseInfo();
@@ -82,43 +92,34 @@ PP_Resource GetResponseInfo(PP_Resource loader) {
int32_t ReadResponseBody(PP_Resource loader,
void* buffer,
int32_t bytes_to_read,
- PP_CompletionCallback callback) {
- EnterURLLoader enter(loader, callback, true);
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_URLLoader::ReadResponseBody()";
+ EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
if (enter.failed())
return enter.retval();
- return enter.SetResult(enter.object()->ReadResponseBody(buffer, bytes_to_read,
+ return enter.SetResult(enter.object()->ReadResponseBody(buffer,
+ bytes_to_read,
enter.callback()));
}
int32_t FinishStreamingToFile(PP_Resource loader,
- PP_CompletionCallback callback) {
- EnterURLLoader enter(loader, callback, true);
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_URLLoader::FinishStreamingToFile()";
+ EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
if (enter.failed())
return enter.retval();
- return enter.SetResult(
- enter.object()->FinishStreamingToFile(enter.callback()));
+ return enter.SetResult(enter.object()->FinishStreamingToFile(
+ enter.callback()));
}
void Close(PP_Resource loader) {
- EnterURLLoader enter(loader, true);
+ VLOG(4) << "PPB_URLLoader::Close()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.succeeded())
enter.object()->Close();
}
-void GrantUniversalAccess(PP_Resource loader) {
- EnterURLLoader enter(loader, true);
- if (enter.succeeded())
- enter.object()->GrantUniversalAccess();
-}
-
-void SetStatusCallback(PP_Resource loader,
- PP_URLLoaderTrusted_StatusCallback cb) {
- EnterURLLoader enter(loader, true);
- if (enter.succeeded())
- enter.object()->SetStatusCallback(cb);
-}
-
-const PPB_URLLoader g_ppb_urlloader_thunk = {
+const PPB_URLLoader_1_0 g_ppb_urlloader_thunk_1_0 = {
&Create,
&IsURLLoader,
&Open,
@@ -131,19 +132,10 @@ const PPB_URLLoader g_ppb_urlloader_thunk = {
&Close
};
-const PPB_URLLoaderTrusted g_ppb_urlloader_trusted_thunk = {
- &GrantUniversalAccess,
- &SetStatusCallback
-};
-
} // namespace
const PPB_URLLoader_1_0* GetPPB_URLLoader_1_0_Thunk() {
- return &g_ppb_urlloader_thunk;
-}
-
-const PPB_URLLoaderTrusted_0_3* GetPPB_URLLoaderTrusted_0_3_Thunk() {
- return &g_ppb_urlloader_trusted_thunk;
+ return &g_ppb_urlloader_thunk_1_0;
}
} // namespace thunk
diff --git a/ppapi/thunk/ppb_url_loader_trusted_thunk.cc b/ppapi/thunk/ppb_url_loader_trusted_thunk.cc
new file mode 100644
index 0000000..398c52d
--- /dev/null
+++ b/ppapi/thunk/ppb_url_loader_trusted_thunk.cc
@@ -0,0 +1,48 @@
+// 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.
+
+// From trusted/ppb_url_loader_trusted.idl modified Wed Apr 17 09:21:10 2013.
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_url_loader_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+void GrantUniversalAccess(PP_Resource loader) {
+ VLOG(4) << "PPB_URLLoaderTrusted::GrantUniversalAccess()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
+ if (enter.succeeded())
+ enter.object()->GrantUniversalAccess();
+}
+
+void RegisterStatusCallback(PP_Resource loader,
+ PP_URLLoaderTrusted_StatusCallback cb) {
+ VLOG(4) << "PPB_URLLoaderTrusted::RegisterStatusCallback()";
+ EnterResource<PPB_URLLoader_API> enter(loader, true);
+ if (enter.succeeded())
+ enter.object()->RegisterStatusCallback(cb);
+}
+
+const PPB_URLLoaderTrusted_0_3 g_ppb_urlloadertrusted_thunk_0_3 = {
+ &GrantUniversalAccess,
+ &RegisterStatusCallback
+};
+
+} // namespace
+
+const PPB_URLLoaderTrusted_0_3* GetPPB_URLLoaderTrusted_0_3_Thunk() {
+ return &g_ppb_urlloadertrusted_thunk_0_3;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index ebe08ef..58397b8 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -311,7 +311,7 @@ void PPB_URLLoader_Impl::GrantUniversalAccess() {
has_universal_access_ = true;
}
-void PPB_URLLoader_Impl::SetStatusCallback(
+void PPB_URLLoader_Impl::RegisterStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) {
status_callback_ = cb;
}
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
index 51b9534..bb4ea3a 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h
@@ -61,7 +61,7 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource,
scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void GrantUniversalAccess() OVERRIDE;
- virtual void SetStatusCallback(
+ virtual void RegisterStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
virtual bool GetResponseInfoData(
::ppapi::URLResponseInfoData* data) OVERRIDE;