OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_pump_glib.h" | 5 #include "base/message_pump_glib.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <math.h> | 8 #include <math.h> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 g_source_destroy(work_source_); | 115 g_source_destroy(work_source_); |
116 g_source_unref(work_source_); | 116 g_source_unref(work_source_); |
117 close(wakeup_pipe_read_); | 117 close(wakeup_pipe_read_); |
118 close(wakeup_pipe_write_); | 118 close(wakeup_pipe_write_); |
119 } | 119 } |
120 | 120 |
121 void MessagePumpForUI::Run(Delegate* delegate) { | 121 void MessagePumpForUI::Run(Delegate* delegate) { |
122 #ifndef NDEBUG | 122 #ifndef NDEBUG |
123 // Make sure we only run this on one thread. GTK only has one message pump | 123 // Make sure we only run this on one thread. GTK only has one message pump |
124 // so we can only have one UI loop per process. | 124 // so we can only have one UI loop per process. |
125 static int thread_id = PlatformThread::CurrentId(); | 125 static PlatformThreadId thread_id = PlatformThread::CurrentId(); |
126 DCHECK(thread_id == PlatformThread::CurrentId()) << | 126 DCHECK(thread_id == PlatformThread::CurrentId()) << |
127 "Running MessagePumpForUI on two different threads; " | 127 "Running MessagePumpForUI on two different threads; " |
128 "this is unsupported by GLib!"; | 128 "this is unsupported by GLib!"; |
129 #endif | 129 #endif |
130 | 130 |
131 RunState state; | 131 RunState state; |
132 state.delegate = delegate; | 132 state.delegate = delegate; |
133 state.should_quit = false; | 133 state.should_quit = false; |
134 state.run_depth = state_ ? state_->run_depth + 1 : 1; | 134 state.run_depth = state_ ? state_->run_depth + 1 : 1; |
135 // We really only do a single task for each iteration of the loop. If we | 135 // We really only do a single task for each iteration of the loop. If we |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 void MessagePumpForUI::ScheduleDelayedWork(const Time& delayed_work_time) { | 230 void MessagePumpForUI::ScheduleDelayedWork(const Time& delayed_work_time) { |
231 // We need to wake up the loop in case the poll timeout needs to be | 231 // We need to wake up the loop in case the poll timeout needs to be |
232 // adjusted. This will cause us to try to do work, but that's ok. | 232 // adjusted. This will cause us to try to do work, but that's ok. |
233 delayed_work_time_ = delayed_work_time; | 233 delayed_work_time_ = delayed_work_time; |
234 ScheduleWork(); | 234 ScheduleWork(); |
235 } | 235 } |
236 | 236 |
237 } // namespace base | 237 } // namespace base |
OLD | NEW |