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

Side by Side Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h

Issue 61063003: Keep NaCl plugins used in app background pages alive when active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: working prototype Created 7 years, 1 month 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
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_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h" 15 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h"
16 #include "content/browser/renderer_host/pepper/ssl_context_helper.h" 16 #include "content/browser/renderer_host/pepper/ssl_context_helper.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/pepper_renderer_instance_data.h" 18 #include "content/common/pepper_renderer_instance_data.h"
19 #include "content/public/browser/browser_ppapi_host.h" 19 #include "content/public/browser/browser_ppapi_host.h"
20 #include "content/public/common/process_type.h" 20 #include "content/public/common/process_type.h"
21 #include "ipc/ipc_channel_proxy.h" 21 #include "ipc/ipc_channel_proxy.h"
22 #include "ppapi/host/ppapi_host.h" 22 #include "ppapi/host/ppapi_host.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { 26 class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost
27 {
27 public: 28 public:
29 // |delegate| will be owned by BrowserPpapiHostImpl, is optional and may be
30 // NULL, and is used only for OnIdleState for NaCl extensions.
28 // The creator is responsible for calling set_plugin_process_handle as soon 31 // The creator is responsible for calling set_plugin_process_handle as soon
29 // as it is known (we start the process asynchronously so it won't be known 32 // as it is known (we start the process asynchronously so it won't be known
30 // when this object is created). 33 // when this object is created).
31 // |external_plugin| signfies that this is a proxy created for an embedder's 34 // |external_plugin| signfies that this is a proxy created for an embedder's
32 // plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess. 35 // plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess.
33 BrowserPpapiHostImpl( 36 BrowserPpapiHostImpl(
37 BrowserPpapiHost::Delegate* delegate,
34 IPC::Sender* sender, 38 IPC::Sender* sender,
35 const ppapi::PpapiPermissions& permissions, 39 const ppapi::PpapiPermissions& permissions,
36 const std::string& plugin_name, 40 const std::string& plugin_name,
37 const base::FilePath& plugin_path, 41 const base::FilePath& plugin_path,
38 const base::FilePath& profile_data_directory, 42 const base::FilePath& profile_data_directory,
39 bool in_process, 43 bool in_process,
40 bool external_plugin); 44 bool external_plugin);
41 virtual ~BrowserPpapiHostImpl(); 45 virtual ~BrowserPpapiHostImpl();
42 46
43 // BrowserPpapiHost. 47 // BrowserPpapiHost.
(...skipping 16 matching lines...) Expand all
60 bool in_process() const { return in_process_; } 64 bool in_process() const { return in_process_; }
61 bool external_plugin() const { return external_plugin_; } 65 bool external_plugin() const { return external_plugin_; }
62 66
63 // These two functions are notifications that an instance has been created 67 // These two functions are notifications that an instance has been created
64 // or destroyed. They allow us to maintain a mapping of PP_Instance to data 68 // or destroyed. They allow us to maintain a mapping of PP_Instance to data
65 // associated with the instance including view IDs in the browser process. 69 // associated with the instance including view IDs in the browser process.
66 void AddInstance(PP_Instance instance, 70 void AddInstance(PP_Instance instance,
67 const PepperRendererInstanceData& instance_data); 71 const PepperRendererInstanceData& instance_data);
68 void DeleteInstance(PP_Instance instance); 72 void DeleteInstance(PP_Instance instance);
69 73
74 // Called to handle the idle state of the plugin changing.
75 void OnIdleState(bool idle);
76
70 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() { 77 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() {
71 return message_filter_; 78 return message_filter_;
72 } 79 }
73 80
74 const scoped_refptr<SSLContextHelper>& ssl_context_helper() const { 81 const scoped_refptr<SSLContextHelper>& ssl_context_helper() const {
75 return ssl_context_helper_; 82 return ssl_context_helper_;
76 } 83 }
77 84
78 private: 85 private:
79 friend class BrowserPpapiHostTest; 86 friend class BrowserPpapiHostTest;
80 87
81 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, 88 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted,
82 // preventing us from returning these to embedders without holding a 89 // preventing us from returning these to embedders without holding a
83 // reference. To avoid that, define a message filter object. 90 // reference. To avoid that, define a message filter object.
84 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { 91 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter {
85 public: 92 public:
86 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) 93 explicit HostMessageFilter(BrowserPpapiHostImpl* host,
dmichael (off chromium) 2013/11/06 22:39:21 nit: explicit not necessary now w/2 params
scheib 2013/11/15 01:22:17 Done.
87 : ppapi_host_(ppapi_host) {} 94 ppapi::host::PpapiHost* ppapi_host)
95 : browser_ppapi_host_impl_(host),
96 ppapi_host_(ppapi_host) {}
88 // IPC::ChannelProxy::MessageFilter. 97 // IPC::ChannelProxy::MessageFilter.
89 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 98 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
90 99
91 void OnHostDestroyed(); 100 void OnHostDestroyed();
92 101
93 private: 102 private:
94 virtual ~HostMessageFilter() {} 103 virtual ~HostMessageFilter() {}
95 104
105 void OnIdleState(bool idle);
106
107 BrowserPpapiHostImpl* browser_ppapi_host_impl_; // Not owned;
96 ppapi::host::PpapiHost* ppapi_host_; 108 ppapi::host::PpapiHost* ppapi_host_;
97 }; 109 };
98 110
111 scoped_ptr<BrowserPpapiHost::Delegate> delegate_;
99 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_; 112 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_;
100 base::ProcessHandle plugin_process_handle_; 113 base::ProcessHandle plugin_process_handle_;
101 std::string plugin_name_; 114 std::string plugin_name_;
102 base::FilePath plugin_path_; 115 base::FilePath plugin_path_;
103 base::FilePath profile_data_directory_; 116 base::FilePath profile_data_directory_;
104 117
105 // If true, this refers to a plugin running in the renderer process. 118 // If true, this refers to a plugin running in the renderer process.
106 bool in_process_; 119 bool in_process_;
107 120
108 // If true, this is an external plugin, i.e. created by the embedder using 121 // If true, this is an external plugin, i.e. created by the embedder using
109 // BrowserPpapiHost::CreateExternalPluginProcess. 122 // BrowserPpapiHost::CreateExternalPluginProcess.
110 bool external_plugin_; 123 bool external_plugin_;
111 124
112 scoped_refptr<SSLContextHelper> ssl_context_helper_; 125 scoped_refptr<SSLContextHelper> ssl_context_helper_;
113 126
114 // Tracks all PP_Instances in this plugin and associated renderer-related 127 // Tracks all PP_Instances in this plugin and associated renderer-related
115 // data. 128 // data.
116 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap; 129 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap;
117 InstanceMap instance_map_; 130 InstanceMap instance_map_;
118 131
119 scoped_refptr<HostMessageFilter> message_filter_; 132 scoped_refptr<HostMessageFilter> message_filter_;
120 133
121 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); 134 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl);
122 }; 135 };
123 136
124 } // namespace content 137 } // namespace content
125 138
126 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 139 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698