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

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: diii 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 "base/memory/weak_ptr.h"
15 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h" 16 #include "content/browser/renderer_host/pepper/content_browser_pepper_host_facto ry.h"
16 #include "content/browser/renderer_host/pepper/ssl_context_helper.h" 17 #include "content/browser/renderer_host/pepper/ssl_context_helper.h"
17 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
18 #include "content/common/pepper_renderer_instance_data.h" 19 #include "content/common/pepper_renderer_instance_data.h"
19 #include "content/public/browser/browser_ppapi_host.h" 20 #include "content/public/browser/browser_ppapi_host.h"
20 #include "content/public/common/process_type.h" 21 #include "content/public/common/process_type.h"
21 #include "ipc/ipc_channel_proxy.h" 22 #include "ipc/ipc_channel_proxy.h"
22 #include "ppapi/host/ppapi_host.h" 23 #include "ppapi/host/ppapi_host.h"
23 24
24 namespace content { 25 namespace content {
(...skipping 20 matching lines...) Expand all
45 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE; 46 virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE;
46 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE; 47 virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE;
47 virtual bool GetRenderViewIDsForInstance(PP_Instance instance, 48 virtual bool GetRenderViewIDsForInstance(PP_Instance instance,
48 int* render_process_id, 49 int* render_process_id,
49 int* render_view_id) const OVERRIDE; 50 int* render_view_id) const OVERRIDE;
50 virtual const std::string& GetPluginName() OVERRIDE; 51 virtual const std::string& GetPluginName() OVERRIDE;
51 virtual const base::FilePath& GetPluginPath() OVERRIDE; 52 virtual const base::FilePath& GetPluginPath() OVERRIDE;
52 virtual const base::FilePath& GetProfileDataDirectory() OVERRIDE; 53 virtual const base::FilePath& GetProfileDataDirectory() OVERRIDE;
53 virtual GURL GetDocumentURLForInstance(PP_Instance instance) OVERRIDE; 54 virtual GURL GetDocumentURLForInstance(PP_Instance instance) OVERRIDE;
54 virtual GURL GetPluginURLForInstance(PP_Instance instance) OVERRIDE; 55 virtual GURL GetPluginURLForInstance(PP_Instance instance) OVERRIDE;
56 virtual void SetOnIdleChangeCallback(
57 const BrowserPpapiHost::OnIdleChangeCallback callback) OVERRIDE;
dmichael (off chromium) 2013/11/15 18:26:22 could be const&
scheib 2013/12/11 21:35:40 Done.
58
55 59
56 void set_plugin_process_handle(base::ProcessHandle handle) { 60 void set_plugin_process_handle(base::ProcessHandle handle) {
57 plugin_process_handle_ = handle; 61 plugin_process_handle_ = handle;
58 } 62 }
59 63
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
(...skipping 11 matching lines...) Expand all
76 } 80 }
77 81
78 private: 82 private:
79 friend class BrowserPpapiHostTest; 83 friend class BrowserPpapiHostTest;
80 84
81 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted, 85 // Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted,
82 // preventing us from returning these to embedders without holding a 86 // preventing us from returning these to embedders without holding a
83 // reference. To avoid that, define a message filter object. 87 // reference. To avoid that, define a message filter object.
84 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter { 88 class HostMessageFilter : public IPC::ChannelProxy::MessageFilter {
85 public: 89 public:
86 explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host) 90 typedef base::Callback<void (bool idle)> OnIdleChangeCallback;
87 : ppapi_host_(ppapi_host) {} 91
92 HostMessageFilter(ppapi::host::PpapiHost* ppapi_host,
93 const OnIdleChangeCallback on_idle_change_callback);
94
88 // IPC::ChannelProxy::MessageFilter. 95 // IPC::ChannelProxy::MessageFilter.
89 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 96 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
90 97
91 void OnHostDestroyed(); 98 void OnHostDestroyed();
92 99
93 private: 100 private:
94 virtual ~HostMessageFilter() {} 101 virtual ~HostMessageFilter();
102
103 void OnIdleStateChange(bool idle);
95 104
96 ppapi::host::PpapiHost* ppapi_host_; 105 ppapi::host::PpapiHost* ppapi_host_;
106 OnIdleChangeCallback on_idle_change_callback_;
97 }; 107 };
98 108
109 void OnIdleChange(bool idle);
110
99 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_; 111 scoped_ptr<ppapi::host::PpapiHost> ppapi_host_;
100 base::ProcessHandle plugin_process_handle_; 112 base::ProcessHandle plugin_process_handle_;
101 std::string plugin_name_; 113 std::string plugin_name_;
102 base::FilePath plugin_path_; 114 base::FilePath plugin_path_;
103 base::FilePath profile_data_directory_; 115 base::FilePath profile_data_directory_;
104 116
105 // If true, this refers to a plugin running in the renderer process. 117 // If true, this refers to a plugin running in the renderer process.
106 bool in_process_; 118 bool in_process_;
107 119
108 // If true, this is an external plugin, i.e. created by the embedder using 120 // If true, this is an external plugin, i.e. created by the embedder using
109 // BrowserPpapiHost::CreateExternalPluginProcess. 121 // BrowserPpapiHost::CreateExternalPluginProcess.
110 bool external_plugin_; 122 bool external_plugin_;
111 123
112 scoped_refptr<SSLContextHelper> ssl_context_helper_; 124 scoped_refptr<SSLContextHelper> ssl_context_helper_;
113 125
114 // Tracks all PP_Instances in this plugin and associated renderer-related 126 // Tracks all PP_Instances in this plugin and associated renderer-related
115 // data. 127 // data.
116 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap; 128 typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap;
117 InstanceMap instance_map_; 129 InstanceMap instance_map_;
118 130
119 scoped_refptr<HostMessageFilter> message_filter_; 131 scoped_refptr<HostMessageFilter> message_filter_;
120 132
133 BrowserPpapiHost::OnIdleChangeCallback on_idle_change_callback_;
134
135 // Member variables should appear before the WeakPtrFactory, see weak_ptr.h.
136 base::WeakPtrFactory<BrowserPpapiHostImpl> weak_factory_;
137
121 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl); 138 DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl);
122 }; 139 };
123 140
124 } // namespace content 141 } // namespace content
125 142
126 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_ 143 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_BROWSER_PPAPI_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698