summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 21:50:28 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 21:50:28 +0000
commit9815108ef72b28eab4c78fe43db9db171f24cd57 (patch)
treef7fe8ea186168eb655eb927113a7f68886ed65dd /ppapi/thunk
parent25fe7fc560ac4350eb57f070194e2755279f7fb4 (diff)
downloadchromium_src-9815108ef72b28eab4c78fe43db9db171f24cd57.zip
chromium_src-9815108ef72b28eab4c78fe43db9db171f24cd57.tar.gz
chromium_src-9815108ef72b28eab4c78fe43db9db171f24cd57.tar.bz2
Move Broker, Buffer, CharSet, and CursorControl to use the new thunk/API system.
This changes the way that the function APIs work in the webkit directory, now they're created per-instance rather than globally, and have their Plugininstance as a class member (this cleans up some code). I had to move the InstanceData member to be a linked_ptr due to copy constructor issues, but this should be more efficient anyway. Review URL: http://codereview.chromium.org/7077024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/ppb_audio_config_thunk.cc2
-rw-r--r--ppapi/thunk/ppb_broker_api.h23
-rw-r--r--ppapi/thunk/ppb_broker_thunk.cc58
-rw-r--r--ppapi/thunk/ppb_buffer_api.h25
-rw-r--r--ppapi/thunk/ppb_buffer_thunk.cc65
-rw-r--r--ppapi/thunk/ppb_char_set_api.h35
-rw-r--r--ppapi/thunk/ppb_char_set_thunk.cc62
-rw-r--r--ppapi/thunk/ppb_cursor_control_api.h32
-rw-r--r--ppapi/thunk/ppb_cursor_control_thunk.cc67
-rw-r--r--ppapi/thunk/resource_creation_api.h2
-rw-r--r--ppapi/thunk/thunk.h8
11 files changed, 378 insertions, 1 deletions
diff --git a/ppapi/thunk/ppb_audio_config_thunk.cc b/ppapi/thunk/ppb_audio_config_thunk.cc
index 8ee8ffd..ca3d589 100644
--- a/ppapi/thunk/ppb_audio_config_thunk.cc
+++ b/ppapi/thunk/ppb_audio_config_thunk.cc
@@ -35,7 +35,7 @@ uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
PP_Bool IsAudioConfig(PP_Resource resource) {
EnterResource<PPB_AudioConfig_API> enter(resource, false);
- return enter.succeeded() ? PP_TRUE : PP_FALSE;
+ return PP_FromBool(enter.succeeded());
}
PP_AudioSampleRate GetSampleRate(PP_Resource config_id) {
diff --git a/ppapi/thunk/ppb_broker_api.h b/ppapi/thunk/ppb_broker_api.h
new file mode 100644
index 0000000..feb53f5
--- /dev/null
+++ b/ppapi/thunk/ppb_broker_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_BROKER_API_H_
+#define PPAPI_THUNK_PPB_BROKER_API_H_
+
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_stdint.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_Broker_API {
+ public:
+ virtual int32_t Connect(PP_CompletionCallback connect_callback) = 0;
+ virtual int32_t GetHandle(int32_t* handle) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_BROKER_API_H_
diff --git a/ppapi/thunk/ppb_broker_thunk.cc b/ppapi/thunk/ppb_broker_thunk.cc
new file mode 100644
index 0000000..1394ee9
--- /dev/null
+++ b/ppapi/thunk/ppb_broker_thunk.cc
@@ -0,0 +1,58 @@
+// 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/trusted/ppb_broker_trusted.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_broker_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Resource CreateTrusted(PP_Instance instance) {
+ EnterFunction<ResourceCreationAPI> enter(instance, true);
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateBroker(instance);
+}
+
+PP_Bool IsBrokerTrusted(PP_Resource resource) {
+ EnterResource<PPB_Broker_API> enter(resource, false);
+ return PP_FromBool(enter.succeeded());
+}
+
+int32_t Connect(PP_Resource resource,
+ PP_CompletionCallback connect_callback) {
+ EnterResource<PPB_Broker_API> enter(resource, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+ return enter.object()->Connect(connect_callback);
+}
+
+int32_t GetHandle(PP_Resource resource, int32_t* handle) {
+ EnterResource<PPB_Broker_API> enter(resource, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+ return enter.object()->GetHandle(handle);
+}
+
+const PPB_BrokerTrusted g_ppb_broker_thunk = {
+ &CreateTrusted,
+ &IsBrokerTrusted,
+ &Connect,
+ &GetHandle,
+};
+
+} // namespace
+
+const PPB_BrokerTrusted* GetPPB_Broker_Thunk() {
+ return &g_ppb_broker_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_buffer_api.h b/ppapi/thunk/ppb_buffer_api.h
new file mode 100644
index 0000000..6d3d5d0
--- /dev/null
+++ b/ppapi/thunk/ppb_buffer_api.h
@@ -0,0 +1,25 @@
+// 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_BUFFER_API_H_
+#define PPAPI_THUNK_PPB_BUFFER_API_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_stdint.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_Buffer_API {
+ public:
+ virtual PP_Bool Describe(uint32_t* size_in_bytes) = 0;
+ virtual PP_Bool IsMapped() = 0;
+ virtual void* Map() = 0;
+ virtual void Unmap() = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_BUFFER_API_H_
diff --git a/ppapi/thunk/ppb_buffer_thunk.cc b/ppapi/thunk/ppb_buffer_thunk.cc
new file mode 100644
index 0000000..cf4952c
--- /dev/null
+++ b/ppapi/thunk/ppb_buffer_thunk.cc
@@ -0,0 +1,65 @@
+// 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_buffer_dev.h"
+#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_buffer_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Resource Create(PP_Instance instance, uint32_t size) {
+ EnterFunction<ResourceCreationAPI> enter(instance, true);
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateBuffer(instance, size);
+}
+
+PP_Bool IsBuffer(PP_Resource resource) {
+ EnterResource<PPB_Buffer_API> enter(resource, false);
+ return PP_FromBool(enter.succeeded());
+}
+
+PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
+ EnterResource<PPB_Buffer_API> enter(resource, true);
+ if (enter.failed()) {
+ *size_in_bytes = 0;
+ return PP_FALSE;
+ }
+ return enter.object()->Describe(size_in_bytes);
+}
+
+void* Map(PP_Resource resource) {
+ EnterResource<PPB_Buffer_API> enter(resource, true);
+ if (enter.failed())
+ return NULL;
+ return enter.object()->Map();
+}
+
+void Unmap(PP_Resource resource) {
+ EnterResource<PPB_Buffer_API> enter(resource, true);
+ if (enter.succeeded())
+ enter.object()->Unmap();
+}
+
+const PPB_Buffer_Dev g_ppb_buffer_thunk = {
+ &Create,
+ &IsBuffer,
+ &Describe,
+ &Map,
+ &Unmap,
+};
+
+} // namespace
+
+const PPB_Buffer_Dev* GetPPB_Buffer_Thunk() {
+ return &g_ppb_buffer_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_char_set_api.h b/ppapi/thunk/ppb_char_set_api.h
new file mode 100644
index 0000000..66b5ff4
--- /dev/null
+++ b/ppapi/thunk/ppb_char_set_api.h
@@ -0,0 +1,35 @@
+// 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_CHAR_SET_API_H_
+#define PPAPI_THUNK_PPB_CHAR_SET_API_H_
+
+#include "ppapi/c/dev/ppb_char_set_dev.h"
+#include "ppapi/proxy/interface_id.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_CharSet_FunctionAPI {
+ public:
+ static const ::pp::proxy::InterfaceID interface_id =
+ ::pp::proxy::INTERFACE_ID_PPB_CHAR_SET;
+
+ virtual char* UTF16ToCharSet(PP_Instance instance,
+ const uint16_t* utf16, uint32_t utf16_len,
+ const char* output_char_set,
+ PP_CharSet_ConversionError on_error,
+ uint32_t* output_length) = 0;
+ virtual uint16_t* CharSetToUTF16(PP_Instance instance,
+ const char* input, uint32_t input_len,
+ const char* input_char_set,
+ PP_CharSet_ConversionError on_error,
+ uint32_t* output_length) = 0;
+ virtual PP_Var GetDefaultCharSet(PP_Instance instance) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_CHAR_SET_API_H_
diff --git a/ppapi/thunk/ppb_char_set_thunk.cc b/ppapi/thunk/ppb_char_set_thunk.cc
new file mode 100644
index 0000000..bc36bad
--- /dev/null
+++ b/ppapi/thunk/ppb_char_set_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/c/pp_var.h"
+#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_char_set_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+char* UTF16ToCharSet(PP_Instance instance,
+ const uint16_t* utf16, uint32_t utf16_len,
+ const char* output_char_set,
+ PP_CharSet_ConversionError on_error,
+ uint32_t* output_length) {
+ EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return NULL;
+ return enter.functions()->UTF16ToCharSet(instance, utf16, utf16_len,
+ output_char_set, on_error,
+ output_length);
+}
+
+uint16_t* CharSetToUTF16(PP_Instance instance,
+ const char* input, uint32_t input_len,
+ const char* input_char_set,
+ PP_CharSet_ConversionError on_error,
+ uint32_t* output_length) {
+ EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return NULL;
+ return enter.functions()->CharSetToUTF16(instance, input, input_len,
+ input_char_set, on_error,
+ output_length);
+}
+
+PP_Var GetDefaultCharSet(PP_Instance instance) {
+ EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_MakeUndefined();
+ return enter.functions()->GetDefaultCharSet(instance);
+}
+
+const PPB_CharSet_Dev g_ppb_char_set_thunk = {
+ &UTF16ToCharSet,
+ &CharSetToUTF16,
+ &GetDefaultCharSet
+};
+
+
+} // namespace
+
+const PPB_CharSet_Dev* GetPPB_CharSet_Thunk() {
+ return &g_ppb_char_set_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_cursor_control_api.h b/ppapi/thunk/ppb_cursor_control_api.h
new file mode 100644
index 0000000..26b1e70
--- /dev/null
+++ b/ppapi/thunk/ppb_cursor_control_api.h
@@ -0,0 +1,32 @@
+// 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_CURSOR_CONTROL_API_H_
+#define PPAPI_THUNK_CURSOR_CONTROL_API_H_
+
+#include "ppapi/c/dev/ppb_cursor_control_dev.h"
+#include "ppapi/proxy/interface_id.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_CursorControl_FunctionAPI {
+ public:
+ static const ::pp::proxy::InterfaceID interface_id =
+ ::pp::proxy::INTERFACE_ID_PPB_CURSORCONTROL;
+
+ virtual PP_Bool SetCursor(PP_Instance instance,
+ PP_CursorType_Dev type,
+ PP_Resource custom_image_id,
+ const PP_Point* hot_spot) = 0;
+ virtual PP_Bool LockCursor(PP_Instance instance) = 0;
+ virtual PP_Bool UnlockCursor(PP_Instance instance) = 0;
+ virtual PP_Bool HasCursorLock(PP_Instance instance) = 0;
+ virtual PP_Bool CanLockCursor(PP_Instance instance) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_CURSOR_CONTROL_API_H_
diff --git a/ppapi/thunk/ppb_cursor_control_thunk.cc b/ppapi/thunk/ppb_cursor_control_thunk.cc
new file mode 100644
index 0000000..56ba078
--- /dev/null
+++ b/ppapi/thunk/ppb_cursor_control_thunk.cc
@@ -0,0 +1,67 @@
+// 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_cursor_control_api.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+PP_Bool SetCursor(PP_Instance instance,
+ PP_CursorType_Dev type,
+ PP_Resource custom_image,
+ const PP_Point* hot_spot) {
+ EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->SetCursor(instance, type, custom_image, hot_spot);
+}
+
+PP_Bool LockCursor(PP_Instance instance) {
+ EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->LockCursor(instance);
+}
+
+PP_Bool UnlockCursor(PP_Instance instance) {
+ EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->UnlockCursor(instance);
+}
+
+PP_Bool HasCursorLock(PP_Instance instance) {
+ EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->HasCursorLock(instance);
+}
+
+PP_Bool CanLockCursor(PP_Instance instance) {
+ EnterFunction<PPB_CursorControl_FunctionAPI> enter(instance, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return enter.functions()->CanLockCursor(instance);
+}
+
+const PPB_CursorControl_Dev g_ppb_cursor_control_thunk = {
+ &SetCursor,
+ &LockCursor,
+ &UnlockCursor,
+ &HasCursorLock,
+ &CanLockCursor
+};
+
+} // namespace
+
+const PPB_CursorControl_Dev* GetPPB_CursorControl_Thunk() {
+ return &g_ppb_cursor_control_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 4dd9204..d25285f 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -37,6 +37,8 @@ class ResourceCreationAPI {
virtual PP_Resource CreateAudioConfig(PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) = 0;
+ virtual PP_Resource CreateBroker(PP_Instance instance) = 0;
+ virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) = 0;
// Note: can't be called CreateFont due to Windows #defines.
virtual PP_Resource CreateFontObject(
PP_Instance instance,
diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h
index efe320e..647f6eb 100644
--- a/ppapi/thunk/thunk.h
+++ b/ppapi/thunk/thunk.h
@@ -8,6 +8,10 @@
struct PPB_Audio;
struct PPB_AudioConfig;
struct PPB_AudioTrusted;
+struct PPB_BrokerTrusted;
+struct PPB_Buffer_Dev;
+struct PPB_CharSet_Dev;
+struct PPB_CursorControl_Dev;
struct PPB_Font_Dev;
struct PPB_Graphics2D;
struct PPB_ImageData;
@@ -18,6 +22,10 @@ namespace thunk {
const PPB_Audio* GetPPB_Audio_Thunk();
const PPB_AudioConfig* GetPPB_AudioConfig_Thunk();
const PPB_AudioTrusted* GetPPB_AudioTrusted_Thunk();
+const PPB_BrokerTrusted* GetPPB_Broker_Thunk();
+const PPB_Buffer_Dev* GetPPB_Buffer_Thunk();
+const PPB_CharSet_Dev* GetPPB_CharSet_Thunk();
+const PPB_CursorControl_Dev* GetPPB_CursorControl_Thunk();
const PPB_Font_Dev* GetPPB_Font_Thunk();
const PPB_Graphics2D* GetPPB_Graphics2D_Thunk();
const PPB_ImageData* GetPPB_ImageData_Thunk();