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

Side by Side Diff: base/test/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: Fix trybot compilation failure. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "base/test/android/java_handler_thread_for_testing.h"
6
7 #include "base/message_loop/message_loop.h"
8
9 namespace base {
10 namespace android {
11
12 base::android::ScopedJavaLocalRef<jobject>
13 TestJavaMessageHandlerFactory::CreateMessageHandler(
14 JNIEnv* env,
15 base::MessagePump::Delegate* delegate,
16 MessagePumpForUI* message_pump,
17 WaitableEvent* test_done_event) {
18 return TestSystemMessageHandlerLink::CreateTestSystemMessageHandler(
19 env, delegate, message_pump, test_done_event);
20 }
21
22 JavaHandlerThreadForTesting::JavaHandlerThreadForTesting(
23 const char* name,
24 base::WaitableEvent* test_done_event)
25 : JavaHandlerThread(name),
26 message_handler_factory_(new TestJavaMessageHandlerFactory()),
27 test_done_event_(test_done_event) {}
28
29 JavaHandlerThreadForTesting::~JavaHandlerThreadForTesting() = default;
30
31 void JavaHandlerThreadForTesting::StartMessageLoop() {
32 static_cast<MessageLoopForUI*>(message_loop_.get())
33 ->StartForTesting(
34 message_handler_factory_.get(),
35 reinterpret_cast<base::WaitableEvent*>(test_done_event_));
36 }
37
38 void JavaHandlerThreadForTesting::StopMessageLoop() {
39 // Instead of calling MessageLoop::QuitWhenIdle here we call
40 // MessageLoop::QuitNow. This is because QuitWhenIdle will have no effect on
41 // the message loop after MessageLoop::Abort has been called (which should
42 // have happened at this point).
43 static_cast<MessageLoopForUI*>(message_loop_.get())->QuitNow();
44 // The message loop must be destroyed on the thread it is attached to.
45 message_loop_.reset();
46 }
47
48 } // namespace base
49 } // namespace android
OLDNEW
« no previous file with comments | « base/test/android/java_handler_thread_for_testing.h ('k') | base/test/android/test_system_message_handler_link_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698