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

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl_private.h

Issue 14981007: Refactor GpuDataManagerImpl to make it thread-safe. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
7
8 #include <list>
9 #include <map>
10 #include <set>
11 #include <string>
12
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/singleton.h"
15 #include "base/observer_list_threadsafe.h"
16 #include "content/browser/gpu/gpu_blacklist.h"
17 #include "content/browser/gpu/gpu_data_manager_impl.h"
18 #include "content/browser/gpu/gpu_driver_bug_list.h"
19 #include "content/browser/gpu/gpu_switching_list.h"
20
21 namespace content {
22
23 class CONTENT_EXPORT GpuDataManagerImplPrivate {
24 public:
25 static GpuDataManagerImplPrivate* Create(GpuDataManagerImpl* owner);
26
27 void InitializeForTesting(
28 const std::string& gpu_blacklist_json,
29 const GPUInfo& gpu_info);
30 bool IsFeatureBlacklisted(int feature) const;
31 GPUInfo GetGPUInfo() const;
32 void GetGpuProcessHandles(
33 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const;
34 bool GpuAccessAllowed(std::string* reason) const;
35 void RequestCompleteGpuInfoIfNeeded();
36 bool IsCompleteGpuInfoAvailable() const;
37 void RequestVideoMemoryUsageStatsUpdate() const;
38 bool ShouldUseSwiftShader() const;
39 void RegisterSwiftShaderPath(const base::FilePath& path);
40 void AddObserver(GpuDataManagerObserver* observer);
41 void RemoveObserver(GpuDataManagerObserver* observer);
42 void UnblockDomainFrom3DAPIs(const GURL& url);
43 void DisableGpuWatchdog();
44 void SetGLStrings(const std::string& gl_vendor,
45 const std::string& gl_renderer,
46 const std::string& gl_version);
47 void GetGLStrings(std::string* gl_vendor,
48 std::string* gl_renderer,
49 std::string* gl_version);
50 void DisableHardwareAcceleration();
51
52 void Initialize();
53
54 void UpdateGpuInfo(const GPUInfo& gpu_info);
55
56 void UpdateVideoMemoryUsageStats(
57 const GPUVideoMemoryUsageStats& video_memory_usage_stats);
58
59 void AppendRendererCommandLine(CommandLine* command_line) const;
60
61 void AppendGpuCommandLine(CommandLine* command_line) const;
62
63 void AppendPluginCommandLine(CommandLine* command_line) const;
64
65 void UpdateRendererWebPrefs(WebPreferences* prefs) const;
66
67 GpuSwitchingOption GetGpuSwitchingOption() const;
68
69 std::string GetBlacklistVersion() const;
70
71 base::ListValue* GetBlacklistReasons() const;
72
73 void AddLogMessage(int level,
74 const std::string& header,
75 const std::string& message);
76
77 void ProcessCrashed(base::TerminationStatus exit_code);
78
79 base::ListValue* GetLogMessages() const;
80
81 void HandleGpuSwitch();
82
83 #if defined(OS_WIN)
84 // Is the GPU process using the accelerated surface to present, instead of
85 // presenting by itself.
86 bool IsUsingAcceleratedSurface() const;
87 #endif
88
89 void BlockDomainFrom3DAPIs(
90 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt);
91 bool Are3DAPIsBlocked(const GURL& url,
92 int render_process_id,
93 int render_view_id,
94 ThreeDAPIType requester);
95
96 void DisableDomainBlockingFor3DAPIsForTesting();
97
98 void Notify3DAPIBlocked(const GURL& url,
99 int render_process_id,
100 int render_view_id,
101 ThreeDAPIType requester);
102
103 size_t GetBlacklistedFeatureCount() const;
104
105 virtual ~GpuDataManagerImplPrivate();
106
107 private:
108 friend class GpuDataManagerImplPrivateTest;
109
110 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
111 GpuSideBlacklisting);
112 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
113 GpuSideExceptions);
114 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
115 DisableHardwareAcceleration);
116 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
117 SwiftShaderRendering);
118 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
119 SwiftShaderRendering2);
120 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
121 GpuInfoUpdate);
122 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
123 NoGpuInfoUpdateWithSwiftShader);
124 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
125 GPUVideoMemoryUsageStatsUpdate);
126 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
127 BlockAllDomainsFrom3DAPIs);
128 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
129 UnblockGuiltyDomainFrom3DAPIs);
130 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
131 UnblockDomainOfUnknownGuiltFrom3DAPIs);
132 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
133 UnblockOtherDomainFrom3DAPIs);
134 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
135 UnblockThisDomainFrom3DAPIs);
136 #if defined(OS_LINUX)
137 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
138 SetGLStrings);
139 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
140 SetGLStringsNoEffects);
141 #endif
142 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
143 GpuDriverBugListSingle);
144 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
145 GpuDriverBugListMultiple);
146 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
147 BlacklistAllFeatures);
148
149 struct DomainBlockEntry {
150 GpuDataManagerImpl::DomainGuilt last_guilt;
151 };
152
153 typedef std::map<std::string, DomainBlockEntry> DomainBlockMap;
154
155 typedef ObserverListThreadSafe<GpuDataManagerObserver>
156 GpuDataManagerObserverList;
157
158 explicit GpuDataManagerImplPrivate(GpuDataManagerImpl* owner);
159
160 void InitializeImpl(const std::string& gpu_blacklist_json,
161 const std::string& gpu_switching_list_json,
162 const std::string& gpu_driver_bug_list_json,
163 const GPUInfo& gpu_info);
164
165 void UpdateBlacklistedFeatures(const std::set<int>& features);
166
167 // This should only be called once at initialization time, when preliminary
168 // gpu info is collected.
169 void UpdatePreliminaryBlacklistedFeatures();
170
171 // Update the GPU switching status.
172 // This should only be called once at initialization time.
173 void UpdateGpuSwitchingManager(const GPUInfo& gpu_info);
174
175 // Notify all observers whenever there is a GPU info update.
176 void NotifyGpuInfoUpdate();
177
178 // Try to switch to SwiftShader rendering, if possible and necessary.
179 void EnableSwiftShaderIfNecessary();
180
181 // Helper to extract the domain from a given URL.
182 std::string GetDomainFromURL(const GURL& url) const;
183
184 // Implementation functions for blocking of 3D graphics APIs, used
185 // for unit testing.
186 void BlockDomainFrom3DAPIsAtTime(const GURL& url,
187 GpuDataManagerImpl::DomainGuilt guilt,
188 base::Time at_time);
189 GpuDataManagerImpl::DomainBlockStatus Are3DAPIsBlockedAtTime(
190 const GURL& url, base::Time at_time) const;
191 int64 GetBlockAllDomainsDurationInMs() const;
192
193 bool complete_gpu_info_already_requested_;
194
195 std::set<int> blacklisted_features_;
196 std::set<int> preliminary_blacklisted_features_;
197
198 GpuSwitchingOption gpu_switching_;
199
200 std::set<int> gpu_driver_bugs_;
201
202 GPUInfo gpu_info_;
203
204 scoped_ptr<GpuBlacklist> gpu_blacklist_;
205 scoped_ptr<GpuSwitchingList> gpu_switching_list_;
206 scoped_ptr<GpuDriverBugList> gpu_driver_bug_list_;
207
208 const scoped_refptr<GpuDataManagerObserverList> observer_list_;
209
210 ListValue log_messages_;
211
212 bool use_swiftshader_;
213
214 base::FilePath swiftshader_path_;
215
216 // Current card force-blacklisted due to GPU crashes, or disabled through
217 // the --disable-gpu commandline switch.
218 bool card_blacklisted_;
219
220 // We disable histogram stuff in testing, especially in unit tests because
221 // they cause random failures.
222 bool update_histograms_;
223
224 // Number of currently open windows, to be used in gpu memory allocation.
225 int window_count_;
226
227 DomainBlockMap blocked_domains_;
228 mutable std::list<base::Time> timestamps_of_gpu_resets_;
229 bool domain_blocking_enabled_;
230
231 GpuDataManagerImpl* owner_;
232
233 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImplPrivate);
234 };
235
236 } // namespace content
237
238 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
239
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl.cc ('k') | content/browser/gpu/gpu_data_manager_impl_private.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698