Cleanup: removing unused descendants information from tracked objects.
[chromium-blink-merge.git] / ppapi / nacl_irt / ppapi_dispatcher.h
blobc03b8b0f01f13744305ed6297444a33f32d4e263
1 // Copyright 2014 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.
5 #ifndef PPAPI_NACL_IRT_PPAPI_DISPATCHER_H_
6 #define PPAPI_NACL_IRT_PPAPI_DISPATCHER_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/files/file.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/process/process_handle.h"
15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_platform_file.h"
17 #include "ipc/ipc_sender.h"
18 #include "ppapi/c/pp_instance.h"
19 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
20 #include "ppapi/proxy/connection.h"
21 #include "ppapi/proxy/plugin_dispatcher.h"
22 #include "ppapi/proxy/plugin_proxy_delegate.h"
24 struct PP_BrowserFont_Trusted_Description;
26 namespace base {
27 class MessageLoopProxy;
28 class WaitableEvent;
29 } // namespace base
31 namespace IPC {
32 class Message;
33 class SyncChannel;
34 } // namespace IPC
36 namespace ppapi {
38 struct PpapiNaClPluginArgs;
39 struct Preferences;
41 // This class manages communication between the plugin and the browser, and
42 // manages the PluginDispatcher instances for communication between the plugin
43 // and the renderer.
44 class PpapiDispatcher : public proxy::PluginDispatcher::PluginDelegate,
45 public proxy::PluginProxyDelegate,
46 public IPC::Listener,
47 public IPC::Sender {
48 public:
49 PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop,
50 base::WaitableEvent* shutdown_event,
51 int browser_ipc_fd,
52 int renderer_ipc_fd);
54 // PluginDispatcher::PluginDelegate implementation.
55 base::MessageLoopProxy* GetIPCMessageLoop() override;
56 base::WaitableEvent* GetShutdownEvent() override;
57 IPC::PlatformFileForTransit ShareHandleWithRemote(
58 base::PlatformFile handle,
59 base::ProcessId peer_pid,
60 bool should_close_source) override;
61 std::set<PP_Instance>* GetGloballySeenInstanceIDSet() override;
62 uint32 Register(proxy::PluginDispatcher* plugin_dispatcher) override;
63 void Unregister(uint32 plugin_dispatcher_id) override;
65 // PluginProxyDelegate implementation.
66 IPC::Sender* GetBrowserSender() override;
67 std::string GetUILanguage() override;
68 void PreCacheFont(const void* logfontw) override;
69 void SetActiveURL(const std::string& url) override;
70 PP_Resource CreateBrowserFont(proxy::Connection connection,
71 PP_Instance instance,
72 const PP_BrowserFont_Trusted_Description& desc,
73 const Preferences& prefs) override;
75 // IPC::Listener implementation.
76 bool OnMessageReceived(const IPC::Message& message) override;
77 void OnChannelError() override;
79 // IPC::Sender implementation
80 bool Send(IPC::Message* message) override;
82 private:
83 void OnMsgInitializeNaClDispatcher(const PpapiNaClPluginArgs& args);
84 void OnPluginDispatcherMessageReceived(const IPC::Message& msg);
86 std::set<PP_Instance> instances_;
87 std::map<uint32, proxy::PluginDispatcher*> plugin_dispatchers_;
88 uint32 next_plugin_dispatcher_id_;
90 scoped_refptr<base::MessageLoopProxy> message_loop_;
91 base::WaitableEvent* shutdown_event_;
92 int renderer_ipc_fd_;
93 scoped_ptr<IPC::SyncChannel> channel_;
96 } // namespace ppapi
98 #endif // PPAPI_NACL_IRT_PPAPI_DISPATCHER_H_