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

Side by Side Diff: base/message_loop.cc

Issue 199105: Continue with the FreeBSD port - this version builds and links, though... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « base/message_loop.h ('k') | base/path_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "base/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_pump_default.h" 12 #include "base/message_pump_default.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/thread_local.h" 14 #include "base/thread_local.h"
15 15
16 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
17 #include "base/message_pump_mac.h" 17 #include "base/message_pump_mac.h"
18 #endif 18 #endif
19 #if defined(OS_POSIX) 19 #if defined(OS_POSIX)
20 #include "base/message_pump_libevent.h" 20 #include "base/message_pump_libevent.h"
21 #include "base/third_party/valgrind/valgrind.h" 21 #include "base/third_party/valgrind/valgrind.h"
22 #endif 22 #endif
23 #if defined(OS_LINUX) 23 #if defined(USE_X11)
24 #include "base/message_pump_glib.h" 24 #include "base/message_pump_glib.h"
25 #endif 25 #endif
26 26
27 using base::Time; 27 using base::Time;
28 using base::TimeDelta; 28 using base::TimeDelta;
29 29
30 // A lazily created thread local storage for quick access to a thread's message 30 // A lazily created thread local storage for quick access to a thread's message
31 // loop, if one exists. This should be safe and free of static constructors. 31 // loop, if one exists. This should be safe and free of static constructors.
32 static base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr( 32 static base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr(
33 base::LINKER_INITIALIZED); 33 base::LINKER_INITIALIZED);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } else if (type_ == TYPE_IO) { 92 } else if (type_ == TYPE_IO) {
93 pump_ = new base::MessagePumpForIO(); 93 pump_ = new base::MessagePumpForIO();
94 } else { 94 } else {
95 DCHECK(type_ == TYPE_UI); 95 DCHECK(type_ == TYPE_UI);
96 pump_ = new base::MessagePumpForUI(); 96 pump_ = new base::MessagePumpForUI();
97 } 97 }
98 #elif defined(OS_POSIX) 98 #elif defined(OS_POSIX)
99 if (type_ == TYPE_UI) { 99 if (type_ == TYPE_UI) {
100 #if defined(OS_MACOSX) 100 #if defined(OS_MACOSX)
101 pump_ = base::MessagePumpMac::Create(); 101 pump_ = base::MessagePumpMac::Create();
102 #elif defined(OS_LINUX) 102 #elif defined(USE_X11)
103 pump_ = new base::MessagePumpForUI(); 103 pump_ = new base::MessagePumpForUI();
104 #endif // OS_LINUX 104 #endif // USE_X11
105 } else if (type_ == TYPE_IO) { 105 } else if (type_ == TYPE_IO) {
106 pump_ = new base::MessagePumpLibevent(); 106 pump_ = new base::MessagePumpLibevent();
107 } else { 107 } else {
108 pump_ = new base::MessagePumpDefault(); 108 pump_ = new base::MessagePumpDefault();
109 } 109 }
110 #endif // OS_POSIX 110 #endif // OS_POSIX
111 } 111 }
112 112
113 MessageLoop::~MessageLoop() { 113 MessageLoop::~MessageLoop() {
114 DCHECK(this == current()); 114 DCHECK(this == current());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 RunInternal(); 181 RunInternal();
182 } 182 }
183 183
184 //------------------------------------------------------------------------------ 184 //------------------------------------------------------------------------------
185 185
186 void MessageLoop::RunInternal() { 186 void MessageLoop::RunInternal() {
187 DCHECK(this == current()); 187 DCHECK(this == current());
188 188
189 StartHistogrammer(); 189 StartHistogrammer();
190 190
191 #if defined(OS_WIN) || defined(OS_LINUX) 191 #if defined(OS_WIN) || defined(USE_X11)
192 if (state_->dispatcher && type() == TYPE_UI) { 192 if (state_->dispatcher && type() == TYPE_UI) {
193 static_cast<base::MessagePumpForUI*>(pump_.get())-> 193 static_cast<base::MessagePumpForUI*>(pump_.get())->
194 RunWithDispatcher(this, state_->dispatcher); 194 RunWithDispatcher(this, state_->dispatcher);
195 return; 195 return;
196 } 196 }
197 #endif 197 #endif
198 198
199 pump_->Run(this); 199 pump_->Run(this);
200 } 200 }
201 201
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 previous_state_ = loop_->state_; 474 previous_state_ = loop_->state_;
475 if (previous_state_) { 475 if (previous_state_) {
476 run_depth = previous_state_->run_depth + 1; 476 run_depth = previous_state_->run_depth + 1;
477 } else { 477 } else {
478 run_depth = 1; 478 run_depth = 1;
479 } 479 }
480 loop_->state_ = this; 480 loop_->state_ = this;
481 481
482 // Initialize the other fields: 482 // Initialize the other fields:
483 quit_received = false; 483 quit_received = false;
484 #if defined(OS_WIN) || defined(OS_LINUX) 484 #if defined(OS_WIN) || defined(USE_X11)
485 dispatcher = NULL; 485 dispatcher = NULL;
486 #endif 486 #endif
487 } 487 }
488 488
489 MessageLoop::AutoRunState::~AutoRunState() { 489 MessageLoop::AutoRunState::~AutoRunState() {
490 loop_->state_ = previous_state_; 490 loop_->state_ = previous_state_;
491 } 491 }
492 492
493 //------------------------------------------------------------------------------ 493 //------------------------------------------------------------------------------
494 // MessageLoop::PendingTask 494 // MessageLoop::PendingTask
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 577 }
578 void MessageLoopForUI::DidProcessMessage(const MSG& message) { 578 void MessageLoopForUI::DidProcessMessage(const MSG& message) {
579 pump_win()->DidProcessMessage(message); 579 pump_win()->DidProcessMessage(message);
580 } 580 }
581 void MessageLoopForUI::PumpOutPendingPaintMessages() { 581 void MessageLoopForUI::PumpOutPendingPaintMessages() {
582 pump_ui()->PumpOutPendingPaintMessages(); 582 pump_ui()->PumpOutPendingPaintMessages();
583 } 583 }
584 584
585 #endif // defined(OS_WIN) 585 #endif // defined(OS_WIN)
586 586
587 #if defined(OS_LINUX) || defined(OS_WIN) 587 #if defined(USE_X11) || defined(OS_WIN)
588 void MessageLoopForUI::AddObserver(Observer* observer) { 588 void MessageLoopForUI::AddObserver(Observer* observer) {
589 pump_ui()->AddObserver(observer); 589 pump_ui()->AddObserver(observer);
590 } 590 }
591 591
592 void MessageLoopForUI::RemoveObserver(Observer* observer) { 592 void MessageLoopForUI::RemoveObserver(Observer* observer) {
593 pump_ui()->RemoveObserver(observer); 593 pump_ui()->RemoveObserver(observer);
594 } 594 }
595 595
596 void MessageLoopForUI::Run(Dispatcher* dispatcher) { 596 void MessageLoopForUI::Run(Dispatcher* dispatcher) {
597 AutoRunState save_state(this); 597 AutoRunState save_state(this);
598 state_->dispatcher = dispatcher; 598 state_->dispatcher = dispatcher;
599 RunHandler(); 599 RunHandler();
600 } 600 }
601 #endif // defined(OS_LINUX) || defined(OS_WIN) 601 #endif // defined(USE_X11) || defined(OS_WIN)
602 602
603 //------------------------------------------------------------------------------ 603 //------------------------------------------------------------------------------
604 // MessageLoopForIO 604 // MessageLoopForIO
605 605
606 #if defined(OS_WIN) 606 #if defined(OS_WIN)
607 607
608 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) { 608 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) {
609 pump_io()->RegisterIOHandler(file, handler); 609 pump_io()->RegisterIOHandler(file, handler);
610 } 610 }
611 611
(...skipping 10 matching lines...) Expand all
622 Watcher *delegate) { 622 Watcher *delegate) {
623 return pump_libevent()->WatchFileDescriptor( 623 return pump_libevent()->WatchFileDescriptor(
624 fd, 624 fd,
625 persistent, 625 persistent,
626 static_cast<base::MessagePumpLibevent::Mode>(mode), 626 static_cast<base::MessagePumpLibevent::Mode>(mode),
627 controller, 627 controller,
628 delegate); 628 delegate);
629 } 629 }
630 630
631 #endif 631 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/path_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698