gpu_data_manager.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 <string>
9
10#include "content/common/content_export.h"
11#include "content/public/common/gpu_feature_type.h"
12#include "content/public/common/gpu_switching_option.h"
13
14class FilePath;
15
16namespace base {
17class ListValue;
18}
19
20namespace content {
21
22class GpuDataManagerObserver;
23struct GPUInfo;
24
25// This class is fully thread-safe.
26class GpuDataManager {
27 public:
28  // Getter for the singleton.
29  CONTENT_EXPORT static GpuDataManager* GetInstance();
30
31  virtual void InitializeForTesting(const std::string& gpu_blacklist_json,
32                                    const content::GPUInfo& gpu_info) = 0;
33
34  virtual std::string GetBlacklistVersion() const = 0;
35
36  virtual GpuFeatureType GetBlacklistedFeatures() const = 0;
37
38  virtual GpuSwitchingOption GetGpuSwitchingOption() const = 0;
39
40  // Returns the reasons for the latest run of blacklisting decisions.
41  // For the structure of returned value, see documentation for
42  // GpuBlacklist::GetBlacklistedReasons().
43  // Caller is responsible to release the returned value.
44  virtual base::ListValue* GetBlacklistReasons() const = 0;
45
46  virtual GPUInfo GetGPUInfo() const = 0;
47
48  // This indicator might change because we could collect more GPU info or
49  // because the GPU blacklist could be updated.
50  // If this returns false, any further GPU access, including launching GPU
51  // process, establish GPU channel, and GPU info collection, should be
52  // blocked.
53  // Can be called on any thread.
54  virtual bool GpuAccessAllowed() const = 0;
55
56  // Requests complete GPUinfo if it has not already been requested
57  virtual void RequestCompleteGpuInfoIfNeeded() = 0;
58
59  virtual bool IsCompleteGpuInfoAvailable() const = 0;
60
61  // Requests that the GPU process report its current video memory usage stats,
62  // which can be retrieved via the GPU data manager's on-update function.
63  virtual void RequestVideoMemoryUsageStatsUpdate() const = 0;
64
65  // Returns true if the software rendering should currently be used.
66  virtual bool ShouldUseSoftwareRendering() const = 0;
67
68  // Register a path to the SwiftShader software renderer.
69  virtual void RegisterSwiftShaderPath(const FilePath& path) = 0;
70
71  virtual void AddLogMessage(
72      int level, const std::string& header, const std::string& message) = 0;
73
74  // Returns a new copy of the ListValue.  Caller is responsible to release
75  // the returned value.
76  virtual base::ListValue* GetLogMessages() const = 0;
77
78  // Registers/unregister |observer|.
79  virtual void AddObserver(GpuDataManagerObserver* observer) = 0;
80  virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0;
81
82  // Notifies the gpu process about the number of browser windows, so
83  // they can be used to determine managed memory allocation.
84  virtual void SetWindowCount(uint32 count) = 0;
85  virtual uint32 GetWindowCount() const = 0;
86
87 protected:
88  virtual ~GpuDataManager() {}
89};
90
91};  // namespace content
92
93#endif  // CONTENT_PUBLIC_BROWSER_GPU_DATA_MANAGER_H_
94