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

Unified Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h

Issue 929483004: Plugin Power Saver: Throttled Plugins should block TCPSocket reads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
index 101e0ebae0e29111ec4d6425a5f3a8f1be9e9e8e..92fbd47764f7ea66974b57c213df772d8db52bbf 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -10,9 +10,11 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/containers/scoped_ptr_hash_map.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "base/process/process.h"
#include "content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h"
#include "content/browser/renderer_host/pepper/ssl_context_helper.h"
@@ -31,6 +33,13 @@ namespace content {
class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
public:
+ class InstanceObserver {
+ public:
+ // Called when the plugin instance is throttled or unthrottled because of
+ // the Plugin Power Saver feature. Invoked on the IO thread.
+ virtual void OnThrottleStateChanged(bool is_throttled) = 0;
+ };
+
// The creator is responsible for calling set_plugin_process as soon as it is
// known (we start the process asynchronously so it won't be known when this
// object is created).
@@ -73,6 +82,12 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
const PepperRendererInstanceData& instance_data);
void DeleteInstance(PP_Instance instance);
+ void AddInstanceObserver(PP_Instance instance, InstanceObserver* observer);
+ void RemoveInstanceObserver(PP_Instance instance, InstanceObserver* observer);
+
+ void OnThrottleStateChanged(PP_Instance instance, bool is_throttled);
+ bool IsThrottled(PP_Instance instance) const;
+
scoped_refptr<IPC::MessageFilter> message_filter() {
return message_filter_;
}
@@ -108,6 +123,14 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
BrowserPpapiHostImpl* browser_ppapi_host_impl_;
};
+ struct InstanceData {
+ InstanceData();
+ ~InstanceData();
+
+ PepperRendererInstanceData renderer_data;
+ bool is_throttled;
+ };
+
// Reports plugin activity to the callback set with SetOnKeepaliveCallback.
void OnKeepalive();
@@ -126,11 +149,13 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
scoped_refptr<SSLContextHelper> ssl_context_helper_;
- // Tracks all PP_Instances in this plugin and associated renderer-related
- // data.
- typedef std::map<PP_Instance, PepperRendererInstanceData> InstanceMap;
+ // Tracks all PP_Instances in this plugin and associated data.
+ typedef std::map<PP_Instance, InstanceData> InstanceMap;
InstanceMap instance_map_;
+ base::ScopedPtrHashMap<PP_Instance, ObserverList<InstanceObserver>>
+ instance_observers_map_;
dmichael (off chromium) 2015/02/18 21:44:39 Couldn't you still put it in InstanceData, and mak
tommycli 2015/02/18 22:17:27 Done. Ah. I didn't see that.
+
scoped_refptr<HostMessageFilter> message_filter_;
BrowserPpapiHost::OnKeepaliveCallback on_keepalive_callback_;
« no previous file with comments | « content/browser/ppapi_plugin_process_host.cc ('k') | content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698