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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/BUILD.gn ('k') | extensions/browser/preload_check_group.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/preload_check_group.h
diff --git a/extensions/browser/preload_check_group.h b/extensions/browser/preload_check_group.h
new file mode 100644
index 0000000000000000000000000000000000000000..45348a85037d93a340fde7713c29ac4390cd265c
--- /dev/null
+++ b/extensions/browser/preload_check_group.h
@@ -0,0 +1,68 @@
+// Copyright 2017 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 EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
+#define EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/string16.h"
+#include "extensions/browser/preload_check.h"
+#include "extensions/common/extension.h"
+
+namespace extensions {
+
+// Starts a collection of PreloadChecks and reports any errors once all
+// checks have completed or, if configured to "fail fast", when the first error
+// or set of errors occurs.
+class PreloadCheckGroup : public PreloadCheck {
+ public:
+ PreloadCheckGroup(scoped_refptr<Extension> extension,
+ const std::vector<PreloadCheck*>& checks,
+ bool fail_fast);
+ ~PreloadCheckGroup() override;
+
+ void AddCheck(PreloadCheck* check);
+
+ // PreloadCheck:
+ void Start(ResultCallback callback) override;
+ // base::string16 GetErrorMessage() const override;
+
+ private:
+ // Saves any errors and may invoke the callback.
+ void OnCheckComplete(PreloadCheck* check, Errors errors);
+
+ // Invokes the callback if the checks are considered finished.
+ void MaybeInvokeCallback();
+
+ // If true, the callback is invoked when the first check fails.
+ bool fail_fast_;
+
+ // Number of currently running checks.
+ int running_checks_;
+
+ // Errors found so far.
+ Errors errors_;
+ /*
+ // Only the first non-empty error string is recorded.
+ mutable base::string16 error_;
+ */
+
+ // Checks to run.
+ std::vector<PreloadCheck*> checks_;
+
+ // The callback to invoke when checks are complete.
+ ResultCallback callback_;
+
+ base::WeakPtrFactory<PreloadCheckGroup> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreloadCheckGroup);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_GROUP_H_
« 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