| 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 // tasks (to faciliate FIFO sorting when two tasks have the same | 617 // tasks (to faciliate FIFO sorting when two tasks have the same |
| 618 // delayed_run_time value) and for identifying the task in about:tracing. | 618 // delayed_run_time value) and for identifying the task in about:tracing. |
| 619 pending_task->sequence_num = next_sequence_num_++; | 619 pending_task->sequence_num = next_sequence_num_++; |
| 620 | 620 |
| 621 TRACE_EVENT_FLOW_BEGIN0("task", "MessageLoop::PostTask", | 621 TRACE_EVENT_FLOW_BEGIN0("task", "MessageLoop::PostTask", |
| 622 TRACE_ID_MANGLE(GetTaskTraceID(*pending_task, this))); | 622 TRACE_ID_MANGLE(GetTaskTraceID(*pending_task, this))); |
| 623 | 623 |
| 624 bool was_empty = incoming_queue_.empty(); | 624 bool was_empty = incoming_queue_.empty(); |
| 625 incoming_queue_.push(*pending_task); | 625 incoming_queue_.push(*pending_task); |
| 626 pending_task->task.Reset(); | 626 pending_task->task.Reset(); |
| 627 if (!was_empty) | 627 // The Android UI message loop needs to get notified each time |
| 628 // a task is added to the incoming queue |
| 629 if (!was_empty && !pump_->NeedsScheduleWorkPerTask()) |
| 628 return true; // Someone else should have started the sub-pump. | 630 return true; // Someone else should have started the sub-pump. |
| 629 | 631 |
| 630 pump = pump_; | 632 pump = pump_; |
| 631 } | 633 } |
| 632 // Since the incoming_queue_ may contain a task that destroys this message | 634 // Since the incoming_queue_ may contain a task that destroys this message |
| 633 // loop, we cannot exit incoming_queue_lock_ until we are done with |this|. | 635 // loop, we cannot exit incoming_queue_lock_ until we are done with |this|. |
| 634 // We use a stack-based reference to the message pump so that we can call | 636 // We use a stack-based reference to the message pump so that we can call |
| 635 // ScheduleWork outside of incoming_queue_lock_. | 637 // ScheduleWork outside of incoming_queue_lock_. |
| 636 | 638 |
| 637 pump->ScheduleWork(); | 639 pump->ScheduleWork(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 fd, | 827 fd, |
| 826 persistent, | 828 persistent, |
| 827 mode, | 829 mode, |
| 828 controller, | 830 controller, |
| 829 delegate); | 831 delegate); |
| 830 } | 832 } |
| 831 | 833 |
| 832 #endif | 834 #endif |
| 833 | 835 |
| 834 } // namespace base | 836 } // namespace base |
| OLD | NEW |