| 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_
|
|
|