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

Side by Side Diff: content/public/test/nested_message_pump_android.cc

Issue 733533002: Do not start RunLoop of MessagePumpForUI in NestedMessagePumpAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failure of FrameTreeBrowserTest.FrameTreeAfterCrash Created 6 years, 1 month 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/test/nested_message_pump_android.h" 5 #include "content/public/test/nested_message_pump_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 29 matching lines...) Expand all
40 bool should_quit; 40 bool should_quit;
41 41
42 // Used to sleep until there is more work to do. 42 // Used to sleep until there is more work to do.
43 base::WaitableEvent waitable_event; 43 base::WaitableEvent waitable_event;
44 44
45 // The time at which we should call DoDelayedWork. 45 // The time at which we should call DoDelayedWork.
46 base::TimeTicks delayed_work_time; 46 base::TimeTicks delayed_work_time;
47 }; 47 };
48 48
49 NestedMessagePumpAndroid::NestedMessagePumpAndroid() 49 NestedMessagePumpAndroid::NestedMessagePumpAndroid()
50 : state_(NULL) { 50 : state_(NULL), redundant_quit_executed_(false) {
51 } 51 }
52 52
53 NestedMessagePumpAndroid::~NestedMessagePumpAndroid() { 53 NestedMessagePumpAndroid::~NestedMessagePumpAndroid() {
54 } 54 }
55 55
56 void NestedMessagePumpAndroid::Run(Delegate* delegate) { 56 void NestedMessagePumpAndroid::Run(Delegate* delegate) {
57 RunState state(delegate, state_ ? state_->run_depth + 1 : 1); 57 RunState state(delegate, state_ ? state_->run_depth + 1 : 1);
58 RunState* previous_state = state_; 58 RunState* previous_state = state_;
59 state_ = &state; 59 state_ = &state;
60 60
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 state_ = previous_state; 117 state_ = previous_state;
118 } 118 }
119 119
120 void NestedMessagePumpAndroid::Start( 120 void NestedMessagePumpAndroid::Start(
121 base::MessagePump::Delegate* delegate) { 121 base::MessagePump::Delegate* delegate) {
122 JNIEnv* env = base::android::AttachCurrentThread(); 122 JNIEnv* env = base::android::AttachCurrentThread();
123 DCHECK(env); 123 DCHECK(env);
124 g_message_handler_obj.Get().Reset( 124 g_message_handler_obj.Get().Reset(
125 Java_NestedSystemMessageHandler_create(env)); 125 Java_NestedSystemMessageHandler_create(env));
126
127 base::MessagePumpForUI::Start(delegate);
128 } 126 }
129 127
130 void NestedMessagePumpAndroid::Quit() { 128 void NestedMessagePumpAndroid::Quit() {
131 if (state_) { 129 if (state_) {
bulach 2014/11/17 22:08:42 it looks like redundant_quit_executed_ could be an
Jaekyun Seok (inactive) 2014/11/18 03:10:06 I will ignore the quit request in browser_main_run
132 state_->should_quit = true; 130 state_->should_quit = true;
133 state_->waitable_event.Signal(); 131 state_->waitable_event.Signal();
134 return; 132 return;
133 } else {
134 redundant_quit_executed_ = true;
135 } 135 }
136 base::MessagePumpForUI::Quit(); 136 }
137
138 bool NestedMessagePumpAndroid::IsRedundantQuitExpected() {
139 // Redundant quit is allowed only once.
140 return !redundant_quit_executed_;
137 } 141 }
138 142
139 void NestedMessagePumpAndroid::ScheduleWork() { 143 void NestedMessagePumpAndroid::ScheduleWork() {
140 if (state_) { 144 if (state_) {
141 state_->waitable_event.Signal(); 145 state_->waitable_event.Signal();
142 return; 146 return;
143 } 147 }
144
145 base::MessagePumpForUI::ScheduleWork();
146 } 148 }
147 149
148 void NestedMessagePumpAndroid::ScheduleDelayedWork( 150 void NestedMessagePumpAndroid::ScheduleDelayedWork(
149 const base::TimeTicks& delayed_work_time) { 151 const base::TimeTicks& delayed_work_time) {
150 if (state_) { 152 if (state_) {
151 // We know that we can't be blocked on Wait right now since this method can 153 // We know that we can't be blocked on Wait right now since this method can
152 // only be called on the same thread as Run, so we only need to update our 154 // only be called on the same thread as Run, so we only need to update our
153 // record of how long to sleep when we do sleep. 155 // record of how long to sleep when we do sleep.
154 state_->delayed_work_time = delayed_work_time; 156 state_->delayed_work_time = delayed_work_time;
155 return; 157 return;
156 } 158 }
157
158 base::MessagePumpForUI::ScheduleDelayedWork(delayed_work_time);
159 } 159 }
160 160
161 // static 161 // static
162 bool NestedMessagePumpAndroid::RegisterJni(JNIEnv* env) { 162 bool NestedMessagePumpAndroid::RegisterJni(JNIEnv* env) {
163 return RegisterNativesImpl(env); 163 return RegisterNativesImpl(env);
164 } 164 }
165 165
166 } // namespace content 166 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698