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

Side by Side Diff: extensions/browser/preload_check_group.h

Issue 2745433002: PreloadCheckGroup for managing multiple extension PreloadChecks (Closed)
Patch Set: rebase & updates Created 3 years, 9 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 | « extensions/browser/BUILD.gn ('k') | extensions/browser/preload_check_group.cc » ('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 2017 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 EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "extensions/browser/preload_check.h"
15 #include "extensions/common/extension.h"
16
17 namespace extensions {
18
19 // Starts a collection of PreloadChecks and reports any errors once all
20 // checks have completed or, if configured to "fail fast", when the first error
21 // or set of errors occurs.
22 class PreloadCheckGroup : public PreloadCheck {
23 public:
24 PreloadCheckGroup(scoped_refptr<Extension> extension,
25 const std::vector<PreloadCheck*>& checks,
26 bool fail_fast);
27 ~PreloadCheckGroup() override;
28
29 void AddCheck(PreloadCheck* check);
30
31 // PreloadCheck:
32 void Start(ResultCallback callback) override;
33 // base::string16 GetErrorMessage() const override;
34
35 private:
36 // Saves any errors and may invoke the callback.
37 void OnCheckComplete(PreloadCheck* check, Errors errors);
38
39 // Invokes the callback if the checks are considered finished.
40 void MaybeInvokeCallback();
41
42 // If true, the callback is invoked when the first check fails.
43 bool fail_fast_;
44
45 // Number of currently running checks.
46 int running_checks_;
47
48 // Errors found so far.
49 Errors errors_;
50 /*
51 // Only the first non-empty error string is recorded.
52 mutable base::string16 error_;
53 */
54
55 // Checks to run.
56 std::vector<PreloadCheck*> checks_;
57
58 // The callback to invoke when checks are complete.
59 ResultCallback callback_;
60
61 base::WeakPtrFactory<PreloadCheckGroup> weak_ptr_factory_;
62
63 DISALLOW_COPY_AND_ASSIGN(PreloadCheckGroup);
64 };
65
66 } // namespace extensions
67
68 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
OLDNEW
« no previous file with comments | « extensions/browser/BUILD.gn ('k') | extensions/browser/preload_check_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698