• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
6 #define CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
7 
8 #include <list>
9 #include <string>
10 
11 #include "base/callback_forward.h"
12 #include "base/process/process.h"
13 #include "content/common/content_export.h"
14 
15 class GURL;
16 
17 namespace base {
18 class FilePath;
19 class ListValue;
20 }
21 
22 namespace gpu {
23 struct GPUInfo;
24 }
25 
26 namespace content {
27 
28 class GpuDataManagerObserver;
29 
30 // This class is fully thread-safe.
31 class GpuDataManager {
32  public:
33   typedef base::Callback<void(const std::list<base::ProcessHandle>&)>
34       GetGpuProcessHandlesCallback;
35 
36   // Getter for the singleton.
37   CONTENT_EXPORT static GpuDataManager* GetInstance();
38 
39   virtual void InitializeForTesting(const std::string& gpu_blacklist_json,
40                                     const gpu::GPUInfo& gpu_info) = 0;
41 
42   virtual bool IsFeatureBlacklisted(int feature) const = 0;
43 
44   virtual gpu::GPUInfo GetGPUInfo() const = 0;
45 
46   // Retrieves a list of process handles for all gpu processes.
47   virtual void GetGpuProcessHandles(
48       const GetGpuProcessHandlesCallback& callback) const = 0;
49 
50   // This indicator might change because we could collect more GPU info or
51   // because the GPU blacklist could be updated.
52   // If this returns false, any further GPU access, including launching GPU
53   // process, establish GPU channel, and GPU info collection, should be
54   // blocked.
55   // Can be called on any thread.
56   // If |reason| is not NULL and GPU access is blocked, upon return, |reason|
57   // contains a description of the reason why GPU access is blocked.
58   virtual bool GpuAccessAllowed(std::string* reason) const = 0;
59 
60   // Requests complete GPUinfo if it has not already been requested
61   virtual void RequestCompleteGpuInfoIfNeeded() = 0;
62 
63   virtual bool IsCompleteGpuInfoAvailable() const = 0;
64 
65   // Requests that the GPU process report its current video memory usage stats,
66   // which can be retrieved via the GPU data manager's on-update function.
67   virtual void RequestVideoMemoryUsageStatsUpdate() const = 0;
68 
69   // Returns true if SwiftShader should be used.
70   virtual bool ShouldUseSwiftShader() const = 0;
71 
72   // Register a path to SwiftShader.
73   virtual void RegisterSwiftShaderPath(const base::FilePath& path) = 0;
74 
75   // Registers/unregister |observer|.
76   virtual void AddObserver(GpuDataManagerObserver* observer) = 0;
77   virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0;
78 
79   // Allows a given domain previously blocked from accessing 3D APIs
80   // to access them again.
81   virtual void UnblockDomainFrom3DAPIs(const GURL& url) = 0;
82 
83   // Disable the gpu process watchdog thread.
84   virtual void DisableGpuWatchdog() = 0;
85 
86   // Set GL strings. This triggers a re-calculation of GPU blacklist
87   // decision.
88   virtual void SetGLStrings(const std::string& gl_vendor,
89                             const std::string& gl_renderer,
90                             const std::string& gl_version) = 0;
91 
92   // Obtain collected GL strings.
93   virtual void GetGLStrings(std::string* gl_vendor,
94                             std::string* gl_renderer,
95                             std::string* gl_version) = 0;
96 
97   // Turn off all hardware acceleration.
98   virtual void DisableHardwareAcceleration() = 0;
99 
100   // Whether the browser compositor can be used.
101   virtual bool CanUseGpuBrowserCompositor() const = 0;
102 
103  protected:
~GpuDataManager()104   virtual ~GpuDataManager() {}
105 };
106 
107 };  // namespace content
108 
109 #endif  // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
110