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

Side by Side Diff: base/message_loop.cc

Issue 3094: As an intermediary step towards having a message pump handling IO through com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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/message_pump_win.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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_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"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 MessageLoop::MessageLoop(Type type) 72 MessageLoop::MessageLoop(Type type)
73 : type_(type), 73 : type_(type),
74 nestable_tasks_allowed_(true), 74 nestable_tasks_allowed_(true),
75 exception_restoration_(false), 75 exception_restoration_(false),
76 state_(NULL), 76 state_(NULL),
77 next_sequence_num_(0) { 77 next_sequence_num_(0) {
78 DCHECK(!current()) << "should only have one message loop per thread"; 78 DCHECK(!current()) << "should only have one message loop per thread";
79 lazy_tls_ptr.Pointer()->Set(this); 79 lazy_tls_ptr.Pointer()->Set(this);
80 80
81 // TODO(darin): Choose the pump based on the requested type.
82 #if defined(OS_WIN) 81 #if defined(OS_WIN)
82 // TODO(rvargas): Get rid of the OS guards.
83 if (type_ == TYPE_DEFAULT) { 83 if (type_ == TYPE_DEFAULT) {
84 pump_ = new base::MessagePumpDefault(); 84 pump_ = new base::MessagePumpDefault();
85 } else if (type_ == TYPE_IO) {
86 pump_ = new base::MessagePumpForIO();
85 } else { 87 } else {
86 pump_ = new base::MessagePumpWin(); 88 DCHECK(type_ == TYPE_UI);
89 pump_ = new base::MessagePumpForUI();
87 } 90 }
88 #elif defined(OS_POSIX) 91 #elif defined(OS_POSIX)
89 #if defined(OS_MACOSX) 92 #if defined(OS_MACOSX)
90 if (type_ == TYPE_UI) { 93 if (type_ == TYPE_UI) {
91 pump_ = base::MessagePumpMac::Create(); 94 pump_ = base::MessagePumpMac::Create();
92 } else 95 } else
93 #endif // OS_MACOSX 96 #endif // OS_MACOSX
94 if (type_ == TYPE_IO) { 97 if (type_ == TYPE_IO) {
95 pump_ = new base::MessagePumpLibevent(); 98 pump_ = new base::MessagePumpLibevent();
96 } else { 99 } else {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 572 }
570 573
571 #endif // defined(OS_WIN) 574 #endif // defined(OS_WIN)
572 575
573 //------------------------------------------------------------------------------ 576 //------------------------------------------------------------------------------
574 // MessageLoopForIO 577 // MessageLoopForIO
575 578
576 #if defined(OS_WIN) 579 #if defined(OS_WIN)
577 580
578 void MessageLoopForIO::WatchObject(HANDLE object, Watcher* watcher) { 581 void MessageLoopForIO::WatchObject(HANDLE object, Watcher* watcher) {
579 pump_win()->WatchObject(object, watcher); 582 pump_io()->WatchObject(object, watcher);
580 } 583 }
581 584
582 #elif defined(OS_POSIX) 585 #elif defined(OS_POSIX)
583 586
584 void MessageLoopForIO::WatchSocket(int socket, short interest_mask, 587 void MessageLoopForIO::WatchSocket(int socket, short interest_mask,
585 struct event* e, Watcher* watcher) { 588 struct event* e, Watcher* watcher) {
586 pump_libevent()->WatchSocket(socket, interest_mask, e, watcher); 589 pump_libevent()->WatchSocket(socket, interest_mask, e, watcher);
587 } 590 }
588 591
589 void MessageLoopForIO::UnwatchSocket(struct event* e) { 592 void MessageLoopForIO::UnwatchSocket(struct event* e) {
590 pump_libevent()->UnwatchSocket(e); 593 pump_libevent()->UnwatchSocket(e);
591 } 594 }
592 #endif 595 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/message_pump_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698