diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 19:54:30 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 19:54:30 +0000 |
commit | f511881bed1a46d2110f36e6b60e28f2b306b935 (patch) | |
tree | 58d69490432a1176a56ee2c0bdd6dd8016162e46 /ppapi/thunk | |
parent | 5d67452f563f0d6eddc932dd67f7e84579b77831 (diff) | |
download | chromium_src-f511881bed1a46d2110f36e6b60e28f2b306b935.zip chromium_src-f511881bed1a46d2110f36e6b60e28f2b306b935.tar.gz chromium_src-f511881bed1a46d2110f36e6b60e28f2b306b935.tar.bz2 |
Add a skeleton gamepad resource.
This implements the skeleton of the gamepad resource for the IPC proxy. It is not actually hooked up. Hooking it up will require moving some gamepad lock code to a shared location.
This also hooks up the browser message routing for implementing resource hosts in the browser process.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10824272
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/ppb_gamepad_api.h | 25 | ||||
-rw-r--r-- | ppapi/thunk/ppb_gamepad_thunk.cc | 15 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 4 |
3 files changed, 39 insertions, 5 deletions
diff --git a/ppapi/thunk/ppb_gamepad_api.h b/ppapi/thunk/ppb_gamepad_api.h new file mode 100644 index 0000000..ee7199a --- /dev/null +++ b/ppapi/thunk/ppb_gamepad_api.h @@ -0,0 +1,25 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_GAMEPAD_API_H_ +#define PPAPI_THUNK_PPB_GAMEPAD_API_H_ + +#include "ppapi/thunk/ppapi_thunk_export.h" + +struct PP_GamepadsSampleData; + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_Gamepad_API { + public: + virtual ~PPB_Gamepad_API() {} + + virtual void Sample(PP_GamepadsSampleData* data) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_GAMEPAD_API_H_ diff --git a/ppapi/thunk/ppb_gamepad_thunk.cc b/ppapi/thunk/ppb_gamepad_thunk.cc index 61b3195..3aeedb5 100644 --- a/ppapi/thunk/ppb_gamepad_thunk.cc +++ b/ppapi/thunk/ppb_gamepad_thunk.cc @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <string.h> + #include "ppapi/c/ppb_gamepad.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_gamepad_api.h" #include "ppapi/thunk/ppb_instance_api.h" #include "ppapi/thunk/resource_creation_api.h" @@ -15,9 +18,15 @@ namespace { void SampleGamepads(PP_Instance instance, PP_GamepadsSampleData* data) { EnterInstance enter(instance); - if (enter.failed()) - return; - enter.functions()->SampleGamepads(instance, data); + if (enter.succeeded()) { + PPB_Gamepad_API* api = enter.functions()->GetGamepadAPI(instance); + if (api) { + api->Sample(data); + return; + } + } + // Failure, zero out. + memset(data, 0, sizeof(PP_GamepadsSampleData)); } const PPB_Gamepad g_ppb_gamepad_thunk = { diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 10868dd..ef80609 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -37,6 +37,7 @@ struct ViewData; namespace thunk { class PPB_Flash_API; +class PPB_Gamepad_API; class PPB_Instance_API { public: @@ -90,8 +91,7 @@ class PPB_Instance_API { virtual PPB_Flash_API* GetFlashAPI() = 0; // Gamepad. - virtual void SampleGamepads(PP_Instance instance, - PP_GamepadsSampleData* data) = 0; + virtual PPB_Gamepad_API* GetGamepadAPI(PP_Instance instance) = 0; // InputEvent. virtual int32_t RequestInputEvents(PP_Instance instance, |