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

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

Issue 10572040: Create a PPAPI host for new resource message routing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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) 2012 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_HOST_PPAPI_HOST_H_
6 #define PPAPI_HOST_PPAPI_HOST_H_
7
8 #include <map>
9
10 #include "base/memory/linked_ptr.h"
11 #include "ipc/ipc_listener.h"
12 #include "ipc/ipc_sender.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/host/ppapi_host_export.h"
16
17 namespace ppapi {
18
19 namespace proxy {
20 class ResourceMessageCallParams;
21 class ResourceMessageReplyParams;
22 }
23
24 namespace host {
25
26 class HostFactory;
27 class ResourceHost;
28
29 // The host provides routing and tracking for resource message calls that
30 // come from the plugin to the host (browser or renderer), and the
31 // corresponding replies.
32 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
33 public:
34 // The sender is the channel to the plugin for outgoing messages. The factory
35 // will be used to receive resource creation messages from the plugin. Both
36 // pointers are owned by the caller and must outlive this class.
37 PpapiHost(IPC::Sender* sender,
38 HostFactory* host_factory);
39 virtual ~PpapiHost();
40
41 // Sender implementation. Forwards to the sender_.
42 virtual bool Send(IPC::Message* msg) OVERRIDE;
43
44 // Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
46
47 // Sends the given reply message to the plugin.
48 void SendReply(const proxy::ResourceMessageReplyParams& params,
49 const IPC::Message& msg);
50
51 private:
52 // Message handlers.
53 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params,
54 const IPC::Message& nested_msg);
55 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param,
56 PP_Instance instance,
57 const IPC::Message& nested_msg);
58 void OnHostMsgResourceDestroyed(PP_Resource resource);
59
60 // Returns null if the resource doesn't exist.
61 host::ResourceHost* GetResourceHost(PP_Resource resource);
62
63 // Non-owning pointer.
64 IPC::Sender* sender_;
65
66 // Non-owning pointer.
67 HostFactory* host_factory_;
68
69 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap;
70 ResourceMap resources_;
71
72 DISALLOW_COPY_AND_ASSIGN(PpapiHost);
73 };
74
75 } // namespace host
76 } // namespace ppapi
77
78 #endif // PPAPI_HOST_PPAPIE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698