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

Side by Side Diff: base/message_loop.cc

Issue 7250001: Refactor the glib message-pump, and use it as the base for a gtk message pump and an X message pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: media.gyp update Created 9 years, 6 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_glib.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/debug/alias.h" 11 #include "base/debug/alias.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_pump_default.h" 15 #include "base/message_pump_default.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 17 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
18 #include "base/threading/thread_local.h" 18 #include "base/threading/thread_local.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "base/tracked_objects.h" 20 #include "base/tracked_objects.h"
21 21
22 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
23 #include "base/message_pump_mac.h" 23 #include "base/message_pump_mac.h"
24 #endif 24 #endif
25 #if defined(OS_POSIX) 25 #if defined(OS_POSIX)
26 #include "base/message_pump_libevent.h" 26 #include "base/message_pump_libevent.h"
27 #endif 27 #endif
28
28 #if defined(OS_POSIX) && !defined(OS_MACOSX) 29 #if defined(OS_POSIX) && !defined(OS_MACOSX)
29 #include <gdk/gdk.h> 30 #include <gdk/gdk.h>
30 #include <gdk/gdkx.h> 31 #include <gdk/gdkx.h>
31 #include "base/message_pump_glib.h"
32 #endif
33 #if defined(TOUCH_UI) 32 #if defined(TOUCH_UI)
34 #include "base/message_pump_glib_x.h" 33 #include "base/message_pump_x.h"
35 #endif 34 #else
35 #include "base/message_pump_gtk.h"
36 #endif // defined(TOUCH_UI)
37 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
36 38
37 using base::TimeDelta; 39 using base::TimeDelta;
38 using base::TimeTicks; 40 using base::TimeTicks;
39 41
40 namespace { 42 namespace {
41 43
42 // A lazily created thread local storage for quick access to a thread's message 44 // A lazily created thread local storage for quick access to a thread's message
43 // loop, if one exists. This should be safe and free of static constructors. 45 // loop, if one exists. This should be safe and free of static constructors.
44 base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr( 46 base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr(
45 base::LINKER_INITIALIZED); 47 base::LINKER_INITIALIZED);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 lazy_tls_ptr.Pointer()->Set(this); 171 lazy_tls_ptr.Pointer()->Set(this);
170 172
171 // TODO(rvargas): Get rid of the OS guards. 173 // TODO(rvargas): Get rid of the OS guards.
172 #if defined(OS_WIN) 174 #if defined(OS_WIN)
173 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() 175 #define MESSAGE_PUMP_UI new base::MessagePumpForUI()
174 #define MESSAGE_PUMP_IO new base::MessagePumpForIO() 176 #define MESSAGE_PUMP_IO new base::MessagePumpForIO()
175 #elif defined(OS_MACOSX) 177 #elif defined(OS_MACOSX)
176 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create() 178 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create()
177 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() 179 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
178 #elif defined(TOUCH_UI) 180 #elif defined(TOUCH_UI)
179 #define MESSAGE_PUMP_UI new base::MessagePumpGlibX() 181 #define MESSAGE_PUMP_UI new base::MessagePumpX()
180 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() 182 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
181 #elif defined(OS_NACL) 183 #elif defined(OS_NACL)
182 // Currently NaCl doesn't have a UI or an IO MessageLoop. 184 // Currently NaCl doesn't have a UI or an IO MessageLoop.
183 // TODO(abarth): Figure out if we need these. 185 // TODO(abarth): Figure out if we need these.
184 #define MESSAGE_PUMP_UI NULL 186 #define MESSAGE_PUMP_UI NULL
185 #define MESSAGE_PUMP_IO NULL 187 #define MESSAGE_PUMP_IO NULL
186 #elif defined(OS_POSIX) // POSIX but not MACOSX. 188 #elif defined(OS_POSIX) // POSIX but not MACOSX.
187 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() 189 #define MESSAGE_PUMP_UI new base::MessagePumpGtk()
188 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() 190 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
189 #else 191 #else
190 #error Not implemented 192 #error Not implemented
191 #endif 193 #endif
192 194
193 if (type_ == TYPE_UI) { 195 if (type_ == TYPE_UI) {
194 pump_ = MESSAGE_PUMP_UI; 196 pump_ = MESSAGE_PUMP_UI;
195 } else if (type_ == TYPE_IO) { 197 } else if (type_ == TYPE_IO) {
196 pump_ = MESSAGE_PUMP_IO; 198 pump_ = MESSAGE_PUMP_IO;
197 } else { 199 } else {
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 Watcher *delegate) { 865 Watcher *delegate) {
864 return pump_libevent()->WatchFileDescriptor( 866 return pump_libevent()->WatchFileDescriptor(
865 fd, 867 fd,
866 persistent, 868 persistent,
867 static_cast<base::MessagePumpLibevent::Mode>(mode), 869 static_cast<base::MessagePumpLibevent::Mode>(mode),
868 controller, 870 controller,
869 delegate); 871 delegate);
870 } 872 }
871 873
872 #endif 874 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/message_pump_glib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698