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

Unified Diff: base/android/java_handler_thread_for_testing.cc

Issue 2169553002: Properly throw java exceptions from shouldOverrideUrlLoading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test-only subclasses for JavaHandlerThread and SystemMessageHandler. Created 4 years, 4 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: base/android/java_handler_thread_for_testing.cc
diff --git a/base/android/java_handler_thread_for_testing.cc b/base/android/java_handler_thread_for_testing.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c427d9bbe781f28a5c50331e5026f284691b99f6
--- /dev/null
+++ b/base/android/java_handler_thread_for_testing.cc
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/android/java_handler_thread_for_testing.h"
+
+#include "base/message_loop/message_loop.h"
+
+namespace base {
+
+namespace android {
+
+JavaHandlerThreadForTesting::JavaHandlerThreadForTesting(
+ const char* name,
+ base::WaitableEvent* test_done_event)
+ : JavaHandlerThread(name), test_done_event_(test_done_event) {}
+
+JavaHandlerThreadForTesting::~JavaHandlerThreadForTesting() {}
+
+void JavaHandlerThreadForTesting::StartMessageLoop() {
+ static_cast<MessageLoopForUI*>(message_loop_.get())
+ ->StartForTesting(
+ reinterpret_cast<base::WaitableEvent*>(test_done_event_));
+}
+
+void JavaHandlerThreadForTesting::StopMessageLoop() {
+ // Instead of calling MessageLoop::QuitWhenIdle here we call
+ // MessageLoop::QuitNow. This is because QuitWhenIdle will have no effect on
+ // the message loop after MessageLoop::Abort has been called (which should
+ // have happened at this point).
+ static_cast<MessageLoopForUI*>(message_loop_.get())->QuitNow();
+ // The message loop must be destroyed on the thread it is attached to.
+ message_loop_.reset();
+}
+
+} // namespace base
+} // namespace android

Powered by Google App Engine
This is Rietveld 408576698