Chromium Code Reviews| Index: content/browser/gpu/gpu_data_manager_impl.h |
| diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h |
| index 9a044b760ceca8e1dc4484940f3c2ebbac05aec2..65c1e469bca588043599b47aa7f7796b0881dd4b 100644 |
| --- a/content/browser/gpu/gpu_data_manager_impl.h |
| +++ b/content/browser/gpu/gpu_data_manager_impl.h |
| @@ -5,7 +5,8 @@ |
| #ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
| #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
| -#include <set> |
| +#include <list> |
| +#include <map> |
| #include <string> |
| #include "base/compiler_specific.h" |
| @@ -15,6 +16,7 @@ |
| #include "base/memory/singleton.h" |
| #include "base/observer_list_threadsafe.h" |
| #include "base/synchronization/lock.h" |
| +#include "base/time.h" |
| #include "base/values.h" |
| #include "content/browser/gpu/gpu_blacklist.h" |
| #include "content/public/browser/gpu_data_manager.h" |
| @@ -22,6 +24,7 @@ |
| #include "content/public/common/gpu_memory_stats.h" |
| class CommandLine; |
| +class GURL; |
| namespace content { |
| @@ -53,6 +56,12 @@ class CONTENT_EXPORT GpuDataManagerImpl |
| virtual void RemoveObserver(GpuDataManagerObserver* observer) OVERRIDE; |
| virtual void SetWindowCount(uint32 count) OVERRIDE; |
| virtual uint32 GetWindowCount() const OVERRIDE; |
| + virtual void BlockDomainFrom3DAPIs( |
| + const GURL& url, DomainGuilt guilt) OVERRIDE; |
| + virtual DomainBlockStatus Are3DAPIsBlocked( |
| + const GURL& url) const OVERRIDE; |
| + virtual void UnblockDomainFrom3DAPIs(const GURL& url) OVERRIDE; |
| + virtual void DisableDomainBlockingFor3DAPIsForTesting() OVERRIDE; |
| // This collects preliminary GPU info, load GpuBlacklist, and compute the |
| // preliminary blacklisted features; it should only be called at browser |
| @@ -92,6 +101,12 @@ class CONTENT_EXPORT GpuDataManagerImpl |
| #endif |
| private: |
| + struct DomainBlockEntry { |
| + DomainGuilt last_guilt; |
| + }; |
| + |
| + typedef std::map<std::string, DomainBlockEntry> DomainBlockMap; |
| + |
| typedef ObserverListThreadSafe<GpuDataManagerObserver> |
| GpuDataManagerObserverList; |
| @@ -108,6 +123,16 @@ class CONTENT_EXPORT GpuDataManagerImpl |
| NoGpuInfoUpdateWithSoftwareRendering); |
| FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| GPUVideoMemoryUsageStatsUpdate); |
| + FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| + BlockAllDomainsFrom3DAPIs); |
| + FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| + UnblockGuiltyDomainFrom3DAPIs); |
| + FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| + UnblockDomainOfUnknownGuiltFrom3DAPIs); |
| + FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| + UnblockOtherDomainFrom3DAPIs); |
| + FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
| + UnblockThisDomainFrom3DAPIs); |
| GpuDataManagerImpl(); |
| virtual ~GpuDataManagerImpl(); |
| @@ -131,6 +156,17 @@ class CONTENT_EXPORT GpuDataManagerImpl |
| // Try to switch to software rendering, if possible and necessary. |
| void EnableSoftwareRenderingIfNecessary(); |
| + // Helper to extract the domain from a given URL. |
| + std::string GetDomainFromURL(const GURL& url) const; |
|
Zhenyao Mo
2012/11/14 16:35:58
nit: this can be a helper defined in anonymous nam
Ken Russell (switch to Gerrit)
2012/11/14 19:09:14
I anticipate this may need to have state in the fu
|
| + |
| + // Implementation functions for blocking of 3D graphics APIs, used |
| + // for unit testing. |
| + void BlockDomainFrom3DAPIsAtTime( |
| + const GURL& url, DomainGuilt guilt, base::Time at_time); |
| + DomainBlockStatus Are3DAPIsBlockedAtTime( |
| + const GURL& url, base::Time at_time) const; |
| + int64 GetBlockAllDomainsDurationInMs() const; |
| + |
| bool complete_gpu_info_already_requested_; |
| GpuFeatureType blacklisted_features_; |
| @@ -163,6 +199,10 @@ class CONTENT_EXPORT GpuDataManagerImpl |
| // Number of currently open windows, to be used in gpu memory allocation. |
| int window_count_; |
| + DomainBlockMap blocked_domains_; |
| + mutable std::list<base::Time> timestamps_of_gpu_resets_; |
| + bool domain_blocking_enabled_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); |
| }; |