OLD | NEW |
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 CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 protected: | 53 protected: |
54 virtual ~Client() {} | 54 virtual ~Client() {} |
55 }; | 55 }; |
56 | 56 |
57 class PluginClient : public Client { | 57 class PluginClient : public Client { |
58 public: | 58 public: |
59 // Returns the resource context for the renderer requesting the channel. | 59 // Returns the resource context for the renderer requesting the channel. |
60 virtual ResourceContext* GetResourceContext() = 0; | 60 virtual ResourceContext* GetResourceContext() = 0; |
61 | 61 |
62 protected: | 62 protected: |
63 virtual ~PluginClient() {} | 63 ~PluginClient() override {} |
64 }; | 64 }; |
65 | 65 |
66 class BrokerClient : public Client { | 66 class BrokerClient : public Client { |
67 protected: | 67 protected: |
68 virtual ~BrokerClient() {} | 68 ~BrokerClient() override {} |
69 }; | 69 }; |
70 | 70 |
71 virtual ~PpapiPluginProcessHost(); | 71 ~PpapiPluginProcessHost() override; |
72 | 72 |
73 static PpapiPluginProcessHost* CreatePluginHost( | 73 static PpapiPluginProcessHost* CreatePluginHost( |
74 const PepperPluginInfo& info, | 74 const PepperPluginInfo& info, |
75 const base::FilePath& profile_data_directory); | 75 const base::FilePath& profile_data_directory); |
76 static PpapiPluginProcessHost* CreateBrokerHost( | 76 static PpapiPluginProcessHost* CreateBrokerHost( |
77 const PepperPluginInfo& info); | 77 const PepperPluginInfo& info); |
78 | 78 |
79 // Notification that a PP_Instance has been created and the associated | 79 // Notification that a PP_Instance has been created and the associated |
80 // renderer related data including the RenderView/Process pair for the given | 80 // renderer related data including the RenderView/Process pair for the given |
81 // plugin. This is necessary so that when the plugin calls us with a | 81 // plugin. This is necessary so that when the plugin calls us with a |
82 // PP_Instance we can find the RenderView associated with it without trusting | 82 // PP_Instance we can find the RenderView associated with it without trusting |
83 // the plugin. | 83 // the plugin. |
84 static void DidCreateOutOfProcessInstance( | 84 static void DidCreateOutOfProcessInstance( |
85 int plugin_process_id, | 85 int plugin_process_id, |
86 int32 pp_instance, | 86 int32 pp_instance, |
87 const PepperRendererInstanceData& instance_data); | 87 const PepperRendererInstanceData& instance_data); |
88 | 88 |
89 // The opposite of DIdCreate... above. | 89 // The opposite of DIdCreate... above. |
90 static void DidDeleteOutOfProcessInstance(int plugin_process_id, | 90 static void DidDeleteOutOfProcessInstance(int plugin_process_id, |
91 int32 pp_instance); | 91 int32 pp_instance); |
92 | 92 |
93 // Returns the instances that match the specified process name. | 93 // Returns the instances that match the specified process name. |
94 // It can only be called on the IO thread. | 94 // It can only be called on the IO thread. |
95 static void FindByName(const base::string16& name, | 95 static void FindByName(const base::string16& name, |
96 std::vector<PpapiPluginProcessHost*>* hosts); | 96 std::vector<PpapiPluginProcessHost*>* hosts); |
97 | 97 |
98 // IPC::Sender implementation: | 98 // IPC::Sender implementation: |
99 virtual bool Send(IPC::Message* message) override; | 99 bool Send(IPC::Message* message) override; |
100 | 100 |
101 // Opens a new channel to the plugin. The client will be notified when the | 101 // Opens a new channel to the plugin. The client will be notified when the |
102 // channel is ready or if there's an error. | 102 // channel is ready or if there's an error. |
103 void OpenChannelToPlugin(Client* client); | 103 void OpenChannelToPlugin(Client* client); |
104 | 104 |
105 BrowserPpapiHostImpl* host_impl() { return host_impl_.get(); } | 105 BrowserPpapiHostImpl* host_impl() { return host_impl_.get(); } |
106 const BrowserChildProcessHostImpl* process() { return process_.get(); } | 106 const BrowserChildProcessHostImpl* process() { return process_.get(); } |
107 const base::FilePath& plugin_path() const { return plugin_path_; } | 107 const base::FilePath& plugin_path() const { return plugin_path_; } |
108 const base::FilePath& profile_data_directory() const { | 108 const base::FilePath& profile_data_directory() const { |
109 return profile_data_directory_; | 109 return profile_data_directory_; |
110 } | 110 } |
111 | 111 |
112 // The client pointer must remain valid until its callback is issued. | 112 // The client pointer must remain valid until its callback is issued. |
113 | 113 |
114 private: | 114 private: |
115 class PluginNetworkObserver; | 115 class PluginNetworkObserver; |
116 | 116 |
117 // Constructors for plugin and broker process hosts, respectively. | 117 // Constructors for plugin and broker process hosts, respectively. |
118 // You must call Init before doing anything else. | 118 // You must call Init before doing anything else. |
119 PpapiPluginProcessHost(const PepperPluginInfo& info, | 119 PpapiPluginProcessHost(const PepperPluginInfo& info, |
120 const base::FilePath& profile_data_directory); | 120 const base::FilePath& profile_data_directory); |
121 PpapiPluginProcessHost(); | 121 PpapiPluginProcessHost(); |
122 | 122 |
123 // Actually launches the process with the given plugin info. Returns true | 123 // Actually launches the process with the given plugin info. Returns true |
124 // on success (the process was spawned). | 124 // on success (the process was spawned). |
125 bool Init(const PepperPluginInfo& info); | 125 bool Init(const PepperPluginInfo& info); |
126 | 126 |
127 void RequestPluginChannel(Client* client); | 127 void RequestPluginChannel(Client* client); |
128 | 128 |
129 virtual void OnProcessLaunched() override; | 129 void OnProcessLaunched() override; |
130 | 130 |
131 virtual void OnProcessCrashed(int exit_code) override; | 131 void OnProcessCrashed(int exit_code) override; |
132 virtual bool OnMessageReceived(const IPC::Message& msg) override; | 132 bool OnMessageReceived(const IPC::Message& msg) override; |
133 virtual void OnChannelConnected(int32 peer_pid) override; | 133 void OnChannelConnected(int32 peer_pid) override; |
134 virtual void OnChannelError() override; | 134 void OnChannelError() override; |
135 | 135 |
136 void CancelRequests(); | 136 void CancelRequests(); |
137 | 137 |
138 // IPC message handlers. | 138 // IPC message handlers. |
139 void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle); | 139 void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle); |
140 | 140 |
141 // Handles most requests from the plugin. May be NULL. | 141 // Handles most requests from the plugin. May be NULL. |
142 scoped_refptr<PepperMessageFilter> filter_; | 142 scoped_refptr<PepperMessageFilter> filter_; |
143 | 143 |
144 ppapi::PpapiPermissions permissions_; | 144 ppapi::PpapiPermissions permissions_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 public: | 183 public: |
184 PpapiBrokerProcessHostIterator() | 184 PpapiBrokerProcessHostIterator() |
185 : BrowserChildProcessHostTypeIterator< | 185 : BrowserChildProcessHostTypeIterator< |
186 PpapiPluginProcessHost>(PROCESS_TYPE_PPAPI_BROKER) {} | 186 PpapiPluginProcessHost>(PROCESS_TYPE_PPAPI_BROKER) {} |
187 }; | 187 }; |
188 | 188 |
189 } // namespace content | 189 } // namespace content |
190 | 190 |
191 #endif // CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ | 191 #endif // CONTENT_BROWSER_PPAPI_PLUGIN_PROCESS_HOST_H_ |
192 | 192 |
OLD | NEW |