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

Side by Side Diff: chrome/browser/extensions/chrome_requirements_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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/chrome_requirements_checker.h" 5 #include "chrome/browser/extensions/chrome_requirements_checker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/gpu/gpu_feature_checker.h"
10 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
11 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/gpu_feature_checker.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/manifest.h" 13 #include "extensions/common/manifest.h"
14 #include "extensions/common/manifest_handlers/requirements_info.h" 14 #include "extensions/common/manifest_handlers/requirements_info.h"
15 #include "gpu/config/gpu_feature_type.h" 15 #include "gpu/config/gpu_feature_type.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 ChromeRequirementsChecker::ChromeRequirementsChecker() 20 ChromeRequirementsChecker::ChromeRequirementsChecker()
21 : pending_requirement_checks_(0), weak_ptr_factory_(this) { 21 : pending_requirement_checks_(0), weak_ptr_factory_(this) {
(...skipping 20 matching lines...) Expand all
42 42
43 if (requirements.window_shape) { 43 if (requirements.window_shape) {
44 #if !defined(USE_AURA) 44 #if !defined(USE_AURA)
45 errors_.push_back( 45 errors_.push_back(
46 l10n_util::GetStringUTF8(IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED)); 46 l10n_util::GetStringUTF8(IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED));
47 #endif 47 #endif
48 } 48 }
49 49
50 if (requirements.webgl) { 50 if (requirements.webgl) {
51 ++pending_requirement_checks_; 51 ++pending_requirement_checks_;
52 webgl_checker_ = new GPUFeatureChecker( 52 webgl_checker_ = content::GpuFeatureChecker::Create(
53 gpu::GPU_FEATURE_TYPE_WEBGL, 53 gpu::GPU_FEATURE_TYPE_WEBGL,
54 base::Bind(&ChromeRequirementsChecker::SetWebGLAvailability, 54 base::Bind(&ChromeRequirementsChecker::SetWebGLAvailability,
55 weak_ptr_factory_.GetWeakPtr())); 55 weak_ptr_factory_.GetWeakPtr()));
56 } 56 }
57 57
58 if (pending_requirement_checks_ == 0) { 58 if (pending_requirement_checks_ == 0) {
59 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 59 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
60 base::Bind(callback_, errors_)); 60 base::Bind(callback_, errors_));
61 // Reset the callback so any ref-counted bound parameters will get released. 61 // Reset the callback so any ref-counted bound parameters will get released.
62 callback_.Reset(); 62 callback_.Reset();
63 return; 63 return;
64 } 64 }
65 // Running the GPU checkers down here removes any race condition that arises 65 // Running the GPU checkers down here removes any race condition that arises
66 // from the use of pending_requirement_checks_. 66 // from the use of pending_requirement_checks_.
67 if (webgl_checker_.get()) 67 if (webgl_checker_.get())
68 webgl_checker_->CheckGPUFeatureAvailability(); 68 webgl_checker_->CheckGpuFeatureAvailability();
69 } 69 }
70 70
71 void ChromeRequirementsChecker::SetWebGLAvailability(bool available) { 71 void ChromeRequirementsChecker::SetWebGLAvailability(bool available) {
72 if (!available) { 72 if (!available) {
73 errors_.push_back( 73 errors_.push_back(
74 l10n_util::GetStringUTF8(IDS_EXTENSION_WEBGL_NOT_SUPPORTED)); 74 l10n_util::GetStringUTF8(IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
75 } 75 }
76 MaybeRunCallback(); 76 MaybeRunCallback();
77 } 77 }
78 78
79 void ChromeRequirementsChecker::MaybeRunCallback() { 79 void ChromeRequirementsChecker::MaybeRunCallback() {
80 if (--pending_requirement_checks_ == 0) { 80 if (--pending_requirement_checks_ == 0) {
81 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 81 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
82 base::Bind(callback_, errors_)); 82 base::Bind(callback_, errors_));
83 // Reset the callback so any ref-counted bound parameters will get released. 83 // Reset the callback so any ref-counted bound parameters will get released.
84 callback_.Reset(); 84 callback_.Reset();
85 errors_.clear(); 85 errors_.clear();
86 } 86 }
87 } 87 }
88 88
89 } // namespace extensions 89 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/chrome_requirements_checker.h ('k') | chrome/browser/gpu/gpu_feature_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698