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

Side by Side Diff: base/message_loop.h

Issue 8391019: Fully enable about:tracking by default (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/location.h ('k') | 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>
(...skipping 26 matching lines...) Expand all
37 #include "base/message_pump_gtk.h" 37 #include "base/message_pump_gtk.h"
38 #endif 38 #endif
39 39
40 #endif 40 #endif
41 #endif 41 #endif
42 42
43 namespace base { 43 namespace base {
44 class Histogram; 44 class Histogram;
45 } 45 }
46 46
47 #if defined(TRACK_ALL_TASK_OBJECTS)
48 namespace tracked_objects { 47 namespace tracked_objects {
49 class Births; 48 class Births;
50 } 49 }
51 #endif // defined(TRACK_ALL_TASK_OBJECTS)
52 50
53 // A MessageLoop is used to process events for a particular thread. There is 51 // A MessageLoop is used to process events for a particular thread. There is
54 // at most one MessageLoop instance per thread. 52 // at most one MessageLoop instance per thread.
55 // 53 //
56 // Events include at a minimum Task instances submitted to PostTask or those 54 // Events include at a minimum Task instances submitted to PostTask or those
57 // managed by TimerManager. Depending on the type of message pump used by the 55 // managed by TimerManager. Depending on the type of message pump used by the
58 // MessageLoop other events such as UI messages may be processed. On Windows 56 // MessageLoop other events such as UI messages may be processed. On Windows
59 // APC calls (as time permits) and signals sent to a registered set of HANDLEs 57 // APC calls (as time permits) and signals sent to a registered set of HANDLEs
60 // may also be processed. 58 // may also be processed.
61 // 59 //
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 #if defined(OS_WIN) 368 #if defined(OS_WIN)
371 void set_os_modal_loop(bool os_modal_loop) { 369 void set_os_modal_loop(bool os_modal_loop) {
372 os_modal_loop_ = os_modal_loop; 370 os_modal_loop_ = os_modal_loop;
373 } 371 }
374 372
375 bool os_modal_loop() const { 373 bool os_modal_loop() const {
376 return os_modal_loop_; 374 return os_modal_loop_;
377 } 375 }
378 #endif // OS_WIN 376 #endif // OS_WIN
379 377
378 // This structure is copied around by value.
379 struct TrackingInfo {
380 TrackingInfo(const tracked_objects::Location& posted_from,
381 base::TimeTicks delayed_run_time);
382 ~TrackingInfo();
383
384 // Counter for location where the Closure was posted from.
385 tracked_objects::Births* birth_tally;
386
387 // Time this PendingTask was posted.
388 base::TimeTicks time_posted;
389
390 // The time when the task should be run.
391 base::TimeTicks delayed_run_time;
392 };
393
380 //---------------------------------------------------------------------------- 394 //----------------------------------------------------------------------------
381 protected: 395 protected:
382 struct RunState { 396 struct RunState {
383 // Used to count how many Run() invocations are on the stack. 397 // Used to count how many Run() invocations are on the stack.
384 int run_depth; 398 int run_depth;
385 399
386 // Used to record that Quit() was called, or that we should quit the pump 400 // Used to record that Quit() was called, or that we should quit the pump
387 // once it becomes idle. 401 // once it becomes idle.
388 bool quit_received; 402 bool quit_received;
389 403
(...skipping 13 matching lines...) Expand all
403 ~AutoRunState(); 417 ~AutoRunState();
404 private: 418 private:
405 MessageLoop* loop_; 419 MessageLoop* loop_;
406 RunState* previous_state_; 420 RunState* previous_state_;
407 }; 421 };
408 #if defined(OS_ANDROID) 422 #if defined(OS_ANDROID)
409 protected: 423 protected:
410 #endif 424 #endif
411 425
412 // This structure is copied around by value. 426 // This structure is copied around by value.
413 struct PendingTask { 427 struct PendingTask : public TrackingInfo {
414 PendingTask(const base::Closure& task, 428 PendingTask(const base::Closure& task,
415 const tracked_objects::Location& posted_from, 429 const tracked_objects::Location& posted_from,
416 base::TimeTicks delayed_run_time, 430 base::TimeTicks delayed_run_time,
417 bool nestable); 431 bool nestable);
418 ~PendingTask(); 432 ~PendingTask();
419 433
420 // Used to support sorting. 434 // Used to support sorting.
421 bool operator<(const PendingTask& other) const; 435 bool operator<(const PendingTask& other) const;
422 436
423 // The task to run. 437 // The task to run.
424 base::Closure task; 438 base::Closure task;
425 439
426 #if defined(TRACK_ALL_TASK_OBJECTS)
427 // Counter for location where the Closure was posted from.
428 tracked_objects::Births* post_births;
429 #endif // defined(TRACK_ALL_TASK_OBJECTS)
430
431 // Time this PendingTask was posted.
432 base::TimeTicks time_posted;
433
434 // The time when the task should be run.
435 base::TimeTicks delayed_run_time;
436
437 // The site this PendingTask was posted from. 440 // The site this PendingTask was posted from.
438 tracked_objects::Location posted_from; 441 tracked_objects::Location posted_from;
439 442
440 // Secondary sort key for run time. 443 // Secondary sort key for run time.
441 int sequence_num; 444 int sequence_num;
442 445
443 // OK to dispatch from a nested loop. 446 // OK to dispatch from a nested loop.
444 bool nestable; 447 bool nestable;
445 }; 448 };
446 449
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 #endif // defined(OS_POSIX) 714 #endif // defined(OS_POSIX)
712 }; 715 };
713 716
714 // Do not add any member variables to MessageLoopForIO! This is important b/c 717 // Do not add any member variables to MessageLoopForIO! This is important b/c
715 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 718 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
716 // data that you need should be stored on the MessageLoop's pump_ instance. 719 // data that you need should be stored on the MessageLoop's pump_ instance.
717 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 720 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
718 MessageLoopForIO_should_not_have_extra_member_variables); 721 MessageLoopForIO_should_not_have_extra_member_variables);
719 722
720 #endif // BASE_MESSAGE_LOOP_H_ 723 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/location.h ('k') | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698