Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ | |
| 7 | |
| 8 #include <vecotr> | |
|
Aaron Boodman
2012/07/30 12:15:11
opps
eaugusti
2012/07/30 20:03:17
Done.
| |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/synchronization/lock.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "chrome/browser/extensions/extension_service.h" | |
| 14 | |
| 15 class GPUFeatureChecker; | |
| 16 | |
| 17 namespace extensions { | |
| 18 class Extension; | |
| 19 | |
| 20 // The caller is responsible for maintaining a reference to the | |
| 21 // RequirementsChecker while it is running. | |
| 22 class RequirementsChecker { | |
| 23 public: | |
| 24 RequirementsChecker(); | |
| 25 ~RequirementsChecker(); | |
| 26 | |
| 27 // The vector passed to the callback are any localized errors describing | |
| 28 // requirement violations. If this vector is non-empty, requirements checking | |
| 29 // failed. This should only be called once from the UI thread. |callback| will | |
| 30 // be invoked on |callback_thread|. | |
| 31 void Check(scoped_refptr<const Extension> extension, | |
| 32 base::Callback<void(std::vector<std::string>)> callback, | |
| 33 content::BrowserThread::ID callback_thread); | |
|
Aaron Boodman
2012/07/30 12:15:11
Is it possible to just assume that the callback th
eaugusti
2012/07/30 20:03:17
Because of GPUFeatureChecker (GPUDataManager), we
Aaron Boodman
2012/08/01 03:58:54
I think that we can require this class to also onl
| |
| 34 | |
| 35 private: | |
| 36 friend class GPUFeatureChecker; | |
| 37 | |
| 38 // Callbacks for the GPUFeatureChecker. | |
| 39 void IsWebGLAvailable(bool available); | |
| 40 void IsCSS3dAvailable(bool available); | |
|
Aaron Boodman
2012/07/30 12:15:11
CSS3D would be more consistent with the other uses
eaugusti
2012/07/30 20:03:17
Done.
| |
| 41 | |
| 42 void MaybeRunCallback(); | |
| 43 void CallbackOnCorrectThread(); | |
| 44 | |
| 45 // These avoid the need for every instance to check with the GPU thread. | |
| 46 static bool checked_for_webgl_; | |
|
Aaron Boodman
2012/07/30 12:15:11
Is this cache necessary? I thought when I looked a
eaugusti
2012/07/30 20:03:17
You're right.
| |
| 47 static bool webgl_supported_; | |
| 48 static bool checked_for_css3d_; | |
| 49 static bool css3d_supported_; | |
| 50 | |
| 51 std::vector<std::string> errors_; | |
| 52 | |
| 53 // Every requirments that needs to be resolved asynchroniously will add to | |
| 54 // this counter. When the counter is depleted, the callback will be run. | |
| 55 int async_requirement_checks_; | |
| 56 base::Lock async_requirement_checks_lock_; | |
|
Aaron Boodman
2012/07/30 12:15:11
You should not need this lock. The asynchronous ch
eaugusti
2012/07/30 20:03:17
Done.
| |
| 57 | |
| 58 scoped_refptr<GPUFeatureChecker> webgl_checker_; | |
|
Aaron Boodman
2012/07/30 12:15:11
These should not need to be refcounted either. The
eaugusti
2012/07/30 20:03:17
GPUFeatureChecker is already RefCountedThreadSafe
| |
| 59 scoped_refptr<GPUFeatureChecker> css3d_checker_; | |
| 60 | |
| 61 base::Callback<void(std::vector<std::string>)> callback_; | |
| 62 content::BrowserThread::ID callback_thread_; | |
| 63 }; | |
| 64 | |
| 65 } // namespace extensions | |
| 66 | |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ | |
| OLD | NEW |