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

Side by Side Diff: base/message_pump_glib.cc

Issue 10143001: Work in progress: Adds MessagePumpDispatcher::ShouldExit(). This is used to handle the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <glib.h> 10 #include <glib.h>
11 11
12 #include "base/eintr_wrapper.h" 12 #include "base/eintr_wrapper.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_pump_dispatcher.h"
14 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
15 16
16 namespace { 17 namespace {
17 18
18 // Return a timeout suitable for the glib loop, -1 to block forever, 19 // Return a timeout suitable for the glib loop, -1 to block forever,
19 // 0 to return right away, or a timeout in milliseconds from now. 20 // 0 to return right away, or a timeout in milliseconds from now.
20 int GetTimeIntervalMilliseconds(const base::TimeTicks& from) { 21 int GetTimeIntervalMilliseconds(const base::TimeTicks& from) {
21 if (from.is_null()) 22 if (from.is_null())
22 return -1; 23 return -1;
23 24
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (GetTimeIntervalMilliseconds(delayed_work_time_) == 0) { 265 if (GetTimeIntervalMilliseconds(delayed_work_time_) == 0) {
265 // The timer has expired. That condition will stay true until we process 266 // The timer has expired. That condition will stay true until we process
266 // that delayed work, so we don't need to record this differently. 267 // that delayed work, so we don't need to record this differently.
267 return true; 268 return true;
268 } 269 }
269 270
270 return false; 271 return false;
271 } 272 }
272 273
273 void MessagePumpGlib::HandleDispatch() { 274 void MessagePumpGlib::HandleDispatch() {
275 MessagePumpDispatcher* dispatcher = GetDispatcher();
276 if (dispatcher && dispatcher->ShouldExit()) {
277 state_->should_quit = true;
278 return;
279 }
280
274 state_->has_work = false; 281 state_->has_work = false;
275 if (state_->delegate->DoWork()) { 282 if (state_->delegate->DoWork()) {
276 // NOTE: on Windows at this point we would call ScheduleWork (see 283 // NOTE: on Windows at this point we would call ScheduleWork (see
277 // MessagePumpGlib::HandleWorkMessage in message_pump_win.cc). But here, 284 // MessagePumpGlib::HandleWorkMessage in message_pump_win.cc). But here,
278 // instead of posting a message on the wakeup pipe, we can avoid the 285 // instead of posting a message on the wakeup pipe, we can avoid the
279 // syscalls and just signal that we have more work. 286 // syscalls and just signal that we have more work.
280 state_->has_work = true; 287 state_->has_work = true;
281 } 288 }
282 289
283 if (state_->should_quit) 290 if (state_->should_quit)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // adjusted. This will cause us to try to do work, but that's ok. 328 // adjusted. This will cause us to try to do work, but that's ok.
322 delayed_work_time_ = delayed_work_time; 329 delayed_work_time_ = delayed_work_time;
323 ScheduleWork(); 330 ScheduleWork();
324 } 331 }
325 332
326 MessagePumpDispatcher* MessagePumpGlib::GetDispatcher() { 333 MessagePumpDispatcher* MessagePumpGlib::GetDispatcher() {
327 return state_ ? state_->dispatcher : NULL; 334 return state_ ? state_->dispatcher : NULL;
328 } 335 }
329 336
330 } // namespace base 337 } // namespace base
OLDNEW
« no previous file with comments | « base/message_pump_dispatcher.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698