| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/test/browser_test_message_pump_android.h" | 5 #include "content/test/browser_test_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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 : state_(NULL) { | 49 : state_(NULL) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 BrowserTestMessagePumpAndroid::~BrowserTestMessagePumpAndroid() { | 52 BrowserTestMessagePumpAndroid::~BrowserTestMessagePumpAndroid() { |
| 53 } | 53 } |
| 54 | 54 |
| 55 void BrowserTestMessagePumpAndroid::Run(Delegate* delegate) { | 55 void BrowserTestMessagePumpAndroid::Run(Delegate* delegate) { |
| 56 RunState state(delegate, state_ ? state_->run_depth + 1 : 1); | 56 RunState state(delegate, state_ ? state_->run_depth + 1 : 1); |
| 57 RunState* previous_state = state_; | 57 RunState* previous_state = state_; |
| 58 state_ = &state; | 58 state_ = &state; |
| 59 DCHECK(state_->run_depth <= 1) << "Only one level nested loops supported"; | |
| 60 | 59 |
| 61 JNIEnv* env = base::android::AttachCurrentThread(); | 60 JNIEnv* env = base::android::AttachCurrentThread(); |
| 62 DCHECK(env); | 61 DCHECK(env); |
| 63 | 62 |
| 64 // Need to cap the wait time to allow task processing on the java | 63 // Need to cap the wait time to allow task processing on the java |
| 65 // side. Otherwise, a long wait time on the native will starve java | 64 // side. Otherwise, a long wait time on the native will starve java |
| 66 // tasks. | 65 // tasks. |
| 67 base::TimeDelta max_delay = base::TimeDelta::FromMilliseconds(100); | 66 base::TimeDelta max_delay = base::TimeDelta::FromMilliseconds(100); |
| 68 | 67 |
| 69 for (;;) { | 68 for (;;) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 155 |
| 157 base::MessagePumpForUI::ScheduleDelayedWork(delayed_work_time); | 156 base::MessagePumpForUI::ScheduleDelayedWork(delayed_work_time); |
| 158 } | 157 } |
| 159 | 158 |
| 160 // static | 159 // static |
| 161 bool BrowserTestMessagePumpAndroid::RegisterJni(JNIEnv* env) { | 160 bool BrowserTestMessagePumpAndroid::RegisterJni(JNIEnv* env) { |
| 162 return RegisterNativesImpl(env); | 161 return RegisterNativesImpl(env); |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace content | 164 } // namespace content |
| OLD | NEW |