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

Side by Side Diff: base/message_loop.h

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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/memory/weak_ptr.h ('k') | base/message_loop_proxy.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 #ifndef BASE_MESSAGE_LOOP_H_ 5 #ifndef BASE_MESSAGE_LOOP_H_
6 #define BASE_MESSAGE_LOOP_H_ 6 #define BASE_MESSAGE_LOOP_H_
7 #pragma once 7 #pragma once
8 8
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 11
12 #include "base/base_api.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/message_pump.h" 16 #include "base/message_pump.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/task.h" 19 #include "base/task.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/tracked.h" 21 #include "base/tracked.h"
22 22
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Sample workaround when inner task processing is needed: 68 // Sample workaround when inner task processing is needed:
69 // bool old_state = MessageLoop::current()->NestableTasksAllowed(); 69 // bool old_state = MessageLoop::current()->NestableTasksAllowed();
70 // MessageLoop::current()->SetNestableTasksAllowed(true); 70 // MessageLoop::current()->SetNestableTasksAllowed(true);
71 // HRESULT hr = DoDragDrop(...); // Implicitly runs a modal message loop here. 71 // HRESULT hr = DoDragDrop(...); // Implicitly runs a modal message loop here.
72 // MessageLoop::current()->SetNestableTasksAllowed(old_state); 72 // MessageLoop::current()->SetNestableTasksAllowed(old_state);
73 // // Process hr (the result returned by DoDragDrop(). 73 // // Process hr (the result returned by DoDragDrop().
74 // 74 //
75 // Please be SURE your task is reentrant (nestable) and all global variables 75 // Please be SURE your task is reentrant (nestable) and all global variables
76 // are stable and accessible before calling SetNestableTasksAllowed(true). 76 // are stable and accessible before calling SetNestableTasksAllowed(true).
77 // 77 //
78 class BASE_API MessageLoop : public base::MessagePump::Delegate { 78 class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
79 public: 79 public:
80 #if defined(OS_WIN) 80 #if defined(OS_WIN)
81 typedef base::MessagePumpWin::Dispatcher Dispatcher; 81 typedef base::MessagePumpWin::Dispatcher Dispatcher;
82 typedef base::MessagePumpForUI::Observer Observer; 82 typedef base::MessagePumpForUI::Observer Observer;
83 #elif !defined(OS_MACOSX) 83 #elif !defined(OS_MACOSX)
84 typedef base::MessagePumpDispatcher Dispatcher; 84 typedef base::MessagePumpDispatcher Dispatcher;
85 typedef base::MessagePumpObserver Observer; 85 typedef base::MessagePumpObserver Observer;
86 #endif 86 #endif
87 87
88 // A MessageLoop has a particular type, which indicates the set of 88 // A MessageLoop has a particular type, which indicates the set of
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 static void InitMessagePumpForUIFactory(MessagePumpFactory* factory); 121 static void InitMessagePumpForUIFactory(MessagePumpFactory* factory);
122 122
123 // A DestructionObserver is notified when the current MessageLoop is being 123 // A DestructionObserver is notified when the current MessageLoop is being
124 // destroyed. These obsevers are notified prior to MessageLoop::current() 124 // destroyed. These obsevers are notified prior to MessageLoop::current()
125 // being changed to return NULL. This gives interested parties the chance to 125 // being changed to return NULL. This gives interested parties the chance to
126 // do final cleanup that depends on the MessageLoop. 126 // do final cleanup that depends on the MessageLoop.
127 // 127 //
128 // NOTE: Any tasks posted to the MessageLoop during this notification will 128 // NOTE: Any tasks posted to the MessageLoop during this notification will
129 // not be run. Instead, they will be deleted. 129 // not be run. Instead, they will be deleted.
130 // 130 //
131 class BASE_API DestructionObserver { 131 class BASE_EXPORT DestructionObserver {
132 public: 132 public:
133 virtual void WillDestroyCurrentMessageLoop() = 0; 133 virtual void WillDestroyCurrentMessageLoop() = 0;
134 134
135 protected: 135 protected:
136 virtual ~DestructionObserver(); 136 virtual ~DestructionObserver();
137 }; 137 };
138 138
139 // Add a DestructionObserver, which will start receiving notifications 139 // Add a DestructionObserver, which will start receiving notifications
140 // immediately. 140 // immediately.
141 void AddDestructionObserver(DestructionObserver* destruction_observer); 141 void AddDestructionObserver(DestructionObserver* destruction_observer);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 exception_restoration_ = restore; 310 exception_restoration_ = restore;
311 } 311 }
312 312
313 // Returns true if we are currently running a nested message loop. 313 // Returns true if we are currently running a nested message loop.
314 bool IsNested(); 314 bool IsNested();
315 315
316 // A TaskObserver is an object that receives task notifications from the 316 // A TaskObserver is an object that receives task notifications from the
317 // MessageLoop. 317 // MessageLoop.
318 // 318 //
319 // NOTE: A TaskObserver implementation should be extremely fast! 319 // NOTE: A TaskObserver implementation should be extremely fast!
320 class BASE_API TaskObserver { 320 class BASE_EXPORT TaskObserver {
321 public: 321 public:
322 TaskObserver(); 322 TaskObserver();
323 323
324 // This method is called before processing a task. 324 // This method is called before processing a task.
325 virtual void WillProcessTask(base::TimeTicks time_posted) = 0; 325 virtual void WillProcessTask(base::TimeTicks time_posted) = 0;
326 326
327 // This method is called after processing a task. 327 // This method is called after processing a task.
328 virtual void DidProcessTask(base::TimeTicks time_posted) = 0; 328 virtual void DidProcessTask(base::TimeTicks time_posted) = 0;
329 329
330 protected: 330 protected:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 376 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
377 Dispatcher* dispatcher; 377 Dispatcher* dispatcher;
378 #endif 378 #endif
379 }; 379 };
380 380
381 #if defined(OS_ANDROID) 381 #if defined(OS_ANDROID)
382 // Android Java process manages the UI thread message loop. So its 382 // Android Java process manages the UI thread message loop. So its
383 // MessagePumpForUI needs to keep the RunState. 383 // MessagePumpForUI needs to keep the RunState.
384 public: 384 public:
385 #endif 385 #endif
386 class BASE_API AutoRunState : RunState { 386 class BASE_EXPORT AutoRunState : RunState {
387 public: 387 public:
388 explicit AutoRunState(MessageLoop* loop); 388 explicit AutoRunState(MessageLoop* loop);
389 ~AutoRunState(); 389 ~AutoRunState();
390 private: 390 private:
391 MessageLoop* loop_; 391 MessageLoop* loop_;
392 RunState* previous_state_; 392 RunState* previous_state_;
393 }; 393 };
394 #if defined(OS_ANDROID) 394 #if defined(OS_ANDROID)
395 protected: 395 protected:
396 #endif 396 #endif
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 DISALLOW_COPY_AND_ASSIGN(MessageLoop); 573 DISALLOW_COPY_AND_ASSIGN(MessageLoop);
574 }; 574 };
575 575
576 //----------------------------------------------------------------------------- 576 //-----------------------------------------------------------------------------
577 // MessageLoopForUI extends MessageLoop with methods that are particular to a 577 // MessageLoopForUI extends MessageLoop with methods that are particular to a
578 // MessageLoop instantiated with TYPE_UI. 578 // MessageLoop instantiated with TYPE_UI.
579 // 579 //
580 // This class is typically used like so: 580 // This class is typically used like so:
581 // MessageLoopForUI::current()->...call some method... 581 // MessageLoopForUI::current()->...call some method...
582 // 582 //
583 class BASE_API MessageLoopForUI : public MessageLoop { 583 class BASE_EXPORT MessageLoopForUI : public MessageLoop {
584 public: 584 public:
585 MessageLoopForUI() : MessageLoop(TYPE_UI) { 585 MessageLoopForUI() : MessageLoop(TYPE_UI) {
586 } 586 }
587 587
588 // Returns the MessageLoopForUI of the current thread. 588 // Returns the MessageLoopForUI of the current thread.
589 static MessageLoopForUI* current() { 589 static MessageLoopForUI* current() {
590 MessageLoop* loop = MessageLoop::current(); 590 MessageLoop* loop = MessageLoop::current();
591 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); 591 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
592 return static_cast<MessageLoopForUI*>(loop); 592 return static_cast<MessageLoopForUI*>(loop);
593 } 593 }
(...skipping 28 matching lines...) Expand all
622 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), 622 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI),
623 MessageLoopForUI_should_not_have_extra_member_variables); 623 MessageLoopForUI_should_not_have_extra_member_variables);
624 624
625 //----------------------------------------------------------------------------- 625 //-----------------------------------------------------------------------------
626 // MessageLoopForIO extends MessageLoop with methods that are particular to a 626 // MessageLoopForIO extends MessageLoop with methods that are particular to a
627 // MessageLoop instantiated with TYPE_IO. 627 // MessageLoop instantiated with TYPE_IO.
628 // 628 //
629 // This class is typically used like so: 629 // This class is typically used like so:
630 // MessageLoopForIO::current()->...call some method... 630 // MessageLoopForIO::current()->...call some method...
631 // 631 //
632 class BASE_API MessageLoopForIO : public MessageLoop { 632 class BASE_EXPORT MessageLoopForIO : public MessageLoop {
633 public: 633 public:
634 #if defined(OS_WIN) 634 #if defined(OS_WIN)
635 typedef base::MessagePumpForIO::IOHandler IOHandler; 635 typedef base::MessagePumpForIO::IOHandler IOHandler;
636 typedef base::MessagePumpForIO::IOContext IOContext; 636 typedef base::MessagePumpForIO::IOContext IOContext;
637 typedef base::MessagePumpForIO::IOObserver IOObserver; 637 typedef base::MessagePumpForIO::IOObserver IOObserver;
638 #elif defined(OS_POSIX) 638 #elif defined(OS_POSIX)
639 typedef base::MessagePumpLibevent::Watcher Watcher; 639 typedef base::MessagePumpLibevent::Watcher Watcher;
640 typedef base::MessagePumpLibevent::FileDescriptorWatcher 640 typedef base::MessagePumpLibevent::FileDescriptorWatcher
641 FileDescriptorWatcher; 641 FileDescriptorWatcher;
642 typedef base::MessagePumpLibevent::IOObserver IOObserver; 642 typedef base::MessagePumpLibevent::IOObserver IOObserver;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 #endif // defined(OS_POSIX) 693 #endif // defined(OS_POSIX)
694 }; 694 };
695 695
696 // Do not add any member variables to MessageLoopForIO! This is important b/c 696 // Do not add any member variables to MessageLoopForIO! This is important b/c
697 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 697 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
698 // data that you need should be stored on the MessageLoop's pump_ instance. 698 // data that you need should be stored on the MessageLoop's pump_ instance.
699 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 699 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
700 MessageLoopForIO_should_not_have_extra_member_variables); 700 MessageLoopForIO_should_not_have_extra_member_variables);
701 701
702 #endif // BASE_MESSAGE_LOOP_H_ 702 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/memory/weak_ptr.h ('k') | base/message_loop_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698