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

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

Issue 2768723002: Update ExtensionInstallChecker to use PreloadCheck classes (Closed)
Patch Set: remove redundant DCHECKs that fail in tests 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 PreloadCheckStub();
61 ~PreloadCheckStub() override;
62
63 void AddError(Error error);
64 void set_error_message(const base::string16& message) { message_ = message; }
65
66 bool is_async() const { return is_async_; }
67 void set_is_async(bool is_async) { is_async_ = is_async; }
68
69 // PreloadCheck:
70 void Start(ResultCallback callback) override;
71 base::string16 GetErrorMessage() const override;
72
73 private:
74 void RunCallback(ResultCallback callback);
75
76 bool is_async_ = false;
77 Errors errors_;
78 base::string16 message_;
79
80 base::WeakPtrFactory<PreloadCheckStub> weak_ptr_factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(PreloadCheckStub);
83 };
84
54 } // namespace extensions 85 } // namespace extensions
55 86
56 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 87 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_checker_unittest.cc ('k') | extensions/browser/preload_check_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698