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> | |
| 9 | |
| 8 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 9 #include "content/public/common/gpu_feature_type.h" | 11 #include "content/public/common/gpu_feature_type.h" |
| 10 | 12 |
| 11 class FilePath; | 13 class FilePath; |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 class ListValue; | 16 class ListValue; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 19 class GpuDataManagerObserver; | 21 class GpuDataManagerObserver; |
| 20 struct GPUInfo; | 22 struct GPUInfo; |
| 21 | 23 |
| 22 // This class lives on the UI thread. Only methods that explicitly state that | |
|
jbates
2012/08/30 20:29:57
nit: How about explaining the new threading rules
| |
| 23 // they can be called on other threads are thread-safe. | |
| 24 class GpuDataManager { | 24 class GpuDataManager { |
| 25 public: | 25 public: |
| 26 // Getter for the singleton. | 26 // Getter for the singleton. |
| 27 CONTENT_EXPORT static GpuDataManager* GetInstance(); | 27 CONTENT_EXPORT static GpuDataManager* GetInstance(); |
| 28 | 28 |
| 29 // This collects preliminary GPU info; it should only be called at | |
| 30 // browser startup time in UI thread before the IO restriction is turned | |
| 31 // on. | |
| 32 virtual void InitializeGpuInfo() = 0; | |
| 33 | |
| 29 // Can be called on any thread. | 34 // Can be called on any thread. |
| 30 virtual GpuFeatureType GetGpuFeatureType() = 0; | 35 virtual GpuFeatureType GetBlacklistedFeatures() const = 0; |
| 31 | 36 |
| 32 // Gives the new feature flags. This is always called on the UI thread. | 37 // Sets the blacklisted feature flags due to preliminary GPU info. |
| 33 virtual void SetGpuFeatureType(GpuFeatureType feature_type) = 0; | 38 virtual void SetPreliminaryBlacklistedFeatures( |
| 39 GpuFeatureType feature_type) = 0; | |
| 34 | 40 |
| 35 virtual GPUInfo GetGPUInfo() const = 0; | 41 virtual GPUInfo GetGPUInfo() const = 0; |
| 36 | 42 |
| 37 // This indicator might change because we could collect more GPU info or | 43 // This indicator might change because we could collect more GPU info or |
| 38 // because the GPU blacklist could be updated. | 44 // because the GPU blacklist could be updated. |
| 39 // If this returns false, any further GPU access, including launching GPU | 45 // If this returns false, any further GPU access, including launching GPU |
| 40 // process, establish GPU channel, and GPU info collection, should be | 46 // process, establish GPU channel, and GPU info collection, should be |
| 41 // blocked. | 47 // blocked. |
| 42 // Can be called on any thread. | 48 // Can be called on any thread. |
| 43 virtual bool GpuAccessAllowed() = 0; | 49 virtual bool GpuAccessAllowed() const = 0; |
| 44 | 50 |
| 45 // Requests complete GPUinfo if it has not already been requested | 51 // Requests complete GPUinfo if it has not already been requested |
| 46 virtual void RequestCompleteGpuInfoIfNeeded() = 0; | 52 virtual void RequestCompleteGpuInfoIfNeeded() = 0; |
| 47 | 53 |
| 48 virtual bool IsCompleteGPUInfoAvailable() const = 0; | 54 virtual bool IsCompleteGpuInfoAvailable() const = 0; |
| 49 | 55 |
| 50 // Requests that the GPU process report its current video memory usage stats, | 56 // Requests that the GPU process report its current video memory usage stats, |
| 51 // which can be retrieved via the GPU data manager's on-update function. | 57 // which can be retrieved via the GPU data manager's on-update function. |
| 52 virtual void RequestVideoMemoryUsageStatsUpdate() = 0; | 58 virtual void RequestVideoMemoryUsageStatsUpdate() const = 0; |
| 53 | 59 |
| 54 // Returns true if the software rendering should currently be used. | 60 // Returns true if the software rendering should currently be used. |
| 55 virtual bool ShouldUseSoftwareRendering() = 0; | 61 virtual bool ShouldUseSoftwareRendering() const = 0; |
| 56 | 62 |
| 57 // Register a path to the SwiftShader software renderer. | 63 // Register a path to the SwiftShader software renderer. |
| 58 virtual void RegisterSwiftShaderPath(const FilePath& path) = 0; | 64 virtual void RegisterSwiftShaderPath(const FilePath& path) = 0; |
| 59 | 65 |
| 60 virtual const base::ListValue& GetLogMessages() const = 0; | 66 virtual void AddLogMessage( |
| 67 int level, const std::string& header, const std::string& message) = 0; | |
| 68 | |
| 69 // Returns a new copy of the ListValue. Caller is responsible to release | |
| 70 // the returned value. | |
| 71 virtual base::ListValue* GetLogMessages() const = 0; | |
| 61 | 72 |
| 62 // Registers/unregister |observer|. | 73 // Registers/unregister |observer|. |
| 63 virtual void AddObserver(GpuDataManagerObserver* observer) = 0; | 74 virtual void AddObserver(GpuDataManagerObserver* observer) = 0; |
| 64 virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0; | 75 virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0; |
| 65 | 76 |
| 66 protected: | 77 protected: |
| 67 virtual ~GpuDataManager() {} | 78 virtual ~GpuDataManager() {} |
| 68 }; | 79 }; |
| 69 | 80 |
| 70 }; // namespace content | 81 }; // namespace content |
| 71 | 82 |
| 72 #endif // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ | 83 #endif // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_ |
| OLD | NEW |