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 | |
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')
-rw-r--r-- | ppapi/thunk/ppb_fullscreen_thunk.cc | 50 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 41 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_thunk.cc | 84 | ||||
-rw-r--r-- | ppapi/thunk/ppb_pdf_api.h | 24 | ||||
-rw-r--r-- | ppapi/thunk/ppb_surface_3d_api.h | 23 | ||||
-rw-r--r-- | ppapi/thunk/ppb_surface_3d_thunk.cc | 69 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_loader_api.h | 38 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_loader_thunk.cc | 145 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_request_info_api.h | 27 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_request_info_thunk.cc | 72 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_response_info_api.h | 22 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_response_info_thunk.cc | 47 | ||||
-rw-r--r-- | ppapi/thunk/ppb_widget_api.h | 24 | ||||
-rw-r--r-- | ppapi/thunk/ppb_widget_thunk.cc | 62 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 6 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 15 |
16 files changed, 749 insertions, 0 deletions
diff --git a/ppapi/thunk/ppb_fullscreen_thunk.cc b/ppapi/thunk/ppb_fullscreen_thunk.cc new file mode 100644 index 0000000..5cc8cc6 --- /dev/null +++ b/ppapi/thunk/ppb_fullscreen_thunk.cc @@ -0,0 +1,50 @@ +// 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/c/dev/ppb_fullscreen_dev.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsFullscreen(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->IsFullscreen(instance); +} + +PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->SetFullscreen(instance, fullscreen); +} + +PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->GetScreenSize(instance, size); +} + +const PPB_Fullscreen_Dev g_ppb_fullscreen_thunk = { + &IsFullscreen, + &SetFullscreen, + &GetScreenSize +}; + +} // namespace + +const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk() { + return &g_ppb_fullscreen_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h new file mode 100644 index 0000000..a01ac36 --- /dev/null +++ b/ppapi/thunk/ppb_instance_api.h @@ -0,0 +1,41 @@ +// 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. + +#ifndef PPAPI_THUNK_INSTANCE_API_H_ +#define PPAPI_THUNK_INSTANCE_API_H_ + +#include "ppapi/c/ppb_instance.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/private/ppb_instance_private.h" +#include "ppapi/proxy/interface_id.h" + +namespace ppapi { +namespace thunk { + +class PPB_Instance_FunctionAPI { + public: + static const ::pp::proxy::InterfaceID interface_id = + ::pp::proxy::INTERFACE_ID_PPB_INSTANCE; + + virtual PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) = 0; + virtual PP_Bool IsFullFrame(PP_Instance instance) = 0; + + // InstancePrivate. + virtual PP_Var GetWindowObject(PP_Instance instance) = 0; + virtual PP_Var GetOwnerElementObject(PP_Instance instance) = 0; + virtual PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) = 0; + + // Fullscreen. + virtual PP_Bool IsFullscreen(PP_Instance instance) = 0; + virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) = 0; + virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_INSTANCE_API_H_ diff --git a/ppapi/thunk/ppb_instance_thunk.cc b/ppapi/thunk/ppb_instance_thunk.cc new file mode 100644 index 0000000..025e3e0 --- /dev/null +++ b/ppapi/thunk/ppb_instance_thunk.cc @@ -0,0 +1,84 @@ +// 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_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Var GetWindowObject(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetWindowObject(instance); +} + +PP_Var GetOwnerElementObject(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetOwnerElementObject(instance); +} + +PP_Bool BindGraphics(PP_Instance instance, PP_Resource graphics_id) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->BindGraphics(instance, graphics_id); +} + +PP_Bool IsFullFrame(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->IsFullFrame(instance); +} + +PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->ExecuteScript(instance, script, exception); +} + +const PPB_Instance_0_5 g_ppb_instance_0_5_thunk = { + &BindGraphics, + &IsFullFrame +}; + +const PPB_Instance_0_4 g_ppb_instance_0_4_thunk = { + &GetWindowObject, + &GetOwnerElementObject, + &BindGraphics, + &IsFullFrame, + &ExecuteScript +}; + +const PPB_Instance_Private g_ppb_instance_private_thunk = { + &GetWindowObject, + &GetOwnerElementObject, + &ExecuteScript +}; + +} // namespace + +const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk() { + return &g_ppb_instance_0_4_thunk; +} +const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk() { + return &g_ppb_instance_0_5_thunk; +} +const PPB_Instance_Private* GetPPB_Instance_Private_Thunk() { + return &g_ppb_instance_private_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_pdf_api.h b/ppapi/thunk/ppb_pdf_api.h new file mode 100644 index 0000000..6637376 --- /dev/null +++ b/ppapi/thunk/ppb_pdf_api.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_PDF_API_H_ +#define PPAPI_THUNK_PPB_PDF_API_H_ + +#include "ppapi/c/private/ppb_pdf.h" + +namespace ppapi { +namespace thunk { + +class PPB_PDFFont_API { + private: + virtual bool GetFontTableForPrivateFontFile(PP_Resource font_file, + uint32_t table, + void* output, + uint32_t* output_length) = 0; +} + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK__API_H_ diff --git a/ppapi/thunk/ppb_surface_3d_api.h b/ppapi/thunk/ppb_surface_3d_api.h new file mode 100644 index 0000000..59c6335 --- /dev/null +++ b/ppapi/thunk/ppb_surface_3d_api.h @@ -0,0 +1,23 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_SURFACE_3D_API_H_ +#define PPAPI_THUNK_PPB_SURFACE_3D_API_H_ + +#include "ppapi/c/dev/ppb_surface_3d_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Surface3D_API { + public: + virtual int32_t SetAttrib(int32_t attribute, int32_t value) = 0; + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) = 0; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_SURFACE_3D_API_H_ diff --git a/ppapi/thunk/ppb_surface_3d_thunk.cc b/ppapi/thunk/ppb_surface_3d_thunk.cc new file mode 100644 index 0000000..0c6d9e6 --- /dev/null +++ b/ppapi/thunk/ppb_surface_3d_thunk.cc @@ -0,0 +1,69 @@ +// 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/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_surface_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateSurface3D(instance, config, attrib_list); +} + +PP_Bool IsSurface3D(PP_Resource resource) { + EnterResource<PPB_Surface3D_API> enter(resource, true); + return PP_FromBool(enter.succeeded()); +} + +int32_t SetAttrib(PP_Resource surface, int32_t attribute, int32_t value) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SetAttrib(attribute, value); +} + +int32_t GetAttrib(PP_Resource surface, + int32_t attribute, + int32_t* value) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetAttrib(attribute, value); +} + +int32_t SwapBuffers(PP_Resource surface, + PP_CompletionCallback callback) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SwapBuffers(callback); +} + +const PPB_Surface3D_Dev g_ppb_surface_3d_thunk = { + &Create, + &IsSurface3D, + &SetAttrib, + &GetAttrib, + &SwapBuffers +}; + +} // namespace + +const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk() { + return &g_ppb_surface_3d_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_url_loader_api.h b/ppapi/thunk/ppb_url_loader_api.h new file mode 100644 index 0000000..cd44c26 --- /dev/null +++ b/ppapi/thunk/ppb_url_loader_api.h @@ -0,0 +1,38 @@ +// 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. + +#ifndef PPAPI_THUNK_URL_LOADER_API_H_ +#define PPAPI_THUNK_URL_LOADER_API_H_ + +#include "ppapi/c/ppb_url_loader.h" +#include "ppapi/c/trusted/ppb_url_loader_trusted.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLLoader_API { + public: + virtual int32_t Open(PP_Resource request_id, + PP_CompletionCallback callback) = 0; + virtual int32_t FollowRedirect(PP_CompletionCallback callback) = 0; + virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent) = 0; + virtual PP_Bool GetDownloadProgress(int64_t* bytes_received, + int64_t* total_bytes_to_be_received) = 0; + virtual PP_Resource GetResponseInfo() = 0; + virtual int32_t ReadResponseBody(void* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) = 0; + virtual int32_t FinishStreamingToFile(PP_CompletionCallback callback) = 0; + virtual void Close() = 0; + + // Trusted API. + virtual void GrantUniversalAccess() = 0; + virtual void SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_LOADER_API_H_ diff --git a/ppapi/thunk/ppb_url_loader_thunk.cc b/ppapi/thunk/ppb_url_loader_thunk.cc new file mode 100644 index 0000000..e5c0b5a --- /dev/null +++ b/ppapi/thunk/ppb_url_loader_thunk.cc @@ -0,0 +1,145 @@ +// 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/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_loader_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()->CreateURLLoader(instance); +} + +PP_Bool IsURLLoader(PP_Resource resource) { + 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) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Open(request_id, callback); +} + +int32_t FollowRedirect(PP_Resource loader, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->FollowRedirect(callback); +} + +PP_Bool GetUploadProgress(PP_Resource loader, + int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) { + *bytes_sent = 0; + *total_bytes_to_be_sent = 0; + return PP_FALSE; + } + 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) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) { + *bytes_received = 0; + *total_bytes_to_be_received = 0; + return PP_FALSE; + } + return enter.object()->GetDownloadProgress(bytes_received, + total_bytes_to_be_received); +} + +PP_Resource GetResponseInfo(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return 0; + return enter.object()->GetResponseInfo(); +} + +int32_t ReadResponseBody(PP_Resource loader, + void* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->ReadResponseBody(buffer, bytes_to_read, callback); +} + +int32_t FinishStreamingToFile(PP_Resource loader, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->FinishStreamingToFile(callback); +} + +void Close(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->Close(); +} + +void GrantUniversalAccess(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->GrantUniversalAccess(); +} + +void SetStatusCallback(PP_Resource loader, + PP_URLLoaderTrusted_StatusCallback cb) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->SetStatusCallback(cb); +} + +const PPB_URLLoader g_ppb_urlloader_thunk = { + &Create, + &IsURLLoader, + &Open, + &FollowRedirect, + &GetUploadProgress, + &GetDownloadProgress, + &GetResponseInfo, + &ReadResponseBody, + &FinishStreamingToFile, + &Close +}; + +const PPB_URLLoaderTrusted g_ppb_urlloader_trusted_thunk = { + &GrantUniversalAccess, + &SetStatusCallback +}; + +} // namespace + +const PPB_URLLoader* GetPPB_URLLoader_Thunk() { + return &g_ppb_urlloader_thunk; +} + +const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk() { + return &g_ppb_urlloader_trusted_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_url_request_info_api.h b/ppapi/thunk/ppb_url_request_info_api.h new file mode 100644 index 0000000..46656abf --- /dev/null +++ b/ppapi/thunk/ppb_url_request_info_api.h @@ -0,0 +1,27 @@ +// 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. + +#ifndef PPAPI_THUNK_URL_REQUEST_INFO_API_H_ +#define PPAPI_THUNK_URL_REQUEST_INFO_API_H_ + +#include "ppapi/c/ppb_url_request_info.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLRequestInfo_API { + public: + virtual PP_Bool SetProperty(PP_URLRequestProperty property, + PP_Var var) = 0; + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) = 0; + virtual PP_Bool AppendFileToBody(PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_REQUEST_INFO_API_H_ 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 diff --git a/ppapi/thunk/ppb_url_response_info_api.h b/ppapi/thunk/ppb_url_response_info_api.h new file mode 100644 index 0000000..f62ac48 --- /dev/null +++ b/ppapi/thunk/ppb_url_response_info_api.h @@ -0,0 +1,22 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_URL_RESPONSE_INFO_API_H_ +#define PPAPI_THUNK_PPB_URL_RESPONSE_INFO_API_H_ + +#include "ppapi/c/ppb_url_response_info.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLResponseInfo_API { + public: + virtual PP_Var GetProperty(PP_URLResponseProperty property) = 0; + virtual PP_Resource GetBodyAsFileRef() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_LOADER_API_H_ diff --git a/ppapi/thunk/ppb_url_response_info_thunk.cc b/ppapi/thunk/ppb_url_response_info_thunk.cc new file mode 100644 index 0000000..3fecb936 --- /dev/null +++ b/ppapi/thunk/ppb_url_response_info_thunk.cc @@ -0,0 +1,47 @@ +// 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_response_info_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsURLResponseInfo(PP_Resource resource) { + EnterResource<PPB_URLResponseInfo_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { + EnterResource<PPB_URLResponseInfo_API> enter(response, true); + if (!enter.succeeded()) + return PP_MakeUndefined(); + return enter.object()->GetProperty(property); +} + +PP_Resource GetBodyAsFileRef(PP_Resource response) { + EnterResource<PPB_URLResponseInfo_API> enter(response, true); + if (!enter.succeeded()) + return 0; + return enter.object()->GetBodyAsFileRef(); +} + +const PPB_URLResponseInfo g_ppb_url_response_info_thunk = { + &IsURLResponseInfo, + &GetProperty, + &GetBodyAsFileRef +}; + +} // namespace + +const PPB_URLResponseInfo* GetPPB_URLResponseInfo_Thunk() { + return &g_ppb_url_response_info_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_widget_api.h b/ppapi/thunk/ppb_widget_api.h new file mode 100644 index 0000000..e278f73 --- /dev/null +++ b/ppapi/thunk/ppb_widget_api.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_WIDGET_API_H_ +#define PPAPI_THUNK_PPB_WIDGET_API_H_ + +#include "ppapi/c/dev/ppb_widget_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Widget_API { + public: + virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource image_id) = 0; + virtual PP_Bool HandleEvent(const PP_InputEvent* event) = 0; + virtual PP_Bool GetLocation(PP_Rect* location) = 0; + virtual void SetLocation(const PP_Rect* location) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_WIDGET_API_H_ diff --git a/ppapi/thunk/ppb_widget_thunk.cc b/ppapi/thunk/ppb_widget_thunk.cc new file mode 100644 index 0000000..7834a7a --- /dev/null +++ b/ppapi/thunk/ppb_widget_thunk.cc @@ -0,0 +1,62 @@ +// 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_widget_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsWidget(PP_Resource resource) { + EnterResource<PPB_Widget_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Bool Paint(PP_Resource widget, const PP_Rect* rect, PP_Resource image_id) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->Paint(rect, image_id); +} + +PP_Bool HandleEvent(PP_Resource widget, const PP_InputEvent* event) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->HandleEvent(event); +} + +PP_Bool GetLocation(PP_Resource widget, PP_Rect* location) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->GetLocation(location); +} + +void SetLocation(PP_Resource widget, const PP_Rect* location) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.succeeded()) + enter.object()->SetLocation(location); +} + +const PPB_Widget_Dev g_ppb_widget_thunk = { + &IsWidget, + &Paint, + &HandleEvent, + &GetLocation, + &SetLocation, +}; + +} // namespace + +const PPB_Widget_Dev* GetPPB_Widget_Thunk() { + return &g_ppb_widget_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index cbaf92e..11b532f 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -7,6 +7,7 @@ #include "ppapi/c/dev/ppb_file_chooser_dev.h" #include "ppapi/c/dev/ppb_file_system_dev.h" +#include "ppapi/c/dev/ppb_graphics_3d_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -65,6 +66,11 @@ class ResourceCreationAPI { PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) = 0; + virtual PP_Resource CreateSurface3D(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) = 0; + virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; + virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) = 0; }; } // namespace thunk diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index 78b1b80..8662729 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -23,10 +23,21 @@ struct PPB_Find_Dev; struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; struct PPB_Font_Dev; +struct PPB_Fullscreen_Dev; struct PPB_Graphics2D; struct PPB_ImageData; +struct PPB_Instance; +struct PPB_Instance_Private; struct PPB_ImageDataTrusted; +#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING +struct PPB_Instance_0_4; +typedef PPB_Instance PPB_Instance_0_5; +#else +struct PPB_Instance_0_5; +typedef PPB_Instance PPB_Instance_0_4; +#endif + namespace ppapi { namespace thunk { @@ -48,8 +59,12 @@ const PPB_Find_Dev* GetPPB_Find_Thunk(); const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk(); const PPB_Font_Dev* GetPPB_Font_Thunk(); +const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk(); const PPB_Graphics2D* GetPPB_Graphics2D_Thunk(); const PPB_ImageData* GetPPB_ImageData_Thunk(); +const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk(); +const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk(); +const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); } // namespace thunk |