Commit 378752b3 authored by asargent@chromium.org's avatar asargent@chromium.org

Revert 194613 "Pepper: Autogenerate thunk for PPB_URL_Loader."

> Pepper: Autogenerate thunk for PPB_URL_Loader.
> 
> This requires another annotation:
>   "always_set_output_parameters"
> 
> This annotation ensures that the thunk implementation will zero-out the value of all output parameters on failure.
> 
> Tested:
>   Built chrome and browser_tests.
> 
> BUG=
> 
> Review URL: https://codereview.chromium.org/14007010

TBR=teravest@chromium.org

Review URL: https://codereview.chromium.org/14195008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194617 0039d316-1c4b-4281-b951-d872f2087c98
parent 3eeddd89
......@@ -90,7 +90,6 @@ 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);
......
......@@ -8,8 +8,6 @@
* URLs.
*/
[generate_thunk]
label Chrome {
M14 = 1.0
};
......@@ -118,7 +116,6 @@ 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,
......@@ -143,7 +140,6 @@ 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,
......
......@@ -5,8 +5,6 @@
/* URL loader trusted interfaces. */
[generate_thunk]
label Chrome {
M14 = 0.3
};
......
......@@ -214,30 +214,6 @@ 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.
......@@ -277,40 +253,42 @@ 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()'
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
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 member.GetProperty('always_set_output_parameters'):
if not out_params:
body += 'if (enter.succeeded())\n'
body += ' %s;' % invocation
else:
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, param)
body += '\nmemset(%s, 0, sizeof(%s));' % param
meta.AddBuiltinInclude('string.h')
else:
body += 'if (enter.succeeded())\n'
body += ' %s;' % invocation
else:
value = member.GetProperty('on_failure')
......@@ -321,18 +299,9 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, None, meta)
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
body += 'if (enter.failed())\n'
body += ' return %s;\n' % value
body += 'return %s;' % invocation
return body
......
......@@ -235,7 +235,6 @@
'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',
......
......@@ -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 RegisterStatusCallback(
virtual void SetStatusCallback(
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::RegisterStatusCallback(
void URLLoader::SetStatusCallback(
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()->RegisterStatusCallback(&UpdateResourceLoadStatus);
enter.object()->SetStatusCallback(&UpdateResourceLoadStatus);
else
NOTREACHED(); // Only called internally, resource should be valid.
}
......
......@@ -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 Wed Apr 17 10:03:38 2013.
// From ppb_gamepad.idl modified Mon Apr 1 08:24:03 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(data));
memset(data, 0, sizeof(struct PP_GamepadsSampleData));
}
const PPB_Gamepad_1_0 g_ppb_gamepad_thunk_1_0 = {
......
......@@ -47,8 +47,7 @@ class PPB_URLLoader_API {
// Trusted API.
virtual void GrantUniversalAccess() = 0;
virtual void RegisterStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) = 0;
virtual void SetStatusCallback(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
......
......@@ -2,27 +2,22 @@
// 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/ppb_instance_api.h"
#include "ppapi/thunk/thunk.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;
......@@ -30,25 +25,22 @@ PP_Resource Create(PP_Instance instance) {
}
PP_Bool IsURLLoader(PP_Resource resource) {
VLOG(4) << "PPB_URLLoader::IsURLLoader()";
EnterResource<PPB_URLLoader_API> enter(resource, false);
EnterURLLoader enter(resource, false);
return PP_FromBool(enter.succeeded());
}
int32_t Open(PP_Resource loader,
PP_Resource request_info,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_URLLoader::Open()";
EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
PP_Resource request_id,
PP_CompletionCallback callback) {
EnterURLLoader enter(loader, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->Open(request_info, enter.callback()));
return enter.SetResult(enter.object()->Open(request_id, enter.callback()));
}
int32_t FollowRedirect(PP_Resource loader,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_URLLoader::FollowRedirect()";
EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
PP_CompletionCallback callback) {
EnterURLLoader enter(loader, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->FollowRedirect(enter.callback()));
......@@ -57,24 +49,23 @@ int32_t FollowRedirect(PP_Resource loader,
PP_Bool GetUploadProgress(PP_Resource loader,
int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent) {
VLOG(4) << "PPB_URLLoader::GetUploadProgress()";
EnterResource<PPB_URLLoader_API> enter(loader, true);
EnterURLLoader enter(loader, true);
if (enter.failed()) {
memset(bytes_sent, 0, sizeof(bytes_sent));
memset(total_bytes_to_be_sent, 0, sizeof(total_bytes_to_be_sent));
*bytes_sent = 0;
*total_bytes_to_be_sent = 0;
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) {
VLOG(4) << "PPB_URLLoader::GetDownloadProgress()";
EnterResource<PPB_URLLoader_API> enter(loader, true);
EnterURLLoader enter(loader, true);
if (enter.failed()) {
memset(bytes_received, 0, sizeof(bytes_received));
memset(total_bytes_to_be_received, 0, sizeof(total_bytes_to_be_received));
*bytes_received = 0;
*total_bytes_to_be_received = 0;
return PP_FALSE;
}
return enter.object()->GetDownloadProgress(bytes_received,
......@@ -82,8 +73,7 @@ PP_Bool GetDownloadProgress(PP_Resource loader,
}
PP_Resource GetResponseInfo(PP_Resource loader) {
VLOG(4) << "PPB_URLLoader::GetResponseInfo()";
EnterResource<PPB_URLLoader_API> enter(loader, true);
EnterURLLoader enter(loader, true);
if (enter.failed())
return 0;
return enter.object()->GetResponseInfo();
......@@ -92,34 +82,43 @@ PP_Resource GetResponseInfo(PP_Resource loader) {
int32_t ReadResponseBody(PP_Resource loader,
void* buffer,
int32_t bytes_to_read,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_URLLoader::ReadResponseBody()";
EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
PP_CompletionCallback callback) {
EnterURLLoader 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,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_URLLoader::FinishStreamingToFile()";
EnterResource<PPB_URLLoader_API> enter(loader, callback, true);
PP_CompletionCallback callback) {
EnterURLLoader 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) {
VLOG(4) << "PPB_URLLoader::Close()";
EnterResource<PPB_URLLoader_API> enter(loader, true);
EnterURLLoader enter(loader, true);
if (enter.succeeded())
enter.object()->Close();
}
const PPB_URLLoader_1_0 g_ppb_urlloader_thunk_1_0 = {
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 = {
&Create,
&IsURLLoader,
&Open,
......@@ -132,10 +131,19 @@ const PPB_URLLoader_1_0 g_ppb_urlloader_thunk_1_0 = {
&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_1_0;
return &g_ppb_urlloader_thunk;
}
const PPB_URLLoaderTrusted_0_3* GetPPB_URLLoaderTrusted_0_3_Thunk() {
return &g_ppb_urlloader_trusted_thunk;
}
} // namespace thunk
......
// 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
......@@ -311,7 +311,7 @@ void PPB_URLLoader_Impl::GrantUniversalAccess() {
has_universal_access_ = true;
}
void PPB_URLLoader_Impl::RegisterStatusCallback(
void PPB_URLLoader_Impl::SetStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) {
status_callback_ = cb;
}
......
......@@ -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 RegisterStatusCallback(
virtual void SetStatusCallback(
PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
virtual bool GetResponseInfoData(
::ppapi::URLResponseInfoData* data) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment