| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 break; | 87 break; |
| 88 | 88 |
| 89 if (did_work) | 89 if (did_work) |
| 90 continue; | 90 continue; |
| 91 | 91 |
| 92 // No native tasks to process right now. Process tasks from the Java | 92 // No native tasks to process right now. Process tasks from the Java |
| 93 // System message handler. This will return when the java message queue | 93 // System message handler. This will return when the java message queue |
| 94 // is idle. | 94 // is idle. |
| 95 bool ret = Java_NestedSystemMessageHandler_runNestedLoopTillIdle( | 95 bool ret = Java_NestedSystemMessageHandler_runNestedLoopTillIdle( |
| 96 env, g_message_handler_obj.Get()); | 96 env, g_message_handler_obj.Get()); |
| 97 CHECK(ret) << "Error running java message loop, tests will likely fail."; | 97 // Error running java message loop, tests will likely fail. |
| 98 CHECK(ret); |
| 98 | 99 |
| 99 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 100 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 100 if (state_->delayed_work_time.is_null()) { | 101 if (state_->delayed_work_time.is_null()) { |
| 101 state_->waitable_event.TimedWait(max_delay); | 102 state_->waitable_event.TimedWait(max_delay); |
| 102 } else { | 103 } else { |
| 103 base::TimeDelta delay = | 104 base::TimeDelta delay = |
| 104 state_->delayed_work_time - base::TimeTicks::Now(); | 105 state_->delayed_work_time - base::TimeTicks::Now(); |
| 105 if (delay > max_delay) | 106 if (delay > max_delay) |
| 106 delay = max_delay; | 107 delay = max_delay; |
| 107 if (delay > base::TimeDelta()) { | 108 if (delay > base::TimeDelta()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if (state_) { | 146 if (state_) { |
| 146 // We know that we can't be blocked on Wait right now since this method can | 147 // We know that we can't be blocked on Wait right now since this method can |
| 147 // only be called on the same thread as Run, so we only need to update our | 148 // only be called on the same thread as Run, so we only need to update our |
| 148 // record of how long to sleep when we do sleep. | 149 // record of how long to sleep when we do sleep. |
| 149 state_->delayed_work_time = delayed_work_time; | 150 state_->delayed_work_time = delayed_work_time; |
| 150 return; | 151 return; |
| 151 } | 152 } |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace content | 155 } // namespace content |
| OLD | NEW |