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

Side by Side Diff: chrome/browser/gpu/gpu_feature_checker.cc

Issue 2666243002: Move GPUFeatureChecker to content layer (Closed)
Patch Set: rebase Created 3 years, 10 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
« no previous file with comments | « chrome/browser/gpu/gpu_feature_checker.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "chrome/browser/gpu/gpu_feature_checker.h"
6
7 #include "base/logging.h"
8 #include "build/build_config.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/gpu_data_manager.h"
11
12 namespace {
13
14 // A false return value is always valid, but a true one is only valid if full
15 // GPU info has been collected in a GPU process.
16 bool IsFeatureAllowed(content::GpuDataManager* manager,
17 gpu::GpuFeatureType feature) {
18 return (manager->GpuAccessAllowed(NULL) &&
19 !manager->IsFeatureBlacklisted(feature));
20 }
21
22 } // namespace
23
24 GPUFeatureChecker::GPUFeatureChecker(gpu::GpuFeatureType feature,
25 FeatureAvailableCallback callback)
26 : feature_(feature),
27 callback_(callback) {
28 }
29
30 GPUFeatureChecker::~GPUFeatureChecker() {
31 }
32
33 void GPUFeatureChecker::CheckGPUFeatureAvailability() {
34 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
35
36 bool finalized = true;
37 #if defined(OS_LINUX)
38 // On Windows and Mac, so far we can always make the final WebGL blacklisting
39 // decision based on partial GPU info; on Linux, we need to launch the GPU
40 // process to collect full GPU info and make the final decision.
41 finalized = false;
42 #endif
43
44 content::GpuDataManager* manager = content::GpuDataManager::GetInstance();
45 if (manager->IsEssentialGpuInfoAvailable())
46 finalized = true;
47
48 bool feature_allowed = IsFeatureAllowed(manager, feature_);
49 if (!feature_allowed)
50 finalized = true;
51
52 if (finalized) {
53 callback_.Run(feature_allowed);
54 } else {
55 // Matched with a Release in OnGpuInfoUpdate.
56 AddRef();
57
58 manager->AddObserver(this);
59 manager->RequestCompleteGpuInfoIfNeeded();
60 }
61 }
62
63 void GPUFeatureChecker::OnGpuInfoUpdate() {
64 content::GpuDataManager* manager = content::GpuDataManager::GetInstance();
65 manager->RemoveObserver(this);
66 bool feature_allowed = IsFeatureAllowed(manager, feature_);
67 callback_.Run(feature_allowed);
68
69 // Matches the AddRef in HasFeature().
70 Release();
71 }
OLDNEW
« no previous file with comments | « chrome/browser/gpu/gpu_feature_checker.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698