1a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// found in the LICENSE file.
4a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
5a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
6a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
7a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
8a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include <list>
9a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include <map>
10a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include <set>
11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include <string>
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <vector>
13a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
14a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/memory/ref_counted.h"
15a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/memory/singleton.h"
16a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/observer_list_threadsafe.h"
17a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "content/browser/gpu/gpu_data_manager_impl.h"
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_blacklist.h"
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "gpu/config/gpu_driver_bug_list.h"
20a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace base {
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class CommandLine;
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
25a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace content {
26a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
27a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)class CONTENT_EXPORT GpuDataManagerImplPrivate {
28a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) public:
29a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  static GpuDataManagerImplPrivate* Create(GpuDataManagerImpl* owner);
30a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
31a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void InitializeForTesting(
32a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      const std::string& gpu_blacklist_json,
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      const gpu::GPUInfo& gpu_info);
34a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool IsFeatureBlacklisted(int feature) const;
35424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool IsDriverBugWorkaroundActive(int feature) const;
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  gpu::GPUInfo GetGPUInfo() const;
37a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void GetGpuProcessHandles(
38a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      const GpuDataManager::GetGpuProcessHandlesCallback& callback) const;
39a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool GpuAccessAllowed(std::string* reason) const;
40a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void RequestCompleteGpuInfoIfNeeded();
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool IsEssentialGpuInfoAvailable() const;
42a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool IsCompleteGpuInfoAvailable() const;
43a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void RequestVideoMemoryUsageStatsUpdate() const;
44a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool ShouldUseSwiftShader() const;
45a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void RegisterSwiftShaderPath(const base::FilePath& path);
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool ShouldUseWarp() const;
47a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void AddObserver(GpuDataManagerObserver* observer);
48a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void RemoveObserver(GpuDataManagerObserver* observer);
49a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void UnblockDomainFrom3DAPIs(const GURL& url);
50a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void DisableGpuWatchdog();
51a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void SetGLStrings(const std::string& gl_vendor,
52a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                    const std::string& gl_renderer,
53a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                    const std::string& gl_version);
54a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void GetGLStrings(std::string* gl_vendor,
55a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                    std::string* gl_renderer,
56a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                    std::string* gl_version);
57a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void DisableHardwareAcceleration();
58a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
59a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void Initialize();
60a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void UpdateGpuInfo(const gpu::GPUInfo& gpu_info);
62a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
63a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void UpdateVideoMemoryUsageStats(
64a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      const GPUVideoMemoryUsageStats& video_memory_usage_stats);
65a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void AppendRendererCommandLine(base::CommandLine* command_line) const;
67a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void AppendGpuCommandLine(base::CommandLine* command_line) const;
69a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void AppendPluginCommandLine(base::CommandLine* command_line) const;
71a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
72a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void UpdateRendererWebPrefs(WebPreferences* prefs) const;
73a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
74a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  std::string GetBlacklistVersion() const;
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  std::string GetDriverBugListVersion() const;
76a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void GetBlacklistReasons(base::ListValue* reasons) const;
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void GetDriverBugWorkarounds(base::ListValue* workarounds) const;
80a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
81a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void AddLogMessage(int level,
82a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                     const std::string& header,
83a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                     const std::string& message);
84a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
85a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void ProcessCrashed(base::TerminationStatus exit_code);
86a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
87a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  base::ListValue* GetLogMessages() const;
88a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
89a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void HandleGpuSwitch();
90a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
917dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool CanUseGpuBrowserCompositor() const;
927dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
93a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void BlockDomainFrom3DAPIs(
94a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      const GURL& url, GpuDataManagerImpl::DomainGuilt guilt);
95a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool Are3DAPIsBlocked(const GURL& url,
96a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                        int render_process_id,
97a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                        int render_view_id,
98a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                        ThreeDAPIType requester);
99a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
100a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void DisableDomainBlockingFor3DAPIsForTesting();
101a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
102a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void Notify3DAPIBlocked(const GURL& url,
103a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                          int render_process_id,
104a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                          int render_view_id,
105a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                          ThreeDAPIType requester);
106a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
107a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  size_t GetBlacklistedFeatureCount() const;
108a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void SetDisplayCount(unsigned int display_count);
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  unsigned int GetDisplayCount() const;
111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool UpdateActiveGpu(uint32 vendor_id, uint32 device_id);
1130529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
114eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void OnGpuProcessInitFailure();
115eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
116a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  virtual ~GpuDataManagerImplPrivate();
117a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
118a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) private:
119a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  friend class GpuDataManagerImplPrivateTest;
120a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
121a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
122a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GpuSideBlacklisting);
123a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
124a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GpuSideExceptions);
125a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
126a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           DisableHardwareAcceleration);
127a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
128a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           SwiftShaderRendering);
129a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
130a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           SwiftShaderRendering2);
131a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                           WarpEnabledOverridesSwiftShader);
1331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
134a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GpuInfoUpdate);
135a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
136a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           NoGpuInfoUpdateWithSwiftShader);
137a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
138a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GPUVideoMemoryUsageStatsUpdate);
139a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
140a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           BlockAllDomainsFrom3DAPIs);
141a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
142a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           UnblockGuiltyDomainFrom3DAPIs);
143a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
144a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           UnblockDomainOfUnknownGuiltFrom3DAPIs);
145a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
146a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           UnblockOtherDomainFrom3DAPIs);
147a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
148a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           UnblockThisDomainFrom3DAPIs);
149a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#if defined(OS_LINUX)
150a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
151a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           SetGLStrings);
152a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
153a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           SetGLStringsNoEffects);
154a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif
155a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
156a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GpuDriverBugListSingle);
157a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
158a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           GpuDriverBugListMultiple);
159a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplPrivateTest,
160a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                           BlacklistAllFeatures);
161a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
162a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  struct DomainBlockEntry {
163a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)    GpuDataManagerImpl::DomainGuilt last_guilt;
164a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  };
165a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
166a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  typedef std::map<std::string, DomainBlockEntry> DomainBlockMap;
167a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
168a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  typedef ObserverListThreadSafe<GpuDataManagerObserver>
169a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      GpuDataManagerObserverList;
170a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  struct LogMessage {
1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    int level;
1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    std::string header;
1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    std::string message;
1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LogMessage(int _level,
1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)               const std::string& _header,
1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)               const std::string& _message)
1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        : level(_level),
1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          header(_header),
1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          message(_message) { }
1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
184a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  explicit GpuDataManagerImplPrivate(GpuDataManagerImpl* owner);
185a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
186a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void InitializeImpl(const std::string& gpu_blacklist_json,
187a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                      const std::string& gpu_driver_bug_list_json,
18890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                      const gpu::GPUInfo& gpu_info);
189a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
190e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  void UpdateGpuInfoHelper();
191e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
192a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void UpdateBlacklistedFeatures(const std::set<int>& features);
193a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
194a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // This should only be called once at initialization time, when preliminary
195a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // gpu info is collected.
196a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void UpdatePreliminaryBlacklistedFeatures();
197a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
198a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Update the GPU switching status.
199a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // This should only be called once at initialization time.
20090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void UpdateGpuSwitchingManager(const gpu::GPUInfo& gpu_info);
201a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
202a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Notify all observers whenever there is a GPU info update.
203a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void NotifyGpuInfoUpdate();
204a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
205a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Try to switch to SwiftShader rendering, if possible and necessary.
206a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void EnableSwiftShaderIfNecessary();
207a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
2081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Try to switch to WARP rendering if the GPU hardware is not supported or
2091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // absent, and if we are trying to run in Windows Metro mode.
2101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void EnableWarpIfNecessary();
2111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Use only for testing, forces |use_warp_| to true.
2131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void ForceWarpModeForTesting();
2141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
215a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Helper to extract the domain from a given URL.
216a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  std::string GetDomainFromURL(const GURL& url) const;
217a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
218a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Implementation functions for blocking of 3D graphics APIs, used
219a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // for unit testing.
220a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  void BlockDomainFrom3DAPIsAtTime(const GURL& url,
221a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                   GpuDataManagerImpl::DomainGuilt guilt,
222a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)                                   base::Time at_time);
223a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  GpuDataManagerImpl::DomainBlockStatus Are3DAPIsBlockedAtTime(
224a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)      const GURL& url, base::Time at_time) const;
225a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  int64 GetBlockAllDomainsDurationInMs() const;
226a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
227a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool complete_gpu_info_already_requested_;
228a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
229a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  std::set<int> blacklisted_features_;
230a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  std::set<int> preliminary_blacklisted_features_;
231a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
232a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  std::set<int> gpu_driver_bugs_;
233a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
23490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  gpu::GPUInfo gpu_info_;
235a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
23690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  scoped_ptr<gpu::GpuBlacklist> gpu_blacklist_;
23790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  scoped_ptr<gpu::GpuDriverBugList> gpu_driver_bug_list_;
238a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
239a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  const scoped_refptr<GpuDataManagerObserverList> observer_list_;
240a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::vector<LogMessage> log_messages_;
242a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
243a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool use_swiftshader_;
244a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
2451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool use_warp_;
2461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
247a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  base::FilePath swiftshader_path_;
248a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
249a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Current card force-blacklisted due to GPU crashes, or disabled through
250a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // the --disable-gpu commandline switch.
251a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool card_blacklisted_;
252a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
253a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // We disable histogram stuff in testing, especially in unit tests because
254a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // they cause random failures.
255a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool update_histograms_;
256a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
257a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  // Number of currently open windows, to be used in gpu memory allocation.
258a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  int window_count_;
259a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
260a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  DomainBlockMap blocked_domains_;
261a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  mutable std::list<base::Time> timestamps_of_gpu_resets_;
262a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  bool domain_blocking_enabled_;
263a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
264a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  GpuDataManagerImpl* owner_;
265a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
266868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  unsigned int display_count_;
267868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
268eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  bool gpu_process_accessible_;
269eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
2704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // True if all future Initialize calls should be ignored.
2714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  bool finalized_;
2724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
273a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImplPrivate);
274a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)};
275a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
276a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}  // namespace content
277a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
278a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif  // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_PRIVATE_H_
279a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
280