summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/interface_list.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 20:07:29 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 20:07:29 +0000
commit62cccdac4221f25d83c84da8da70e7c540d4af35 (patch)
tree227fb39351ee5df0d6ac143f31527270b0c493d2 /ppapi/proxy/interface_list.h
parentcc89cd9a46629ca8230aae41f8ad2855c8b30264 (diff)
downloadchromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.zip
chromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.tar.gz
chromium_src-62cccdac4221f25d83c84da8da70e7c540d4af35.tar.bz2
This patch tries to remove most of the manual registration for Pepper interfaces, and replaces it with a list of macros. When files want to know which Pepper interface names and structs there are, they define what they want to do with the macros, and then include the relevant files for the classes of interfaces they want (stable, private, dev).
This does not convert all the dev interfaces. I just did a few to keep the patch smaller. So there is still a lot of manual registration. This fixes the previous design problem where we assumed one *_Proxy object == one interface. We have been hacking around this lately with duplicate GetInfo calls, but this doesn't work for PPP interfaces. Now, a _Proxy object is just there to help keep things organized. One proxy can handle zero, one, or many interfaces, and this mapping is controlled by just one line in the interfaces file. So for example, to add a new function to a new version of an interface with backward compatibility, you would add that function to the _api.h file, and write a thunk for the new interface. Then you only need to add one line to the interfaces_ppb_public_stable.h file and that will be hooked up with the proxy and the implementation. This removes some _proxy objects/files that were used only to declare that the interfaces existed, since they're no longer necessary. I folded Console into the Instance API which removed a bunch of code. I removed FileChooser 0.4. I think everybody has converted to the new one, and I think parts of it weren't even hooked up properly anymore. Review URL: http://codereview.chromium.org/7740038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/interface_list.h')
-rw-r--r--ppapi/proxy/interface_list.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h
new file mode 100644
index 0000000..7354af5
--- /dev/null
+++ b/ppapi/proxy/interface_list.h
@@ -0,0 +1,77 @@
+// 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_PROXY_INTERFACE_LIST_H_
+#define PPAPI_PROXY_INTERFACE_LIST_H_
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "ppapi/proxy/interface_proxy.h"
+
+namespace ppapi {
+namespace proxy {
+
+class InterfaceList {
+ public:
+ InterfaceList();
+ ~InterfaceList();
+
+ static InterfaceList* GetInstance();
+
+ // Looks up the ID for the given interface name. Returns INTERFACE_ID_NONE if
+ // the interface string is not found.
+ InterfaceID GetIDForPPBInterface(const std::string& name) const;
+ InterfaceID GetIDForPPPInterface(const std::string& name) const;
+
+ // Looks up the factory function for the given ID. Returns NULL if not
+ // supported.
+ InterfaceProxy::Factory GetFactoryForID(InterfaceID id) const;
+
+ // Returns the interface pointer for the given browser or plugin interface,
+ // or NULL if it's not supported.
+ const void* GetInterfaceForPPB(const std::string& name) const;
+ const void* GetInterfaceForPPP(const std::string& name) const;
+
+ private:
+ struct InterfaceInfo {
+ InterfaceInfo()
+ : id(INTERFACE_ID_NONE),
+ interface(NULL) {
+ }
+ InterfaceInfo(InterfaceID in_id, const void* in_interface)
+ : id(in_id),
+ interface(in_interface) {
+ }
+
+ InterfaceID id;
+ const void* interface;
+ };
+
+ typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap;
+
+ void AddProxy(InterfaceID id, InterfaceProxy::Factory factory);
+
+ void AddPPB(const char* name, InterfaceID id, const void* interface);
+ void AddPPP(const char* name, InterfaceID id, const void* interface);
+
+ // Old-style add functions. These should be removed when the rest of the
+ // proxies are converted over to using the new system.
+ void AddPPB(const InterfaceProxy::Info* info);
+ void AddPPP(const InterfaceProxy::Info* info);
+
+ NameToInterfaceInfoMap name_to_browser_info_;
+ NameToInterfaceInfoMap name_to_plugin_info_;
+
+ InterfaceProxy::Factory id_to_factory_[INTERFACE_ID_COUNT];
+
+ DISALLOW_COPY_AND_ASSIGN(InterfaceList);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_INTERFACE_LIST_H_
+