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

Side by Side Diff: ppapi/host/ppapi_host.h

Issue 10909138: Convert the async device ID getter to a chrome resource host (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_HOST_PPAPI_HOST_H_ 5 #ifndef PPAPI_HOST_PPAPI_HOST_H_
6 #define PPAPI_HOST_PPAPI_HOST_H_ 6 #define PPAPI_HOST_PPAPI_HOST_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 19 matching lines...) Expand all
30 30
31 class HostFactory; 31 class HostFactory;
32 class InstanceMessageFilter; 32 class InstanceMessageFilter;
33 class ResourceHost; 33 class ResourceHost;
34 34
35 // The host provides routing and tracking for resource message calls that 35 // The host provides routing and tracking for resource message calls that
36 // come from the plugin to the host (browser or renderer), and the 36 // come from the plugin to the host (browser or renderer), and the
37 // corresponding replies. 37 // corresponding replies.
38 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { 38 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
39 public: 39 public:
40 // The sender is the channel to the plugin for outgoing messages. The factory 40 // The sender is the channel to the plugin for outgoing messages.
41 // will be used to receive resource creation messages from the plugin. Both 41 // Normally the creator will add filters for resource creation messages
42 // pointers are owned by the caller and must outlive this class. 42 // (AddHostFactoryFilter) and instance messages (AddInstanceMessageFilter)
43 PpapiHost(IPC::Sender* sender, 43 // after construction.
44 HostFactory* host_factory, 44 PpapiHost(IPC::Sender* sender, const PpapiPermissions& perms);
45 const PpapiPermissions& perms);
46 virtual ~PpapiHost(); 45 virtual ~PpapiHost();
47 46
48 const PpapiPermissions& permissions() const { return permissions_; } 47 const PpapiPermissions& permissions() const { return permissions_; }
49 48
50 // Sender implementation. Forwards to the sender_. 49 // Sender implementation. Forwards to the sender_.
51 virtual bool Send(IPC::Message* msg) OVERRIDE; 50 virtual bool Send(IPC::Message* msg) OVERRIDE;
52 51
53 // Listener implementation. 52 // Listener implementation.
54 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 53 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
55 54
56 // Sends the given reply message to the plugin. 55 // Sends the given reply message to the plugin.
57 void SendReply(const proxy::ResourceMessageReplyParams& params, 56 void SendReply(const proxy::ResourceMessageReplyParams& params,
58 const IPC::Message& msg); 57 const IPC::Message& msg);
59 58
59 // Adds the given host factory filter to the host. The PpapiHost will take
60 // ownership of the pointer.
61 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter);
62
60 // Adds the given message filter to the host. The PpapiHost will take 63 // Adds the given message filter to the host. The PpapiHost will take
61 // ownership of the pointer. 64 // ownership of the pointer.
62 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); 65 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter);
63 66
64 private: 67 private:
65 friend class InstanceMessageFilter; 68 friend class InstanceMessageFilter;
66 69
67 // Message handlers. 70 // Message handlers.
68 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, 71 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params,
69 const IPC::Message& nested_msg); 72 const IPC::Message& nested_msg);
70 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, 73 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param,
71 PP_Instance instance, 74 PP_Instance instance,
72 const IPC::Message& nested_msg); 75 const IPC::Message& nested_msg);
73 void OnHostMsgResourceDestroyed(PP_Resource resource); 76 void OnHostMsgResourceDestroyed(PP_Resource resource);
74 77
75 // Returns null if the resource doesn't exist. 78 // Returns null if the resource doesn't exist.
76 host::ResourceHost* GetResourceHost(PP_Resource resource); 79 host::ResourceHost* GetResourceHost(PP_Resource resource);
77 80
78 // Non-owning pointer. 81 // Non-owning pointer.
79 IPC::Sender* sender_; 82 IPC::Sender* sender_;
80 83
81 // Non-owning pointer. 84 PpapiPermissions permissions_;
82 HostFactory* host_factory_;
83 85
84 PpapiPermissions permissions_; 86 // Filters for resource creation messages. Note that since we don't support
87 // deleting these dynamically we don't need to worry about modifications
88 // during iteration. If we add that capability, this should be replaced with
89 // an ObserverList.
90 ScopedVector<HostFactory> host_factory_filters_;
85 91
86 // Filters for instance messages. Note that since we don't support deleting 92 // Filters for instance messages. Note that since we don't support deleting
87 // these dynamically we don't need to worry about modifications during 93 // these dynamically we don't need to worry about modifications during
88 // iteration. If we add that capability, this should be replaced with an 94 // iteration. If we add that capability, this should be replaced with an
89 // ObserverList. 95 // ObserverList.
90 ScopedVector<InstanceMessageFilter> instance_message_filters_; 96 ScopedVector<InstanceMessageFilter> instance_message_filters_;
91 97
92 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; 98 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap;
93 ResourceMap resources_; 99 ResourceMap resources_;
94 100
95 DISALLOW_COPY_AND_ASSIGN(PpapiHost); 101 DISALLOW_COPY_AND_ASSIGN(PpapiHost);
96 }; 102 };
97 103
98 } // namespace host 104 } // namespace host
99 } // namespace ppapi 105 } // namespace ppapi
100 106
101 #endif // PPAPI_HOST_PPAPIE_HOST_H_ 107 #endif // PPAPI_HOST_PPAPIE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698