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_instance_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_instance_thunk.cc')
-rw-r--r-- | ppapi/thunk/ppb_instance_thunk.cc | 84 |
1 files changed, 84 insertions, 0 deletions
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 |