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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_PROXY_INTERFACE_LIST_H_
6 #define PPAPI_PROXY_INTERFACE_LIST_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "ppapi/proxy/interface_proxy.h"
13
14 namespace ppapi {
15 namespace proxy {
16
17 class InterfaceList {
18 public:
19 InterfaceList();
20 ~InterfaceList();
21
22 static InterfaceList* GetInstance();
23
24 // Looks up the ID for the given interface name. Returns INTERFACE_ID_NONE if
25 // the interface string is not found.
26 InterfaceID GetIDForPPBInterface(const std::string& name) const;
27 InterfaceID GetIDForPPPInterface(const std::string& name) const;
28
29 // Looks up the factory function for the given ID. Returns NULL if not
30 // supported.
31 InterfaceProxy::Factory GetFactoryForID(InterfaceID id) const;
32
33 // Returns the interface pointer for the given browser or plugin interface,
34 // or NULL if it's not supported.
35 const void* GetInterfaceForPPB(const std::string& name) const;
36 const void* GetInterfaceForPPP(const std::string& name) const;
37
38 private:
39 struct InterfaceInfo {
40 InterfaceInfo()
41 : id(INTERFACE_ID_NONE),
42 interface(NULL) {
43 }
44 InterfaceInfo(InterfaceID in_id, const void* in_interface)
45 : id(in_id),
46 interface(in_interface) {
47 }
48
49 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
50 const void* interface;
51 };
52
53 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap;
54
55 void AddProxy(InterfaceID id, InterfaceProxy::Factory factory);
56
57 void AddPPB(const char* name, InterfaceID id, const void* interface);
58 void AddPPP(const char* name, InterfaceID id, const void* interface);
59
60 // Old-style add functions. These should be removed when the rest of the
61 // proxies are converted over to using the new system.
62 void AddPPB(const InterfaceProxy::Info* info);
63 void AddPPP(const InterfaceProxy::Info* info);
64
65 NameToInterfaceInfoMap name_to_browser_info_;
66 NameToInterfaceInfoMap name_to_plugin_info_;
67
68 InterfaceProxy::Factory id_to_factory_[INTERFACE_ID_COUNT];
69
70 DISALLOW_COPY_AND_ASSIGN(InterfaceList);
71 };
72
73 } // namespace proxy
74 } // namespace ppapi
75
76 #endif // PPAPI_PROXY_INTERFACE_LIST_H_
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698