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

Side by Side Diff: base/message_loop.cc

Issue 1655007: Make MessageLoop::MessageLoop easier to read. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « no previous file | no next file » | 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) 2010 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"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 MessageLoop::MessageLoop(Type type) 79 MessageLoop::MessageLoop(Type type)
80 : type_(type), 80 : type_(type),
81 nestable_tasks_allowed_(true), 81 nestable_tasks_allowed_(true),
82 exception_restoration_(false), 82 exception_restoration_(false),
83 state_(NULL), 83 state_(NULL),
84 next_sequence_num_(0) { 84 next_sequence_num_(0) {
85 DCHECK(!current()) << "should only have one message loop per thread"; 85 DCHECK(!current()) << "should only have one message loop per thread";
86 lazy_tls_ptr.Pointer()->Set(this); 86 lazy_tls_ptr.Pointer()->Set(this);
87 87
88 // TODO(rvargas): Get rid of the OS guards.
88 #if defined(OS_WIN) 89 #if defined(OS_WIN)
89 // TODO(rvargas): Get rid of the OS guards. 90 #define MESSAGE_PUMP_UI new base::MessagePumpForUI()
90 if (type_ == TYPE_DEFAULT) { 91 #define MESSAGE_PUMP_IO new base::MessagePumpForIO()
91 pump_ = new base::MessagePumpDefault(); 92 #elif defined(OS_MACOSX)
93 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create()
94 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
95 #elif defined(OS_POSIX) // POSIX but not MACOSX.
96 #define MESSAGE_PUMP_UI new base::MessagePumpForUI()
97 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
98 #else
99 #error Not implemented
100 #endif
101
102 if (type_ == TYPE_UI) {
103 pump_ = MESSAGE_PUMP_UI;
92 } else if (type_ == TYPE_IO) { 104 } else if (type_ == TYPE_IO) {
93 pump_ = new base::MessagePumpForIO(); 105 pump_ = MESSAGE_PUMP_IO;
94 } else { 106 } else {
95 DCHECK(type_ == TYPE_UI); 107 DCHECK_EQ(TYPE_DEFAULT, type_);
96 pump_ = new base::MessagePumpForUI();
97 }
98 #elif defined(OS_POSIX)
99 if (type_ == TYPE_UI) {
100 #if defined(OS_MACOSX)
101 pump_ = base::MessagePumpMac::Create();
102 #else
103 pump_ = new base::MessagePumpForUI();
104 #endif
105 } else if (type_ == TYPE_IO) {
106 pump_ = new base::MessagePumpLibevent();
107 } else {
108 pump_ = new base::MessagePumpDefault(); 108 pump_ = new base::MessagePumpDefault();
109 } 109 }
110 #endif // OS_POSIX
111 } 110 }
112 111
113 MessageLoop::~MessageLoop() { 112 MessageLoop::~MessageLoop() {
114 DCHECK(this == current()); 113 DCHECK(this == current());
115 114
116 // Let interested parties have one last shot at accessing this. 115 // Let interested parties have one last shot at accessing this.
117 FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, 116 FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_,
118 WillDestroyCurrentMessageLoop()); 117 WillDestroyCurrentMessageLoop());
119 118
120 DCHECK(!state_); 119 DCHECK(!state_);
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 Watcher *delegate) { 634 Watcher *delegate) {
636 return pump_libevent()->WatchFileDescriptor( 635 return pump_libevent()->WatchFileDescriptor(
637 fd, 636 fd,
638 persistent, 637 persistent,
639 static_cast<base::MessagePumpLibevent::Mode>(mode), 638 static_cast<base::MessagePumpLibevent::Mode>(mode),
640 controller, 639 controller,
641 delegate); 640 delegate);
642 } 641 }
643 642
644 #endif 643 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698