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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 virtual void LogWithSource(PP_Instance instance, | 67 virtual void LogWithSource(PP_Instance instance, |
68 PP_LogLevel level, | 68 PP_LogLevel level, |
69 const std::string& source, | 69 const std::string& source, |
70 const std::string& value) OVERRIDE; | 70 const std::string& value) OVERRIDE; |
71 virtual void BroadcastLogWithSource(PP_Module module, | 71 virtual void BroadcastLogWithSource(PP_Module module, |
72 PP_LogLevel level, | 72 PP_LogLevel level, |
73 const std::string& source, | 73 const std::string& source, |
74 const std::string& value) OVERRIDE; | 74 const std::string& value) OVERRIDE; |
75 virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; | 75 virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; |
76 base::TaskRunner* GetFileTaskRunner() OVERRIDE; | 76 base::TaskRunner* GetFileTaskRunner() OVERRIDE; |
| 77 virtual void MarkPluginIsActive() OVERRIDE; |
77 | 78 |
78 // Returns the channel for sending to the browser. | 79 // Returns the channel for sending to the browser. |
79 IPC::Sender* GetBrowserSender(); | 80 IPC::Sender* GetBrowserSender(); |
80 | 81 |
81 // Returns the language code of the current UI language. | 82 // Returns the language code of the current UI language. |
82 std::string GetUILanguage(); | 83 std::string GetUILanguage(); |
83 | 84 |
84 // Sets the active url which is reported by breakpad. | 85 // Sets the active url which is reported by breakpad. |
85 void SetActiveURL(const std::string& url); | 86 void SetActiveURL(const std::string& url); |
86 | 87 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // is known. This will be used for error logging. | 127 // is known. This will be used for error logging. |
127 void set_plugin_name(const std::string& name) { plugin_name_ = name; } | 128 void set_plugin_name(const std::string& name) { plugin_name_ = name; } |
128 | 129 |
129 // The embedder should call this function when the command line is known. | 130 // The embedder should call this function when the command line is known. |
130 void set_command_line(const std::string& c) { command_line_ = c; } | 131 void set_command_line(const std::string& c) { command_line_ = c; } |
131 | 132 |
132 ResourceReplyThreadRegistrar* resource_reply_thread_registrar() { | 133 ResourceReplyThreadRegistrar* resource_reply_thread_registrar() { |
133 return resource_reply_thread_registrar_.get(); | 134 return resource_reply_thread_registrar_.get(); |
134 } | 135 } |
135 | 136 |
| 137 // Interval to limit how many IPC messages are sent indicating that the plugin |
| 138 // is active and should be kept alive. The value must be smaller than any |
| 139 // threshold used to kill inactive plugins by the embedder host. |
| 140 int keepalive_throttle_interval_milliseconds() const; |
| 141 void set_keepalive_throttle_interval_milliseconds(int i); |
| 142 |
136 private: | 143 private: |
137 class BrowserSender; | 144 class BrowserSender; |
138 | 145 |
139 // PpapiGlobals overrides. | 146 // PpapiGlobals overrides. |
140 virtual bool IsPluginGlobals() const OVERRIDE; | 147 virtual bool IsPluginGlobals() const OVERRIDE; |
141 | 148 |
| 149 // Locks the proxy lock and releases the throttle on keepalive IPC messages. |
| 150 void OnReleaseKeepaliveThrottle(); |
| 151 |
142 static PluginGlobals* plugin_globals_; | 152 static PluginGlobals* plugin_globals_; |
143 | 153 |
144 PluginProxyDelegate* plugin_proxy_delegate_; | 154 PluginProxyDelegate* plugin_proxy_delegate_; |
145 PluginResourceTracker plugin_resource_tracker_; | 155 PluginResourceTracker plugin_resource_tracker_; |
146 PluginVarTracker plugin_var_tracker_; | 156 PluginVarTracker plugin_var_tracker_; |
147 scoped_refptr<CallbackTracker> callback_tracker_; | 157 scoped_refptr<CallbackTracker> callback_tracker_; |
148 | 158 |
149 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; | 159 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; |
150 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it | 160 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it |
151 // must be initialized after msg_loop_slot_ (hence the order here). | 161 // must be initialized after msg_loop_slot_ (hence the order here). |
152 scoped_refptr<MessageLoopResource> loop_for_main_thread_; | 162 scoped_refptr<MessageLoopResource> loop_for_main_thread_; |
153 | 163 |
154 // Name of the plugin used for error logging. This will be empty until | 164 // Name of the plugin used for error logging. This will be empty until |
155 // set_plugin_name is called. | 165 // set_plugin_name is called. |
156 std::string plugin_name_; | 166 std::string plugin_name_; |
157 | 167 |
158 // Command line for the plugin. This will be empty until set_command_line is | 168 // Command line for the plugin. This will be empty until set_command_line is |
159 // called. | 169 // called. |
160 std::string command_line_; | 170 std::string command_line_; |
161 | 171 |
162 scoped_ptr<BrowserSender> browser_sender_; | 172 scoped_ptr<BrowserSender> browser_sender_; |
163 | 173 |
164 // Thread for performing potentially blocking file operations. It's created | 174 // Thread for performing potentially blocking file operations. It's created |
165 // lazily, since it might not be needed. | 175 // lazily, since it might not be needed. |
166 scoped_ptr<base::Thread> file_thread_; | 176 scoped_ptr<base::Thread> file_thread_; |
167 | 177 |
168 scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; | 178 scoped_refptr<ResourceReplyThreadRegistrar> resource_reply_thread_registrar_; |
169 | 179 |
| 180 // Indicates activity by the plugin. Used to monitor when a plugin can be |
| 181 // shutdown due to idleness. Current needs do not require differentiating |
| 182 // between idle state between multiple instances, if any are active they are |
| 183 // all considered active. |
| 184 bool plugin_recently_active_; |
| 185 |
| 186 int keepalive_throttle_interval_milliseconds_; |
| 187 |
| 188 // Member variables should appear before the WeakPtrFactory, see weak_ptr.h. |
| 189 base::WeakPtrFactory<PluginGlobals> weak_factory_; |
| 190 |
170 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); | 191 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); |
171 }; | 192 }; |
172 | 193 |
173 } // namespace proxy | 194 } // namespace proxy |
174 } // namespace ppapi | 195 } // namespace ppapi |
175 | 196 |
176 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 197 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
OLD | NEW |