Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux...
[chromium-blink-merge.git] / chrome / browser / extensions / requirements_checker.h
blob1626789b7780e0c5b0a62f7c1c1a4d12cfbfc287
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/extension_service.h"
15 class GPUFeatureChecker;
17 namespace extensions {
18 class Extension;
20 // Validates the 'requirements' extension manifest field. This is an
21 // asynchronous process that involves several threads, but the public interface
22 // of this class (including constructor and destructor) must only be used on
23 // the UI thread.
24 class RequirementsChecker : public base::SupportsWeakPtr<RequirementsChecker> {
25 public:
26 RequirementsChecker();
27 ~RequirementsChecker();
29 // The vector passed to the callback are any localized errors describing
30 // requirement violations. If this vector is non-empty, requirements checking
31 // failed. This should only be called once. |callback| will always be invoked
32 // asynchronously on the UI thread. |callback| will only be called once, and
33 // will be reset after called.
34 void Check(scoped_refptr<const Extension> extension,
35 base::Callback<void(std::vector<std::string> requirement)> callback);
37 private:
38 // Callbacks for the GPUFeatureChecker.
39 void SetWebGLAvailability(bool available);
41 void MaybeRunCallback();
43 std::vector<std::string> errors_;
45 // Every requirement that needs to be resolved asynchronously will add to
46 // this counter. When the counter is depleted, the callback will be run.
47 int pending_requirement_checks_;
49 scoped_refptr<GPUFeatureChecker> webgl_checker_;
51 base::Callback<void(std::vector<std::string> requirement_errorss)> callback_;
54 } // namespace extensions
56 #endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_