OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "extensions/browser/preload_check_test_util.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" |
| 10 #include "base/run_loop.h" |
| 11 |
| 12 namespace extensions { |
| 13 |
| 14 PreloadCheckRunner::PreloadCheckRunner() : called_(false) {} |
| 15 PreloadCheckRunner::~PreloadCheckRunner() {} |
| 16 |
| 17 void PreloadCheckRunner::OnCheckComplete(PreloadCheck::Errors errors) { |
| 18 CHECK(!called_); |
| 19 called_ = true; |
| 20 errors_ = errors; |
| 21 } |
| 22 |
| 23 void PreloadCheckRunner::RunUntilComplete(PreloadCheck* check) { |
| 24 check->Start(GetCallback()); |
| 25 CHECK(!called_); |
| 26 Wait(); |
| 27 CHECK(called_); |
| 28 } |
| 29 |
| 30 PreloadCheck::ResultCallback PreloadCheckRunner::GetCallback() { |
| 31 return base::Bind(&PreloadCheckRunner::OnCheckComplete, |
| 32 base::Unretained(this)); |
| 33 } |
| 34 |
| 35 void PreloadCheckRunner::Wait() { |
| 36 base::RunLoop().RunUntilIdle(); |
| 37 } |
| 38 |
| 39 } // namespace extensions |
OLD | NEW |