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

Side by Side Diff: base/message_loop/message_loop.h

Issue 1223193004: Revert of base: Make it possible to replace the MessageLoop's task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | base/message_loop/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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_MESSAGE_LOOP_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 Type type() const { return type_; } 289 Type type() const { return type_; }
290 290
291 // Optional call to connect the thread name with this loop. 291 // Optional call to connect the thread name with this loop.
292 void set_thread_name(const std::string& thread_name) { 292 void set_thread_name(const std::string& thread_name) {
293 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; 293 DCHECK(thread_name_.empty()) << "Should not rename this thread!";
294 thread_name_ = thread_name; 294 thread_name_ = thread_name;
295 } 295 }
296 const std::string& thread_name() const { return thread_name_; } 296 const std::string& thread_name() const { return thread_name_; }
297 297
298 // Gets the TaskRunner associated with this message loop. 298 // Gets the TaskRunner associated with this message loop.
299 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { 299 // TODO(skyostil): Change this to return a const reference to a refptr
300 return task_runner_; 300 // once the internal type matches what is being returned (crbug.com/465354).
301 } 301 scoped_refptr<SingleThreadTaskRunner> task_runner() { return task_runner_; }
302
303 // Sets a new TaskRunner for this message loop. The message loop must already
304 // have been bound to a thread prior to this call, and the task runner must
305 // belong to that thread. Note that changing the task runner will also affect
306 // the ThreadTaskRunnerHandle for the target thread. Must be called on the
307 // thread to which the message loop is bound.
308 void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner);
309 302
310 // Enables or disables the recursive task processing. This happens in the case 303 // Enables or disables the recursive task processing. This happens in the case
311 // of recursive message loops. Some unwanted message loop may occurs when 304 // of recursive message loops. Some unwanted message loop may occurs when
312 // using common controls or printer functions. By default, recursive task 305 // using common controls or printer functions. By default, recursive task
313 // processing is disabled. 306 // processing is disabled.
314 // 307 //
315 // Please utilize |ScopedNestableTaskAllower| instead of calling these methods 308 // Please utilize |ScopedNestableTaskAllower| instead of calling these methods
316 // directly. In general nestable message loops are to be avoided. They are 309 // directly. In general nestable message loops are to be avoided. They are
317 // dangerous and difficult to get right, so please use with extreme caution. 310 // dangerous and difficult to get right, so please use with extreme caution.
318 // 311 //
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 HistogramBase* message_histogram_; 514 HistogramBase* message_histogram_;
522 515
523 RunLoop* run_loop_; 516 RunLoop* run_loop_;
524 517
525 ObserverList<TaskObserver> task_observers_; 518 ObserverList<TaskObserver> task_observers_;
526 519
527 debug::TaskAnnotator task_annotator_; 520 debug::TaskAnnotator task_annotator_;
528 521
529 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; 522 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
530 523
531 // A task runner which we haven't bound to a thread yet.
532 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_;
533
534 // The task runner associated with this message loop. 524 // The task runner associated with this message loop.
535 scoped_refptr<SingleThreadTaskRunner> task_runner_; 525 scoped_refptr<internal::MessageLoopTaskRunner> task_runner_;
536 scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; 526 scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
537 527
538 template <class T, class R> friend class base::subtle::DeleteHelperInternal; 528 template <class T, class R> friend class base::subtle::DeleteHelperInternal;
539 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; 529 template <class T, class R> friend class base::subtle::ReleaseHelperInternal;
540 530
541 void DeleteSoonInternal(const tracked_objects::Location& from_here, 531 void DeleteSoonInternal(const tracked_objects::Location& from_here,
542 void(*deleter)(const void*), 532 void(*deleter)(const void*),
543 const void* object); 533 const void* object);
544 void ReleaseSoonInternal(const tracked_objects::Location& from_here, 534 void ReleaseSoonInternal(const tracked_objects::Location& from_here,
545 void(*releaser)(const void*), 535 void(*releaser)(const void*),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 673
684 // Do not add any member variables to MessageLoopForIO! This is important b/c 674 // Do not add any member variables to MessageLoopForIO! This is important b/c
685 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 675 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
686 // data that you need should be stored on the MessageLoop's pump_ instance. 676 // data that you need should be stored on the MessageLoop's pump_ instance.
687 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 677 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
688 MessageLoopForIO_should_not_have_extra_member_variables); 678 MessageLoopForIO_should_not_have_extra_member_variables);
689 679
690 } // namespace base 680 } // namespace base
691 681
692 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 682 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698