diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 23:04:24 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 23:04:24 +0000 |
commit | ceadc397e01759ce1fb876f35357427766b70c2a (patch) | |
tree | 2d2ba77bcc48065140a88545801415574241fb2f /ppapi/thunk/ppb_url_request_info_thunk.cc | |
parent | 9af75df68c6103002f27298dee8e53574457a1ab (diff) | |
download | chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.zip chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.tar.gz chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.tar.bz2 |
Move fullscreen and instance to the new thunk system.
This takes it in a slightl different direction. Rather than maintaining separate
APIs, proxies, and impls for each interface, I think smaller instance-related
interfaces can just be added on the Instance_API. There's no need for binary
compatibility here and it saves a whole lot of boilerplate. Although
PPB_Instance_API will get large, this isn't necessarily bad, and is probably
more clear than the alternative (it saves a whole lot of code).
This means that the interface IDs no longer have a 1:1 mapping to interface
names. But this was already going to be the case when we have multiple versions
of different interfaces. Currently the code in dispatcher to deal with this is
a bit weird, because of the way the mapping works. Long term, I'm going to
change these from interface IDs in the proxy to API IDs in the thunk layer.
This adds APIs and thunks for several other interfaces without implementing
them yet (this patch was getting too large): URL loading and surface 3D.
TEST=ppapi tests
BUG=none
Review URL: http://codereview.chromium.org/7058015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk/ppb_url_request_info_thunk.cc')
-rw-r--r-- | ppapi/thunk/ppb_url_request_info_thunk.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/ppapi/thunk/ppb_url_request_info_thunk.cc b/ppapi/thunk/ppb_url_request_info_thunk.cc new file mode 100644 index 0000000..5c99d18 --- /dev/null +++ b/ppapi/thunk/ppb_url_request_info_thunk.cc @@ -0,0 +1,72 @@ +// 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. + +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateURLRequestInfo(instance); +} + +PP_Bool IsURLRequestInfo(PP_Resource resource) { + EnterResource<PPB_URLRequestInfo_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Bool SetProperty(PP_Resource request, + PP_URLRequestProperty property, + PP_Var var) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->SetProperty(property, var); +} + +PP_Bool AppendDataToBody(PP_Resource request, + const void* data, uint32_t len) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->AppendDataToBody(data, len); +} + +PP_Bool AppendFileToBody(PP_Resource request, + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->AppendFileToBody(file_ref, start_offset, + number_of_bytes, + expected_last_modified_time); +} + +const PPB_URLRequestInfo g_ppb_url_request_info_thunk = { + &Create, + &IsURLRequestInfo, + &SetProperty, + &AppendDataToBody, + &AppendFileToBody +}; + +} // namespace + +const PPB_URLRequestInfo* GetPPB_URLRequestInfo_Thunk() { + return &g_ppb_url_request_info_thunk; +} + +} // namespace thunk +} // namespace ppapi |