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

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

Issue 2768723002: Update ExtensionInstallChecker to use PreloadCheck classes (Closed)
Patch Set: newline 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 5 #ifndef EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
10 #include "extensions/browser/preload_check.h" 13 #include "extensions/browser/preload_check.h"
11 14
12 namespace base { 15 namespace base {
13 class RunLoop; 16 class RunLoop;
14 } 17 }
15 18
16 namespace extensions { 19 namespace extensions {
17 20
18 // Provides a callback method for a PreloadCheck that stores its results. 21 // Provides a callback method for a PreloadCheck that stores its results.
19 class PreloadCheckRunner { 22 class PreloadCheckRunner {
(...skipping 24 matching lines...) Expand all
44 47
45 PreloadCheck::Errors errors_; 48 PreloadCheck::Errors errors_;
46 bool called_; 49 bool called_;
47 50
48 // Using a RunLoop data member would trigger tricky timing troubles. 51 // Using a RunLoop data member would trigger tricky timing troubles.
49 std::unique_ptr<base::RunLoop> run_loop_; 52 std::unique_ptr<base::RunLoop> run_loop_;
50 53
51 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner); 54 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner);
52 }; 55 };
53 56
57 // Stub for a PreloadCheck that returns the desired error(s).
58 class PreloadCheckStub : public PreloadCheck {
59 public:
60 explicit PreloadCheckStub(bool is_async = false);
Devlin 2017/03/22 15:08:46 Maybe an enum, SYNCHRONOUS and ASYNCHRONOUS? Make
michaelpg 2017/03/24 02:34:17 I'll add set_is_async to mirror ExtensionInstallCh
61 ~PreloadCheckStub() override;
62
63 void AddError(Error error);
64 void set_error_message(const base::string16& message) { message_ = message; }
65
66 // PreloadCheck:
67 void Start(ResultCallback callback) override;
68 base::string16 GetErrorMessage() const override;
69
70 private:
71 void StartInternal(ResultCallback callback);
72
73 bool is_async_;
74 Errors errors_;
75 base::string16 message_;
76
77 base::WeakPtrFactory<PreloadCheckStub> weak_ptr_factory_;
78
79 DISALLOW_COPY_AND_ASSIGN(PreloadCheckStub);
80 };
81
54 } // namespace extensions 82 } // namespace extensions
55 83
56 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 84 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698