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

Unified Diff: extensions/browser/preload_check_test_util.cc

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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/preload_check_test_util.cc
diff --git a/extensions/browser/preload_check_test_util.cc b/extensions/browser/preload_check_test_util.cc
index b12bc17950de05927ec82b86c69a8736e5b65232..a956be93a813ee26e6c7cc92fa38cf890a6166e3 100644
--- a/extensions/browser/preload_check_test_util.cc
+++ b/extensions/browser/preload_check_test_util.cc
@@ -9,10 +9,14 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "extensions/common/extension.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
+// PreloadCheckRunner:
PreloadCheckRunner::PreloadCheckRunner() : called_(false) {}
PreloadCheckRunner::~PreloadCheckRunner() {}
@@ -47,4 +51,34 @@ void PreloadCheckRunner::WaitForIdle() {
run_loop_->RunUntilIdle();
}
+// PreloadCheckStub:
+PreloadCheckStub::PreloadCheckStub(bool is_async)
+ : PreloadCheck(nullptr), is_async_(is_async), weak_ptr_factory_(this) {}
+
+PreloadCheckStub::~PreloadCheckStub() {}
+
+void PreloadCheckStub::AddError(Error error) {
+ errors_.insert(error);
+}
+
+void PreloadCheckStub::Start(ResultCallback callback) {
+ DCHECK(!callback.is_null());
+ if (is_async_) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&PreloadCheckStub::StartInternal,
Devlin 2017/03/22 15:08:46 Another option would be to do PostTask(FROM_HERE,
michaelpg 2017/03/24 02:34:17 Since I'm using a OnceCallback (new best practice)
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(&callback)));
+ } else {
+ StartInternal(std::move(callback));
+ }
+}
+
+void PreloadCheckStub::StartInternal(ResultCallback callback) {
Devlin 2017/03/22 15:08:46 StartInternal is a funny name for something that d
michaelpg 2017/03/24 02:34:16 RunCallback sound good?
+ std::move(callback).Run(errors_);
+}
+
+base::string16 PreloadCheckStub::GetErrorMessage() const {
+ return message_;
+}
+
} // namespace extensions
« extensions/browser/preload_check_test_util.h ('K') | « 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