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

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

Issue 2693373003: PreloadCheck class for extension pre-install checks (Closed)
Patch Set: don't break enable_extensions=false 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
« no previous file with comments | « extensions/browser/preload_check_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/memory/ptr_util.h"
11 #include "base/run_loop.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace extensions {
15
16 PreloadCheckRunner::PreloadCheckRunner() : called_(false) {}
17 PreloadCheckRunner::~PreloadCheckRunner() {}
18
19 void PreloadCheckRunner::OnCheckComplete(PreloadCheck::Errors errors) {
20 ASSERT_FALSE(called_);
21 called_ = true;
22 errors_ = errors;
23 if (run_loop_)
24 run_loop_->Quit();
25 }
26
27 void PreloadCheckRunner::Run(PreloadCheck* check) {
28 check->Start(GetCallback());
29 }
30
31 void PreloadCheckRunner::RunUntilComplete(PreloadCheck* check) {
32 Run(check);
33 ASSERT_FALSE(called_);
34
35 run_loop_ = base::MakeUnique<base::RunLoop>();
36 run_loop_->Run();
37 ASSERT_TRUE(called_);
38 }
39
40 PreloadCheck::ResultCallback PreloadCheckRunner::GetCallback() {
41 return base::Bind(&PreloadCheckRunner::OnCheckComplete,
42 base::Unretained(this));
43 }
44
45 void PreloadCheckRunner::WaitForIdle() {
46 run_loop_ = base::MakeUnique<base::RunLoop>();
47 run_loop_->RunUntilIdle();
48 }
49
50 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/preload_check_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698