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_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class CommandLine; | 24 class CommandLine; |
25 | 25 |
26 class CONTENT_EXPORT GpuDataManagerImpl | 26 class CONTENT_EXPORT GpuDataManagerImpl |
27 : public NON_EXPORTED_BASE(content::GpuDataManager) { | 27 : public NON_EXPORTED_BASE(content::GpuDataManager) { |
28 public: | 28 public: |
29 // Getter for the singleton. This will return NULL on failure. | 29 // Getter for the singleton. This will return NULL on failure. |
30 static GpuDataManagerImpl* GetInstance(); | 30 static GpuDataManagerImpl* GetInstance(); |
31 | 31 |
32 // GpuDataManager implementation. | 32 // GpuDataManager implementation. |
33 virtual void Initialize( | 33 virtual void InitializeForTesting( |
34 const std::string& browser_version_string, | |
35 const std::string& gpu_blacklist_json) OVERRIDE; | |
36 virtual void Initialize( | |
37 const std::string& browser_version_string, | |
38 const std::string& gpu_blacklist_json, | 34 const std::string& gpu_blacklist_json, |
39 const content::GPUInfo& gpu_info) OVERRIDE; | 35 const content::GPUInfo& gpu_info) OVERRIDE; |
40 virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE; | 36 virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE; |
41 virtual content::GpuSwitchingOption GetGpuSwitchingOption() const OVERRIDE; | 37 virtual content::GpuSwitchingOption GetGpuSwitchingOption() const OVERRIDE; |
42 virtual base::ListValue* GetBlacklistReasons() const OVERRIDE; | 38 virtual base::ListValue* GetBlacklistReasons() const OVERRIDE; |
43 virtual std::string GetBlacklistVersion() const OVERRIDE; | 39 virtual std::string GetBlacklistVersion() const OVERRIDE; |
44 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; | 40 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; |
45 virtual bool GpuAccessAllowed() const OVERRIDE; | 41 virtual bool GpuAccessAllowed() const OVERRIDE; |
46 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; | 42 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; |
47 virtual bool IsCompleteGpuInfoAvailable() const OVERRIDE; | 43 virtual bool IsCompleteGpuInfoAvailable() const OVERRIDE; |
48 virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE; | 44 virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE; |
49 virtual bool ShouldUseSoftwareRendering() const OVERRIDE; | 45 virtual bool ShouldUseSoftwareRendering() const OVERRIDE; |
50 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; | 46 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; |
51 virtual void AddLogMessage(int level, const std::string& header, | 47 virtual void AddLogMessage(int level, const std::string& header, |
52 const std::string& message) OVERRIDE; | 48 const std::string& message) OVERRIDE; |
53 virtual base::ListValue* GetLogMessages() const OVERRIDE; | 49 virtual base::ListValue* GetLogMessages() const OVERRIDE; |
54 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; | 50 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; |
55 virtual void RemoveObserver( | 51 virtual void RemoveObserver( |
56 content::GpuDataManagerObserver* observer) OVERRIDE; | 52 content::GpuDataManagerObserver* observer) OVERRIDE; |
57 | 53 |
| 54 // This collects preliminary GPU info, load GpuBlacklist, and compute the |
| 55 // preliminary blacklisted features; it should only be called at browser |
| 56 // startup time in UI thread before the IO restriction is turned on. |
| 57 void Initialize(); |
| 58 |
58 // Only update if the current GPUInfo is not finalized. If blacklist is | 59 // Only update if the current GPUInfo is not finalized. If blacklist is |
59 // loaded, run through blacklist and update blacklisted features. | 60 // loaded, run through blacklist and update blacklisted features. |
60 void UpdateGpuInfo(const content::GPUInfo& gpu_info); | 61 void UpdateGpuInfo(const content::GPUInfo& gpu_info); |
61 | 62 |
62 void UpdateVideoMemoryUsageStats( | 63 void UpdateVideoMemoryUsageStats( |
63 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); | 64 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); |
64 | 65 |
65 // Insert disable-feature switches corresponding to preliminary gpu feature | 66 // Insert disable-feature switches corresponding to preliminary gpu feature |
66 // flags into the renderer process command line. | 67 // flags into the renderer process command line. |
67 void AppendRendererCommandLine(CommandLine* command_line) const; | 68 void AppendRendererCommandLine(CommandLine* command_line) const; |
(...skipping 26 matching lines...) Expand all Loading... |
94 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideBlacklisting); | 95 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideBlacklisting); |
95 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideExceptions); | 96 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideExceptions); |
96 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, BlacklistCard); | 97 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, BlacklistCard); |
97 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuInfoUpdate); | 98 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuInfoUpdate); |
98 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, | 99 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
99 GPUVideoMemoryUsageStatsUpdate); | 100 GPUVideoMemoryUsageStatsUpdate); |
100 | 101 |
101 GpuDataManagerImpl(); | 102 GpuDataManagerImpl(); |
102 virtual ~GpuDataManagerImpl(); | 103 virtual ~GpuDataManagerImpl(); |
103 | 104 |
| 105 void InitializeImpl(const std::string& gpu_blacklist_json, |
| 106 const content::GPUInfo& gpu_info); |
| 107 |
104 void UpdateBlacklistedFeatures(content::GpuFeatureType features); | 108 void UpdateBlacklistedFeatures(content::GpuFeatureType features); |
105 | 109 |
106 // This should only be called once at initialization time, when preliminary | 110 // This should only be called once at initialization time, when preliminary |
107 // gpu info is collected. | 111 // gpu info is collected. |
108 void UpdatePreliminaryBlacklistedFeatures(); | 112 void UpdatePreliminaryBlacklistedFeatures(); |
109 | 113 |
110 // Notify all observers whenever there is a GPU info update. | 114 // Notify all observers whenever there is a GPU info update. |
111 void NotifyGpuInfoUpdate(); | 115 void NotifyGpuInfoUpdate(); |
112 | 116 |
113 // Try to switch to software rendering, if possible and necessary. | 117 // Try to switch to software rendering, if possible and necessary. |
(...skipping 28 matching lines...) Expand all Loading... |
142 bool card_blacklisted_; | 146 bool card_blacklisted_; |
143 | 147 |
144 // We disable histogram stuff in testing, especially in unit tests because | 148 // We disable histogram stuff in testing, especially in unit tests because |
145 // they cause random failures. | 149 // they cause random failures. |
146 bool update_histograms_; | 150 bool update_histograms_; |
147 | 151 |
148 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); | 152 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); |
149 }; | 153 }; |
150 | 154 |
151 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 155 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
OLD | NEW |