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 PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/thread_local_storage.h" | 13 #include "base/threading/thread_local_storage.h" |
13 #include "ppapi/proxy/connection.h" | 14 #include "ppapi/proxy/connection.h" |
14 #include "ppapi/proxy/plugin_resource_tracker.h" | 15 #include "ppapi/proxy/plugin_resource_tracker.h" |
15 #include "ppapi/proxy/plugin_var_tracker.h" | 16 #include "ppapi/proxy/plugin_var_tracker.h" |
16 #include "ppapi/proxy/ppapi_proxy_export.h" | 17 #include "ppapi/proxy/ppapi_proxy_export.h" |
17 #include "ppapi/shared_impl/callback_tracker.h" | 18 #include "ppapi/shared_impl/callback_tracker.h" |
18 #include "ppapi/shared_impl/ppapi_globals.h" | 19 #include "ppapi/shared_impl/ppapi_globals.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class Thread; | 22 class Thread; |
22 } | 23 } |
23 namespace IPC { | 24 namespace IPC { |
24 class Sender; | 25 class Sender; |
25 } | 26 } |
26 | 27 |
27 struct PP_BrowserFont_Trusted_Description; | 28 struct PP_BrowserFont_Trusted_Description; |
28 | 29 |
29 namespace ppapi { | 30 namespace ppapi { |
30 | 31 |
31 struct Preferences; | 32 struct Preferences; |
32 | 33 |
33 namespace proxy { | 34 namespace proxy { |
34 | 35 |
35 class MessageLoopResource; | 36 class MessageLoopResource; |
| 37 class PluginMessageFilter; |
36 class PluginProxyDelegate; | 38 class PluginProxyDelegate; |
37 class ResourceReplyThreadRegistrar; | 39 class ResourceReplyThreadRegistrar; |
| 40 class UDPSocketFilter; |
38 | 41 |
39 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { | 42 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { |
40 public: | 43 public: |
41 PluginGlobals(); | 44 explicit PluginGlobals(const scoped_refptr<base::TaskRunner>& task_runner); |
42 explicit PluginGlobals(PpapiGlobals::PerThreadForTest); | 45 PluginGlobals(PpapiGlobals::PerThreadForTest, |
| 46 const scoped_refptr<base::TaskRunner>& task_runner); |
43 virtual ~PluginGlobals(); | 47 virtual ~PluginGlobals(); |
44 | 48 |
45 // Getter for the global singleton. Generally, you should use | 49 // Getter for the global singleton. Generally, you should use |
46 // PpapiGlobals::Get() when possible. Use this only when you need some | 50 // PpapiGlobals::Get() when possible. Use this only when you need some |
47 // plugin-specific functionality. | 51 // plugin-specific functionality. |
48 inline static PluginGlobals* Get() { | 52 inline static PluginGlobals* Get() { |
49 // Explicitly crash if this is the wrong process type, we want to get | 53 // Explicitly crash if this is the wrong process type, we want to get |
50 // crash reports. | 54 // crash reports. |
51 CHECK(PpapiGlobals::Get()->IsPluginGlobals()); | 55 CHECK(PpapiGlobals::Get()->IsPluginGlobals()); |
52 return static_cast<PluginGlobals*>(PpapiGlobals::Get()); | 56 return static_cast<PluginGlobals*>(PpapiGlobals::Get()); |
(...skipping 19 matching lines...) Expand all Loading... |
72 PP_LogLevel level, | 76 PP_LogLevel level, |
73 const std::string& source, | 77 const std::string& source, |
74 const std::string& value) override; | 78 const std::string& value) override; |
75 virtual MessageLoopShared* GetCurrentMessageLoop() override; | 79 virtual MessageLoopShared* GetCurrentMessageLoop() override; |
76 base::TaskRunner* GetFileTaskRunner() override; | 80 base::TaskRunner* GetFileTaskRunner() override; |
77 virtual void MarkPluginIsActive() override; | 81 virtual void MarkPluginIsActive() override; |
78 | 82 |
79 // Returns the channel for sending to the browser. | 83 // Returns the channel for sending to the browser. |
80 IPC::Sender* GetBrowserSender(); | 84 IPC::Sender* GetBrowserSender(); |
81 | 85 |
| 86 base::TaskRunner* ipc_task_runner() { return ipc_task_runner_.get(); } |
| 87 |
82 // Returns the language code of the current UI language. | 88 // Returns the language code of the current UI language. |
83 std::string GetUILanguage(); | 89 std::string GetUILanguage(); |
84 | 90 |
85 // Sets the active url which is reported by breakpad. | 91 // Sets the active url which is reported by breakpad. |
86 void SetActiveURL(const std::string& url); | 92 void SetActiveURL(const std::string& url); |
87 | 93 |
88 PP_Resource CreateBrowserFont( | 94 PP_Resource CreateBrowserFont( |
89 Connection connection, | 95 Connection connection, |
90 PP_Instance instance, | 96 PP_Instance instance, |
91 const PP_BrowserFont_Trusted_Description& desc, | 97 const PP_BrowserFont_Trusted_Description& desc, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // is known. This will be used for error logging. | 135 // is known. This will be used for error logging. |
130 void set_plugin_name(const std::string& name) { plugin_name_ = name; } | 136 void set_plugin_name(const std::string& name) { plugin_name_ = name; } |
131 | 137 |
132 // The embedder should call this function when the command line is known. | 138 // The embedder should call this function when the command line is known. |
133 void set_command_line(const std::string& c) { command_line_ = c; } | 139 void set_command_line(const std::string& c) { command_line_ = c; } |
134 | 140 |
135 ResourceReplyThreadRegistrar* resource_reply_thread_registrar() { | 141 ResourceReplyThreadRegistrar* resource_reply_thread_registrar() { |
136 return resource_reply_thread_registrar_.get(); | 142 return resource_reply_thread_registrar_.get(); |
137 } | 143 } |
138 | 144 |
| 145 UDPSocketFilter* udp_socket_filter() const { |
| 146 return udp_socket_filter_.get(); |
| 147 } |
| 148 // Add any necessary ResourceMessageFilters to the PluginMessageFilter so |
| 149 // that they can receive and handle appropriate messages on the IO thread. |
| 150 void RegisterResourceMessageFilters( |
| 151 ppapi::proxy::PluginMessageFilter* plugin_filter); |
| 152 |
139 // Interval to limit how many IPC messages are sent indicating that the plugin | 153 // Interval to limit how many IPC messages are sent indicating that the plugin |
140 // is active and should be kept alive. The value must be smaller than any | 154 // is active and should be kept alive. The value must be smaller than any |
141 // threshold used to kill inactive plugins by the embedder host. | 155 // threshold used to kill inactive plugins by the embedder host. |
142 void set_keepalive_throttle_interval_milliseconds(unsigned i); | 156 void set_keepalive_throttle_interval_milliseconds(unsigned i); |
143 | 157 |
144 private: | 158 private: |
145 class BrowserSender; | 159 class BrowserSender; |
146 | 160 |
147 // PpapiGlobals overrides. | 161 // PpapiGlobals overrides. |
148 virtual bool IsPluginGlobals() const override; | 162 virtual bool IsPluginGlobals() const override; |
(...skipping 16 matching lines...) Expand all Loading... |
165 // Name of the plugin used for error logging. This will be empty until | 179 // Name of the plugin used for error logging. This will be empty until |
166 // set_plugin_name is called. | 180 // set_plugin_name is called. |
167 std::string plugin_name_; | 181 std::string plugin_name_; |
168 | 182 |
169 // Command line for the plugin. This will be empty until set_command_line is | 183 // Command line for the plugin. This will be empty until set_command_line is |
170 // called. | 184 // called. |
171 std::string command_line_; | 185 std::string command_line_; |
172 | 186 |
173 scoped_ptr<BrowserSender> browser_sender_; | 187 scoped_ptr<BrowserSender> browser_sender_; |
174 | 188 |
| 189 scoped_refptr<base::TaskRunner> ipc_task_runner_; |
| 190 |
175 // Thread for performing potentially blocking file operations. It's created | 191 // Thread for performing potentially blocking file operations. It's created |
176 // lazily, since it might not be needed. | 192 // lazily, since it might not be needed. |
177 scoped_ptr<base::Thread> file_thread_; | 193 scoped_ptr<base::Thread> file_thread_; |
178 | 194 |
179 scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; | 195 scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; |
180 | 196 |
| 197 scoped_refptr<UDPSocketFilter> udp_socket_filter_; |
| 198 |
181 // Indicates activity by the plugin. Used to monitor when a plugin can be | 199 // Indicates activity by the plugin. Used to monitor when a plugin can be |
182 // shutdown due to idleness. Current needs do not require differentiating | 200 // shutdown due to idleness. Current needs do not require differentiating |
183 // between idle state between multiple instances, if any are active they are | 201 // between idle state between multiple instances, if any are active they are |
184 // all considered active. | 202 // all considered active. |
185 bool plugin_recently_active_; | 203 bool plugin_recently_active_; |
186 | 204 |
187 unsigned keepalive_throttle_interval_milliseconds_; | 205 unsigned keepalive_throttle_interval_milliseconds_; |
188 | 206 |
189 // Member variables should appear before the WeakPtrFactory, see weak_ptr.h. | 207 // Member variables should appear before the WeakPtrFactory, see weak_ptr.h. |
190 base::WeakPtrFactory<PluginGlobals> weak_factory_; | 208 base::WeakPtrFactory<PluginGlobals> weak_factory_; |
191 | 209 |
192 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); | 210 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); |
193 }; | 211 }; |
194 | 212 |
195 } // namespace proxy | 213 } // namespace proxy |
196 } // namespace ppapi | 214 } // namespace ppapi |
197 | 215 |
198 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 216 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
OLD | NEW |