Chromium Code Reviews| Index: chrome/browser/extensions/requirements_checker.h |
| diff --git a/chrome/browser/extensions/requirements_checker.h b/chrome/browser/extensions/requirements_checker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5eb6e4864d0004c4c68330f99e32f6bc344d3826 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/requirements_checker.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |
| + |
| +#include <vecotr> |
|
Aaron Boodman
2012/07/30 12:15:11
opps
eaugusti
2012/07/30 20:03:17
Done.
|
| + |
| +#include "base/callback.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| + |
| +class GPUFeatureChecker; |
| + |
| +namespace extensions { |
| +class Extension; |
| + |
| +// The caller is responsible for maintaining a reference to the |
| +// RequirementsChecker while it is running. |
| +class RequirementsChecker { |
| + public: |
| + RequirementsChecker(); |
| + ~RequirementsChecker(); |
| + |
| + // The vector passed to the callback are any localized errors describing |
| + // requirement violations. If this vector is non-empty, requirements checking |
| + // failed. This should only be called once from the UI thread. |callback| will |
| + // be invoked on |callback_thread|. |
| + void Check(scoped_refptr<const Extension> extension, |
| + base::Callback<void(std::vector<std::string>)> callback, |
| + 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
|
| + |
| + private: |
| + friend class GPUFeatureChecker; |
| + |
| + // Callbacks for the GPUFeatureChecker. |
| + void IsWebGLAvailable(bool available); |
| + 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.
|
| + |
| + void MaybeRunCallback(); |
| + void CallbackOnCorrectThread(); |
| + |
| + // These avoid the need for every instance to check with the GPU thread. |
| + 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.
|
| + static bool webgl_supported_; |
| + static bool checked_for_css3d_; |
| + static bool css3d_supported_; |
| + |
| + std::vector<std::string> errors_; |
| + |
| + // Every requirments that needs to be resolved asynchroniously will add to |
| + // this counter. When the counter is depleted, the callback will be run. |
| + int async_requirement_checks_; |
| + 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.
|
| + |
| + 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
|
| + scoped_refptr<GPUFeatureChecker> css3d_checker_; |
| + |
| + base::Callback<void(std::vector<std::string>)> callback_; |
| + content::BrowserThread::ID callback_thread_; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |