Chromium Code Reviews| 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 CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/common/gpu_feature_type.h" | 11 #include "content/public/common/gpu_feature_type.h" |
| 12 #include "content/public/common/gpu_switching_option.h" | 12 #include "content/public/common/gpu_switching_option.h" |
| 13 | 13 |
| 14 class FilePath; | 14 class FilePath; |
| 15 class GURL; | |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class ListValue; | 18 class ListValue; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 class GpuDataManagerObserver; | 23 class GpuDataManagerObserver; |
| 23 struct GPUInfo; | 24 struct GPUInfo; |
| 24 | 25 |
| 25 // This class is fully thread-safe. | 26 // This class is fully thread-safe. |
| 26 class GpuDataManager { | 27 class GpuDataManager { |
| 27 public: | 28 public: |
| 29 // Indicates the guilt level of a domain which caused a GPU reset. | |
| 30 // If a domain is 100% known to be guilty of resetting the GPU, then | |
| 31 // it will generally not cause other domains' use of 3D APIs to be | |
| 32 // blocked, unless system stability would be compromised. | |
| 33 enum DomainGuilt { | |
| 34 kKnownGuilty, | |
|
jam
2012/11/14 18:21:57
nit: here and below, please use chrome recommended
Ken Russell (switch to Gerrit)
2012/11/14 19:09:14
Will change -- sorry, I'd missed this in the Chrom
| |
| 35 kUnknownGuilt | |
| 36 }; | |
| 37 | |
| 38 // Indicates the reason that access to a given client API (like | |
| 39 // WebGL or Pepper 3D) was blocked or not. This state is distinct | |
| 40 // from blacklisting of an entire feature. | |
| 41 enum DomainBlockStatus { | |
| 42 kDomainBlocked, | |
| 43 kAllDomainsBlocked, | |
| 44 kNotBlocked | |
| 45 }; | |
| 46 | |
| 28 // Getter for the singleton. | 47 // Getter for the singleton. |
| 29 CONTENT_EXPORT static GpuDataManager* GetInstance(); | 48 CONTENT_EXPORT static GpuDataManager* GetInstance(); |
| 30 | 49 |
| 31 virtual void InitializeForTesting(const std::string& gpu_blacklist_json, | 50 virtual void InitializeForTesting(const std::string& gpu_blacklist_json, |
| 32 const content::GPUInfo& gpu_info) = 0; | 51 const content::GPUInfo& gpu_info) = 0; |
| 33 | 52 |
| 34 virtual std::string GetBlacklistVersion() const = 0; | 53 virtual std::string GetBlacklistVersion() const = 0; |
| 35 | 54 |
| 36 virtual GpuFeatureType GetBlacklistedFeatures() const = 0; | 55 virtual GpuFeatureType GetBlacklistedFeatures() const = 0; |
| 37 | 56 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 96 |
| 78 // Registers/unregister |observer|. | 97 // Registers/unregister |observer|. |
| 79 virtual void AddObserver(GpuDataManagerObserver* observer) = 0; | 98 virtual void AddObserver(GpuDataManagerObserver* observer) = 0; |
| 80 virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0; | 99 virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0; |
| 81 | 100 |
| 82 // Notifies the gpu process about the number of browser windows, so | 101 // Notifies the gpu process about the number of browser windows, so |
| 83 // they can be used to determine managed memory allocation. | 102 // they can be used to determine managed memory allocation. |
| 84 virtual void SetWindowCount(uint32 count) = 0; | 103 virtual void SetWindowCount(uint32 count) = 0; |
| 85 virtual uint32 GetWindowCount() const = 0; | 104 virtual uint32 GetWindowCount() const = 0; |
| 86 | 105 |
| 106 // Maintenance of domains requiring explicit user permission before | |
| 107 // using client-facing 3D APIs (WebGL, Pepper 3D), either because | |
| 108 // the domain has caused the GPU to reset, or because too many GPU | |
| 109 // resets have been observed globally recently, and system stability | |
| 110 // might be compromised. | |
| 111 // | |
| 112 // The given URL may be a partial URL (including at least the host) | |
| 113 // or a full URL to a page. | |
| 114 virtual void BlockDomainFrom3DAPIs(const GURL& url, DomainGuilt guilt) = 0; | |
| 115 virtual DomainBlockStatus Are3DAPIsBlocked( | |
| 116 const GURL& url) const = 0; | |
| 117 virtual void UnblockDomainFrom3DAPIs(const GURL& url) = 0; | |
| 118 // Disables domain blocking. For use only in tests. | |
| 119 virtual void DisableDomainBlockingFor3DAPIsForTesting() = 0; | |
| 120 | |
| 87 protected: | 121 protected: |
| 88 virtual ~GpuDataManager() {} | 122 virtual ~GpuDataManager() {} |
| 89 }; | 123 }; |
| 90 | 124 |
| 91 }; // namespace content | 125 }; // namespace content |
| 92 | 126 |
| 93 #endif // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ | 127 #endif // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ |
| OLD | NEW |