OLD | NEW |
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/strings/string16.h" |
10 #include "extensions/browser/preload_check.h" | 12 #include "extensions/browser/preload_check.h" |
11 | 13 |
12 namespace base { | 14 namespace base { |
13 class RunLoop; | 15 class RunLoop; |
14 } | 16 } |
15 | 17 |
16 namespace extensions { | 18 namespace extensions { |
17 | 19 |
18 // Provides a callback method for a PreloadCheck that stores its results. | 20 // Provides a callback method for a PreloadCheck that stores its results. |
19 class PreloadCheckRunner { | 21 class PreloadCheckRunner { |
(...skipping 24 matching lines...) Expand all Loading... |
44 | 46 |
45 PreloadCheck::Errors errors_; | 47 PreloadCheck::Errors errors_; |
46 bool called_; | 48 bool called_; |
47 | 49 |
48 // Using a RunLoop data member would trigger tricky timing troubles. | 50 // Using a RunLoop data member would trigger tricky timing troubles. |
49 std::unique_ptr<base::RunLoop> run_loop_; | 51 std::unique_ptr<base::RunLoop> run_loop_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner); | 53 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner); |
52 }; | 54 }; |
53 | 55 |
| 56 // Stub for a PreloadCheck that returns the desired error(s). |
| 57 class PreloadCheckStub : public PreloadCheck { |
| 58 public: |
| 59 explicit PreloadCheckStub(bool is_async = false); |
| 60 ~PreloadCheckStub() override; |
| 61 |
| 62 void AddError(Error error); |
| 63 void set_error_message(const base::string16& message) { message_ = message; } |
| 64 |
| 65 // PreloadCheck: |
| 66 void Start(ResultCallback callback) override; |
| 67 base::string16 GetErrorMessage() const override; |
| 68 |
| 69 private: |
| 70 void StartInternal(ResultCallback callback); |
| 71 |
| 72 bool is_async_; |
| 73 Errors errors_; |
| 74 base::string16 message_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(PreloadCheckStub); |
| 77 }; |
| 78 |
54 } // namespace extensions | 79 } // namespace extensions |
55 | 80 |
56 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ | 81 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ |
OLD | NEW |