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.h

Issue 9034029: Revert 115997 - Replace MessageLoop::DeleteSoon implementation with one that uses base::Bind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 12 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 | base/message_loop.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) 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_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/message_loop_helpers.h"
18 #include "base/message_loop_proxy.h" 17 #include "base/message_loop_proxy.h"
19 #include "base/message_pump.h" 18 #include "base/message_pump.h"
20 #include "base/observer_list.h" 19 #include "base/observer_list.h"
21 #include "base/pending_task.h" 20 #include "base/pending_task.h"
22 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
23 #include "base/task.h" 22 #include "base/task.h"
24 #include "base/tracking_info.h" 23 #include "base/tracking_info.h"
25 #include "base/time.h" 24 #include "base/time.h"
26 25
27 #if defined(OS_WIN) 26 #if defined(OS_WIN)
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // if the object needs to live until the next run of the MessageLoop (for 201 // if the object needs to live until the next run of the MessageLoop (for
203 // example, deleting a RenderProcessHost from within an IPC callback is not 202 // example, deleting a RenderProcessHost from within an IPC callback is not
204 // good). 203 // good).
205 // 204 //
206 // NOTE: This method may be called on any thread. The object will be deleted 205 // NOTE: This method may be called on any thread. The object will be deleted
207 // on the thread that executes MessageLoop::Run(). If this is not the same 206 // on the thread that executes MessageLoop::Run(). If this is not the same
208 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit 207 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit
209 // from RefCountedThreadSafe<T>! 208 // from RefCountedThreadSafe<T>!
210 template <class T> 209 template <class T>
211 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) { 210 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) {
212 base::subtle::DeleteHelperInternal<T, void>::DeleteOnMessageLoop( 211 PostNonNestableTask(from_here, new DeleteTask<T>(object));
213 this, from_here, object);
214 } 212 }
215 213
216 // A variant on PostTask that releases the given reference counted object 214 // A variant on PostTask that releases the given reference counted object
217 // (by calling its Release method). This is useful if the object needs to 215 // (by calling its Release method). This is useful if the object needs to
218 // live until the next run of the MessageLoop, or if the object needs to be 216 // live until the next run of the MessageLoop, or if the object needs to be
219 // released on a particular thread. 217 // released on a particular thread.
220 // 218 //
221 // NOTE: This method may be called on any thread. The object will be 219 // NOTE: This method may be called on any thread. The object will be
222 // released (and thus possibly deleted) on the thread that executes 220 // released (and thus possibly deleted) on the thread that executes
223 // MessageLoop::Run(). If this is not the same as the thread that calls 221 // MessageLoop::Run(). If this is not the same as the thread that calls
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 525
528 // The next sequence number to use for delayed tasks. 526 // The next sequence number to use for delayed tasks.
529 int next_sequence_num_; 527 int next_sequence_num_;
530 528
531 ObserverList<TaskObserver> task_observers_; 529 ObserverList<TaskObserver> task_observers_;
532 530
533 // The message loop proxy associated with this message loop, if one exists. 531 // The message loop proxy associated with this message loop, if one exists.
534 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 532 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
535 533
536 private: 534 private:
537 template <class T, class R> friend class base::subtle::DeleteHelperInternal;
538
539 void DeleteSoonInternal(const tracked_objects::Location& from_here,
540 void(*deleter)(const void*),
541 const void* object);
542
543 DISALLOW_COPY_AND_ASSIGN(MessageLoop); 535 DISALLOW_COPY_AND_ASSIGN(MessageLoop);
544 }; 536 };
545 537
546 //----------------------------------------------------------------------------- 538 //-----------------------------------------------------------------------------
547 // MessageLoopForUI extends MessageLoop with methods that are particular to a 539 // MessageLoopForUI extends MessageLoop with methods that are particular to a
548 // MessageLoop instantiated with TYPE_UI. 540 // MessageLoop instantiated with TYPE_UI.
549 // 541 //
550 // This class is typically used like so: 542 // This class is typically used like so:
551 // MessageLoopForUI::current()->...call some method... 543 // MessageLoopForUI::current()->...call some method...
552 // 544 //
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 #endif // defined(OS_POSIX) 656 #endif // defined(OS_POSIX)
665 }; 657 };
666 658
667 // Do not add any member variables to MessageLoopForIO! This is important b/c 659 // Do not add any member variables to MessageLoopForIO! This is important b/c
668 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 660 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
669 // data that you need should be stored on the MessageLoop's pump_ instance. 661 // data that you need should be stored on the MessageLoop's pump_ instance.
670 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 662 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
671 MessageLoopForIO_should_not_have_extra_member_variables); 663 MessageLoopForIO_should_not_have_extra_member_variables);
672 664
673 #endif // BASE_MESSAGE_LOOP_H_ 665 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698