Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: ppapi/proxy/interface_list.h

Issue 7740038: Use macros to define pepper interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/interface_list.h
diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..7354af53d20bed6170142687faa819c94657b5c4
--- /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;
noelallen_use_chromium 2011/09/07 21:16:57 Should there be a prototype in case whichever head
brettw 2011/09/08 05:34:29 I'm not sure what you mean here.
noelallen_use_chromium 2011/09/08 19:49:16 nvm. I was wondering if you should explicitly inc
+ 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_
+

Powered by Google App Engine
This is Rietveld 408576698