Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / public / browser / gpu_data_manager.h
blob20657ea612c5f9a4a09c9379249ea3679f40765b
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.
5 #ifndef CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
6 #define CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
8 #include <list>
9 #include <string>
11 #include "base/callback_forward.h"
12 #include "base/process.h"
13 #include "content/common/content_export.h"
15 class GURL;
17 namespace base {
18 class FilePath;
19 class ListValue;
22 namespace gpu {
23 struct GPUInfo;
26 namespace content {
28 class GpuDataManagerObserver;
30 // This class is fully thread-safe.
31 class GpuDataManager {
32 public:
33 typedef base::Callback<void(const std::list<base::ProcessHandle>&)>
34 GetGpuProcessHandlesCallback;
36 // Getter for the singleton.
37 CONTENT_EXPORT static GpuDataManager* GetInstance();
39 virtual void InitializeForTesting(const std::string& gpu_blacklist_json,
40 const gpu::GPUInfo& gpu_info) = 0;
42 virtual bool IsFeatureBlacklisted(int feature) const = 0;
44 virtual gpu::GPUInfo GetGPUInfo() const = 0;
46 // Retrieves a list of process handles for all gpu processes.
47 virtual void GetGpuProcessHandles(
48 const GetGpuProcessHandlesCallback& callback) const = 0;
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;
60 // Requests complete GPUinfo if it has not already been requested
61 virtual void RequestCompleteGpuInfoIfNeeded() = 0;
63 virtual bool IsCompleteGpuInfoAvailable() const = 0;
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;
69 // Returns true if SwiftShader should be used.
70 virtual bool ShouldUseSwiftShader() const = 0;
72 // Register a path to SwiftShader.
73 virtual void RegisterSwiftShaderPath(const base::FilePath& path) = 0;
75 // Registers/unregister |observer|.
76 virtual void AddObserver(GpuDataManagerObserver* observer) = 0;
77 virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0;
79 // Allows a given domain previously blocked from accessing 3D APIs
80 // to access them again.
81 virtual void UnblockDomainFrom3DAPIs(const GURL& url) = 0;
83 // Disable the gpu process watchdog thread.
84 virtual void DisableGpuWatchdog() = 0;
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;
92 // Obtain collected GL strings.
93 virtual void GetGLStrings(std::string* gl_vendor,
94 std::string* gl_renderer,
95 std::string* gl_version) = 0;
97 // Turn off all hardware acceleration.
98 virtual void DisableHardwareAcceleration() = 0;
100 protected:
101 virtual ~GpuDataManager() {}
104 }; // namespace content
106 #endif // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_