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

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

Issue 10803050: Hook up the PPB_Flash_Print interface to new host system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with deps Created 8 years, 4 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
« no previous file with comments | « ppapi/host/instance_message_filter.cc ('k') | ppapi/host/ppapi_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/memory/scoped_vector.h"
12 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h" 16 #include "ipc/ipc_sender.h"
14 #include "ppapi/c/pp_instance.h" 17 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_resource.h" 18 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/host/ppapi_host_export.h" 19 #include "ppapi/host/ppapi_host_export.h"
17 #include "ppapi/shared_impl/ppapi_permissions.h" 20 #include "ppapi/shared_impl/ppapi_permissions.h"
18 21
19 namespace ppapi { 22 namespace ppapi {
20 23
21 namespace proxy { 24 namespace proxy {
22 class ResourceMessageCallParams; 25 class ResourceMessageCallParams;
23 class ResourceMessageReplyParams; 26 class ResourceMessageReplyParams;
24 } 27 }
25 28
26 namespace host { 29 namespace host {
27 30
28 class HostFactory; 31 class HostFactory;
32 class InstanceMessageFilter;
29 class ResourceHost; 33 class ResourceHost;
30 34
31 // The host provides routing and tracking for resource message calls that 35 // The host provides routing and tracking for resource message calls that
32 // 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
33 // corresponding replies. 37 // corresponding replies.
34 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { 38 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
35 public: 39 public:
36 // 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. The factory
37 // will be used to receive resource creation messages from the plugin. Both 41 // will be used to receive resource creation messages from the plugin. Both
38 // pointers are owned by the caller and must outlive this class. 42 // pointers are owned by the caller and must outlive this class.
39 PpapiHost(IPC::Sender* sender, 43 PpapiHost(IPC::Sender* sender,
40 HostFactory* host_factory, 44 HostFactory* host_factory,
41 const PpapiPermissions& perms); 45 const PpapiPermissions& perms);
42 virtual ~PpapiHost(); 46 virtual ~PpapiHost();
43 47
44 const PpapiPermissions& permissions() const { return permissions_; } 48 const PpapiPermissions& permissions() const { return permissions_; }
45 49
46 // Sender implementation. Forwards to the sender_. 50 // Sender implementation. Forwards to the sender_.
47 virtual bool Send(IPC::Message* msg) OVERRIDE; 51 virtual bool Send(IPC::Message* msg) OVERRIDE;
48 52
49 // Listener implementation. 53 // Listener implementation.
50 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 54 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
51 55
52 // Sends the given reply message to the plugin. 56 // Sends the given reply message to the plugin.
53 void SendReply(const proxy::ResourceMessageReplyParams& params, 57 void SendReply(const proxy::ResourceMessageReplyParams& params,
54 const IPC::Message& msg); 58 const IPC::Message& msg);
55 59
60 // Adds the given message filter to the host. The PpapiHost will take
61 // ownership of the pointer.
62 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter);
63
56 private: 64 private:
65 friend class InstanceMessageFilter;
66
57 // Message handlers. 67 // Message handlers.
58 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, 68 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params,
59 const IPC::Message& nested_msg); 69 const IPC::Message& nested_msg);
60 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, 70 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param,
61 PP_Instance instance, 71 PP_Instance instance,
62 const IPC::Message& nested_msg); 72 const IPC::Message& nested_msg);
63 void OnHostMsgResourceDestroyed(PP_Resource resource); 73 void OnHostMsgResourceDestroyed(PP_Resource resource);
64 74
65 // Returns null if the resource doesn't exist. 75 // Returns null if the resource doesn't exist.
66 host::ResourceHost* GetResourceHost(PP_Resource resource); 76 host::ResourceHost* GetResourceHost(PP_Resource resource);
67 77
68 // Non-owning pointer. 78 // Non-owning pointer.
69 IPC::Sender* sender_; 79 IPC::Sender* sender_;
70 80
71 // Non-owning pointer. 81 // Non-owning pointer.
72 HostFactory* host_factory_; 82 HostFactory* host_factory_;
73 83
74 PpapiPermissions permissions_; 84 PpapiPermissions permissions_;
75 85
86 // Filters for instance messages. Note that since we don't support deleting
87 // these dynamically we don't need to worry about modifications during
88 // iteration. If we add that capability, this should be replaced with an
89 // ObserverList.
90 ScopedVector<InstanceMessageFilter> instance_message_filters_;
91
76 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; 92 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap;
77 ResourceMap resources_; 93 ResourceMap resources_;
78 94
79 DISALLOW_COPY_AND_ASSIGN(PpapiHost); 95 DISALLOW_COPY_AND_ASSIGN(PpapiHost);
80 }; 96 };
81 97
82 } // namespace host 98 } // namespace host
83 } // namespace ppapi 99 } // namespace ppapi
84 100
85 #endif // PPAPI_HOST_PPAPIE_HOST_H_ 101 #endif // PPAPI_HOST_PPAPIE_HOST_H_
OLDNEW
« no previous file with comments | « ppapi/host/instance_message_filter.cc ('k') | ppapi/host/ppapi_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698