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

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

Issue 1044413002: Record async "task backtraces" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More wording fixes. Created 3 years, 10 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 | « base/message_loop/incoming_task_queue.cc ('k') | 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 <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // A subclass can invoke this constructor to create a message_loop of a 339 // A subclass can invoke this constructor to create a message_loop of a
340 // specific type with a custom loop. The implementation does not call 340 // specific type with a custom loop. The implementation does not call
341 // BindToCurrentThread. If this constructor is invoked directly by a subclass, 341 // BindToCurrentThread. If this constructor is invoked directly by a subclass,
342 // then the subclass must subsequently bind the message loop. 342 // then the subclass must subsequently bind the message loop.
343 MessageLoop(Type type, MessagePumpFactoryCallback pump_factory); 343 MessageLoop(Type type, MessagePumpFactoryCallback pump_factory);
344 344
345 // Configure various members and bind this message loop to the current thread. 345 // Configure various members and bind this message loop to the current thread.
346 void BindToCurrentThread(); 346 void BindToCurrentThread();
347 347
348 private: 348 private:
349 friend class internal::IncomingTaskQueue;
349 friend class RunLoop; 350 friend class RunLoop;
350 friend class internal::IncomingTaskQueue;
351 friend class ScheduleWorkTest; 351 friend class ScheduleWorkTest;
352 friend class Thread; 352 friend class Thread;
353 friend struct PendingTask;
353 FRIEND_TEST_ALL_PREFIXES(MessageLoopTest, DeleteUnboundLoop); 354 FRIEND_TEST_ALL_PREFIXES(MessageLoopTest, DeleteUnboundLoop);
355 friend class PendingTaskTest;
354 356
355 // Creates a MessageLoop without binding to a thread. 357 // Creates a MessageLoop without binding to a thread.
356 // If |type| is TYPE_CUSTOM non-null |pump_factory| must be also given 358 // If |type| is TYPE_CUSTOM non-null |pump_factory| must be also given
357 // to create a message pump for this message loop. Otherwise a default 359 // to create a message pump for this message loop. Otherwise a default
358 // message pump for the |type| is created. 360 // message pump for the |type| is created.
359 // 361 //
360 // It is valid to call this to create a new message loop on one thread, 362 // It is valid to call this to create a new message loop on one thread,
361 // and then pass it to the thread where the message loop actually runs. 363 // and then pass it to the thread where the message loop actually runs.
362 // The message loop's BindToCurrentThread() method must be called on the 364 // The message loop's BindToCurrentThread() method must be called on the
363 // thread the message loop runs on, before calling Run(). 365 // thread the message loop runs on, before calling Run().
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // pump_factory_.Run() is called to create a message pump for this loop 445 // pump_factory_.Run() is called to create a message pump for this loop
444 // if type_ is TYPE_CUSTOM and pump_ is null. 446 // if type_ is TYPE_CUSTOM and pump_ is null.
445 MessagePumpFactoryCallback pump_factory_; 447 MessagePumpFactoryCallback pump_factory_;
446 448
447 RunLoop* run_loop_; 449 RunLoop* run_loop_;
448 450
449 ObserverList<TaskObserver> task_observers_; 451 ObserverList<TaskObserver> task_observers_;
450 452
451 debug::TaskAnnotator task_annotator_; 453 debug::TaskAnnotator task_annotator_;
452 454
455 // Used to allow creating a breadcrumb of program counters in PostTask.
456 // This variable is only initialized while a task is being executed and is
457 // meant only to store context for creating a backtrace breadcrumb. Do not
458 // attach other semantics to it without thinking through the use caes
459 // thoroughly.
460 const PendingTask* current_pending_task_;
461
453 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; 462 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
454 463
455 // A task runner which we haven't bound to a thread yet. 464 // A task runner which we haven't bound to a thread yet.
456 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_; 465 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_;
457 466
458 // The task runner associated with this message loop. 467 // The task runner associated with this message loop.
459 scoped_refptr<SingleThreadTaskRunner> task_runner_; 468 scoped_refptr<SingleThreadTaskRunner> task_runner_;
460 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; 469 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
461 470
462 // Id of the thread this message loop is bound to. Initialized once when the 471 // Id of the thread this message loop is bound to. Initialized once when the
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 618
610 // Do not add any member variables to MessageLoopForIO! This is important b/c 619 // Do not add any member variables to MessageLoopForIO! This is important b/c
611 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 620 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
612 // data that you need should be stored on the MessageLoop's pump_ instance. 621 // data that you need should be stored on the MessageLoop's pump_ instance.
613 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 622 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
614 "MessageLoopForIO should not have extra member variables"); 623 "MessageLoopForIO should not have extra member variables");
615 624
616 } // namespace base 625 } // namespace base
617 626
618 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 627 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/message_loop/incoming_task_queue.cc ('k') | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698