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

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

Issue 1942053002: Deletes base::MessageLoop::set_thread_name(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adds memory barrier Created 4 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
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | base/message_loop/message_loop.cc » ('J')
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 <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 11
12 #include "base/atomicops.h"
12 #include "base/base_export.h" 13 #include "base/base_export.h"
13 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
14 #include "base/debug/task_annotator.h" 15 #include "base/debug/task_annotator.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/location.h" 17 #include "base/location.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/message_loop/incoming_task_queue.h" 20 #include "base/message_loop/incoming_task_queue.h"
20 #include "base/message_loop/message_loop_task_runner.h" 21 #include "base/message_loop/message_loop_task_runner.h"
21 #include "base/message_loop/message_pump.h" 22 #include "base/message_loop/message_pump.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 pump_->SetTimerSlack(timer_slack); 285 pump_->SetTimerSlack(timer_slack);
285 } 286 }
286 287
287 // Returns true if this loop is |type|. This allows subclasses (especially 288 // Returns true if this loop is |type|. This allows subclasses (especially
288 // those in tests) to specialize how they are identified. 289 // those in tests) to specialize how they are identified.
289 virtual bool IsType(Type type) const; 290 virtual bool IsType(Type type) const;
290 291
291 // Returns the type passed to the constructor. 292 // Returns the type passed to the constructor.
292 Type type() const { return type_; } 293 Type type() const { return type_; }
293 294
294 // Optional call to connect the thread name with this loop. 295 // Returns the name of the thread this message loop is bound to.
295 void set_thread_name(const std::string& thread_name) { 296 std::string GetThreadName() const;
296 DCHECK(thread_name_.empty()) << "Should not rename this thread!";
297 thread_name_ = thread_name;
298 }
299 const std::string& thread_name() const { return thread_name_; }
300 297
301 // Gets the TaskRunner associated with this message loop. 298 // Gets the TaskRunner associated with this message loop.
302 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { 299 const scoped_refptr<SingleThreadTaskRunner>& task_runner() {
303 return task_runner_; 300 return task_runner_;
304 } 301 }
305 302
306 // Sets a new TaskRunner for this message loop. The message loop must already 303 // Sets a new TaskRunner for this message loop. The message loop must already
307 // have been bound to a thread prior to this call, and the task runner must 304 // have been bound to a thread prior to this call, and the task runner must
308 // belong to that thread. Note that changing the task runner will also affect 305 // belong to that thread. Note that changing the task runner will also affect
309 // the ThreadTaskRunnerHandle for the target thread. Must be called on the 306 // the ThreadTaskRunnerHandle for the target thread. Must be called on the
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 ObserverList<NestingObserver> nesting_observers_; 507 ObserverList<NestingObserver> nesting_observers_;
511 508
512 // A recursion block that prevents accidentally running additional tasks when 509 // A recursion block that prevents accidentally running additional tasks when
513 // insider a (accidentally induced?) nested message pump. 510 // insider a (accidentally induced?) nested message pump.
514 bool nestable_tasks_allowed_; 511 bool nestable_tasks_allowed_;
515 512
516 // pump_factory_.Run() is called to create a message pump for this loop 513 // pump_factory_.Run() is called to create a message pump for this loop
517 // if type_ is TYPE_CUSTOM and pump_ is null. 514 // if type_ is TYPE_CUSTOM and pump_ is null.
518 MessagePumpFactoryCallback pump_factory_; 515 MessagePumpFactoryCallback pump_factory_;
519 516
520 std::string thread_name_;
521 // A profiling histogram showing the counts of various messages and events. 517 // A profiling histogram showing the counts of various messages and events.
522 HistogramBase* message_histogram_; 518 HistogramBase* message_histogram_;
523 519
524 RunLoop* run_loop_; 520 RunLoop* run_loop_;
525 521
526 ObserverList<TaskObserver> task_observers_; 522 ObserverList<TaskObserver> task_observers_;
527 523
528 debug::TaskAnnotator task_annotator_; 524 debug::TaskAnnotator task_annotator_;
529 525
530 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; 526 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
531 527
532 // A task runner which we haven't bound to a thread yet. 528 // A task runner which we haven't bound to a thread yet.
533 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_; 529 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_;
534 530
535 // The task runner associated with this message loop. 531 // The task runner associated with this message loop.
536 scoped_refptr<SingleThreadTaskRunner> task_runner_; 532 scoped_refptr<SingleThreadTaskRunner> task_runner_;
537 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; 533 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
538 534
535 // Id of the thread this message loop is bound to.
536 subtle::Atomic32 thread_id_;
537
539 template <class T, class R> friend class base::subtle::DeleteHelperInternal; 538 template <class T, class R> friend class base::subtle::DeleteHelperInternal;
540 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; 539 template <class T, class R> friend class base::subtle::ReleaseHelperInternal;
541 540
542 void DeleteSoonInternal(const tracked_objects::Location& from_here, 541 void DeleteSoonInternal(const tracked_objects::Location& from_here,
543 void(*deleter)(const void*), 542 void(*deleter)(const void*),
544 const void* object); 543 const void* object);
545 void ReleaseSoonInternal(const tracked_objects::Location& from_here, 544 void ReleaseSoonInternal(const tracked_objects::Location& from_here,
546 void(*releaser)(const void*), 545 void(*releaser)(const void*),
547 const void* object); 546 const void* object);
548 547
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 680
682 // Do not add any member variables to MessageLoopForIO! This is important b/c 681 // Do not add any member variables to MessageLoopForIO! This is important b/c
683 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 682 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
684 // data that you need should be stored on the MessageLoop's pump_ instance. 683 // data that you need should be stored on the MessageLoop's pump_ instance.
685 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 684 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
686 "MessageLoopForIO should not have extra member variables"); 685 "MessageLoopForIO should not have extra member variables");
687 686
688 } // namespace base 687 } // namespace base
689 688
690 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 689 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | base/message_loop/message_loop.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698