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

Side by Side Diff: base/tracked_objects.h

Issue 8894022: Detect child tasks born during a profiled tasks (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
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_TRACKED_OBJECTS_H_ 5 #ifndef BASE_TRACKED_OBJECTS_H_
6 #define BASE_TRACKED_OBJECTS_H_ 6 #define BASE_TRACKED_OBJECTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set>
10 #include <stack> 11 #include <stack>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/base_export.h" 15 #include "base/base_export.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
17 #include "base/location.h" 18 #include "base/location.h"
18 #include "base/profiler/tracked_time.h" 19 #include "base/profiler/tracked_time.h"
19 #include "base/time.h" 20 #include "base/time.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // For a specific thread, and a specific birth place, the collection of all 192 // For a specific thread, and a specific birth place, the collection of all
192 // death info (with tallies for each death thread, to prevent access conflicts). 193 // death info (with tallies for each death thread, to prevent access conflicts).
193 class ThreadData; 194 class ThreadData;
194 class BASE_EXPORT BirthOnThread { 195 class BASE_EXPORT BirthOnThread {
195 public: 196 public:
196 BirthOnThread(const Location& location, const ThreadData& current); 197 BirthOnThread(const Location& location, const ThreadData& current);
197 198
198 const Location location() const; 199 const Location location() const;
199 const ThreadData* birth_thread() const; 200 const ThreadData* birth_thread() const;
200 201
202 // Insert our state (location, and thread name) into the dictionary.
203 // Use the supplied |prefix| in frost of "thread_name" and "location"
204 // respectively when defining keys.
205 void ToValue(const std::string& prefix,
206 base::DictionaryValue* dictionary) const;
207
201 private: 208 private:
202 // File/lineno of birth. This defines the essence of the task, as the context 209 // File/lineno of birth. This defines the essence of the task, as the context
203 // of the birth (construction) often tell what the item is for. This field 210 // of the birth (construction) often tell what the item is for. This field
204 // is const, and hence safe to access from any thread. 211 // is const, and hence safe to access from any thread.
205 const Location location_; 212 const Location location_;
206 213
207 // The thread that records births into this object. Only this thread is 214 // The thread that records births into this object. Only this thread is
208 // allowed to update birth_count_ (which changes over time). 215 // allowed to update birth_count_ (which changes over time).
209 const ThreadData* const birth_thread_; 216 const ThreadData* const birth_thread_;
210 217
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 //------------------------------------------------------------------------------ 305 //------------------------------------------------------------------------------
299 // A temporary collection of data that can be sorted and summarized. It is 306 // A temporary collection of data that can be sorted and summarized. It is
300 // gathered (carefully) from many threads. Instances are held in arrays and 307 // gathered (carefully) from many threads. Instances are held in arrays and
301 // processed, filtered, and rendered. 308 // processed, filtered, and rendered.
302 // The source of this data was collected on many threads, and is asynchronously 309 // The source of this data was collected on many threads, and is asynchronously
303 // changing. The data in this instance is not asynchronously changing. 310 // changing. The data in this instance is not asynchronously changing.
304 311
305 class BASE_EXPORT Snapshot { 312 class BASE_EXPORT Snapshot {
306 public: 313 public:
307 // When snapshotting a full life cycle set (birth-to-death), use this: 314 // When snapshotting a full life cycle set (birth-to-death), use this:
308 Snapshot(const BirthOnThread& birth_on_thread, const ThreadData& death_thread, 315 Snapshot(const BirthOnThread& birth_on_thread,
316 const ThreadData& death_thread,
309 const DeathData& death_data); 317 const DeathData& death_data);
310 318
311 // When snapshotting a birth, with no death yet, use this: 319 // When snapshotting a birth, with no death yet, use this:
312 Snapshot(const BirthOnThread& birth_on_thread, int count); 320 Snapshot(const BirthOnThread& birth_on_thread, int count);
313 321
314 // Accessor, that provides default value when there is no death thread. 322 // Accessor, that provides default value when there is no death thread.
315 const std::string DeathThreadName() const; 323 const std::string DeathThreadName() const;
316 324
317 // Construct a DictionaryValue instance containing all our data recursively. 325 // Construct a DictionaryValue instance containing all our data recursively.
318 // The caller assumes ownership of the memory in the returned instance. 326 // The caller assumes ownership of the memory in the returned instance.
(...skipping 10 matching lines...) Expand all
329 // on this thread. This prevents the need for locking as data accumulates. 337 // on this thread. This prevents the need for locking as data accumulates.
330 // We use ThreadLocalStorage to quickly identfy the current ThreadData context. 338 // We use ThreadLocalStorage to quickly identfy the current ThreadData context.
331 // We also have a linked list of ThreadData instances, and that list is used to 339 // We also have a linked list of ThreadData instances, and that list is used to
332 // harvest data from all existing instances. 340 // harvest data from all existing instances.
333 341
334 class BASE_EXPORT ThreadData { 342 class BASE_EXPORT ThreadData {
335 public: 343 public:
336 // Current allowable states of the tracking system. The states can vary 344 // Current allowable states of the tracking system. The states can vary
337 // between ACTIVE and DEACTIVATED, but can never go back to UNINITIALIZED. 345 // between ACTIVE and DEACTIVATED, but can never go back to UNINITIALIZED.
338 enum Status { 346 enum Status {
339 UNINITIALIZED, 347 UNINITIALIZED, // PRistine, link-time state before running.
340 ACTIVE, 348 DORMANT_DURING_TESTS, // Only used during testing.
341 DEACTIVATED, 349 DEACTIVATED, // No longer recordin profling.
350 PROFILING_ACTIVE, // Recording profiles, but not parent-child links.
351 FULLY_ACTIVE, // Fully active, recording parent-child links.
342 }; 352 };
343 353
344 typedef std::map<Location, Births*> BirthMap; 354 typedef std::map<Location, Births*> BirthMap;
345 typedef std::map<const Births*, DeathData> DeathMap; 355 typedef std::map<const Births*, DeathData> DeathMap;
356 typedef std::pair<const Births*, const Births*> ParentChildPair;
357 typedef std::set<ParentChildPair> ParentChildSet;
358 typedef std::stack<const Births*> ParentStack;
346 359
347 // Initialize the current thread context with a new instance of ThreadData. 360 // Initialize the current thread context with a new instance of ThreadData.
348 // This is used by all threads that have names, and should be explicitly 361 // This is used by all threads that have names, and should be explicitly
349 // set *before* any births on the threads have taken place. It is generally 362 // set *before* any births on the threads have taken place. It is generally
350 // only used by the message loop, which has a well defined thread name. 363 // only used by the message loop, which has a well defined thread name.
351 static void InitializeThreadContext(const std::string& suggested_name); 364 static void InitializeThreadContext(const std::string& suggested_name);
352 365
353 // Using Thread Local Store, find the current instance for collecting data. 366 // Using Thread Local Store, find the current instance for collecting data.
354 // If an instance does not exist, construct one (and remember it for use on 367 // If an instance does not exist, construct one (and remember it for use on
355 // this thread. 368 // this thread.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Record the end of execution in region, generally corresponding to a scope 409 // Record the end of execution in region, generally corresponding to a scope
397 // being exited. 410 // being exited.
398 static void TallyRunInAScopedRegionIfTracking( 411 static void TallyRunInAScopedRegionIfTracking(
399 const Births* birth, 412 const Births* birth,
400 const TrackedTime& start_of_run, 413 const TrackedTime& start_of_run,
401 const TrackedTime& end_of_run); 414 const TrackedTime& end_of_run);
402 415
403 const std::string thread_name() const; 416 const std::string thread_name() const;
404 417
405 // Snapshot (under a lock) copies of the maps in each ThreadData instance. For 418 // Snapshot (under a lock) copies of the maps in each ThreadData instance. For
406 // each set of maps (BirthMap and DeathMap) call the Append() method of the 419 // each set of maps (BirthMap, DeathMap, and ParentChildSet) call the Append()
407 // |target| DataCollector. If |reset_max| is true, then the max values in 420 // method of the |target| DataCollector. If |reset_max| is true, then the max
408 // each DeathData instance should be reset during the scan. 421 // values in each DeathData instance should be reset during the scan.
409 static void SendAllMaps(bool reset_max, class DataCollector* target); 422 static void SendAllMaps(bool reset_max, class DataCollector* target);
410 423
411 // Hack: asynchronously clear all birth counts and death tallies data values 424 // Hack: asynchronously clear all birth counts and death tallies data values
412 // in all ThreadData instances. The numerical (zeroing) part is done without 425 // in all ThreadData instances. The numerical (zeroing) part is done without
413 // use of a locks or atomics exchanges, and may (for int64 values) produce 426 // use of a locks or atomics exchanges, and may (for int64 values) produce
414 // bogus counts VERY rarely. 427 // bogus counts VERY rarely.
415 static void ResetAllThreadData(); 428 static void ResetAllThreadData();
416 429
417 // Initializes all statics if needed (this initialization call should be made 430 // Initializes all statics if needed (this initialization call should be made
418 // while we are single threaded). Returns false if unable to initialize. 431 // while we are single threaded). Returns false if unable to initialize.
419 static bool Initialize(); 432 static bool Initialize();
420 433
421 // Sets internal status_ to either become ACTIVE, or DEACTIVATED, 434 // Sets internal status_.
422 // based on argument being true or false respectively. 435 // If |status| is false, then status_ is set to DEACTIVATED.
436 // If |status| is true, then status_ is set to, PROFILING_ACTIVE, or
437 // FULLY_ACTIVE.
423 // If tracking is not compiled in, this function will return false. 438 // If tracking is not compiled in, this function will return false.
439 // If parent-child tracking is not compiled in, then an attempt to set the
440 // status to FULLY_ACTIVE will only result in a status of PROFILING_ACTIVE
441 // (i.e., it can't be set to a higher level than what is compiled into the
442 // binary, and parent-child tracking at the FULLY_ACTIVE level might not be
443 // compiled in).
424 static bool InitializeAndSetTrackingStatus(bool status); 444 static bool InitializeAndSetTrackingStatus(bool status);
445
446 // Indicate if any sort of profiling is being done (i.e., we are more than
447 // DEACTIVATED).
425 static bool tracking_status(); 448 static bool tracking_status();
426 449
450 // For testing only, indicate if the status of parent-child tracking is turned
451 // on. This is currently a compiled option, atop tracking_status().
452 static bool tracking_parent_child_status();
453
427 // Special versions of Now() for getting times at start and end of a tracked 454 // Special versions of Now() for getting times at start and end of a tracked
428 // run. They are super fast when tracking is disabled, and have some internal 455 // run. They are super fast when tracking is disabled, and have some internal
429 // side effects when we are tracking, so that we can deduce the amount of time 456 // side effects when we are tracking, so that we can deduce the amount of time
430 // accumulated outside of execution of tracked runs. 457 // accumulated outside of execution of tracked runs.
431 static TrackedTime NowForStartOfRun(); 458 // The task that will be tracked is passed in as |parent| so that parent-child
459 // relationships can be (optionally) calculated.
460 static TrackedTime NowForStartOfRun(const Births* parent);
432 static TrackedTime NowForEndOfRun(); 461 static TrackedTime NowForEndOfRun();
433 462
434 // Provide a time function that does nothing (runs fast) when we don't have 463 // Provide a time function that does nothing (runs fast) when we don't have
435 // the profiler enabled. It will generally be optimized away when it is 464 // the profiler enabled. It will generally be optimized away when it is
436 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of 465 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of
437 // the code). 466 // the code).
438 static TrackedTime Now(); 467 static TrackedTime Now();
439 468
440 // This function can be called at process termination to validate that thread 469 // This function can be called at process termination to validate that thread
441 // cleanup routines have been called for at least some number of named 470 // cleanup routines have been called for at least some number of named
442 // threads. 471 // threads.
443 static void EnsureCleanupWasCalled(int major_threads_shutdown_count); 472 static void EnsureCleanupWasCalled(int major_threads_shutdown_count);
444 473
445 private: 474 private:
446 // Allow only tests to call ShutdownSingleThreadedCleanup. We NEVER call it 475 // Allow only tests to call ShutdownSingleThreadedCleanup. We NEVER call it
447 // in production code. 476 // in production code.
448 // TODO(jar): Make this a friend in DEBUG only, so that the optimizer has a 477 // TODO(jar): Make this a friend in DEBUG only, so that the optimizer has a
449 // better change of optimizing (inlining? etc.) private methods (knowing that 478 // better change of optimizing (inlining? etc.) private methods (knowing that
450 // there will be no need for an external entry point). 479 // there will be no need for an external entry point).
451 friend class TrackedObjectsTest; 480 friend class TrackedObjectsTest;
452 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, MinimalStartupShutdown); 481 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, MinimalStartupShutdown);
453 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, TinyStartupShutdown); 482 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, TinyStartupShutdown);
483 FRIEND_TEST_ALL_PREFIXES(TrackedObjectsTest, ParentChildTest);
454 484
455 // Worker thread construction creates a name since there is none. 485 // Worker thread construction creates a name since there is none.
456 explicit ThreadData(int thread_number); 486 explicit ThreadData(int thread_number);
457 487
458 // Message loop based construction should provide a name. 488 // Message loop based construction should provide a name.
459 explicit ThreadData(const std::string& suggested_name); 489 explicit ThreadData(const std::string& suggested_name);
460 490
461 ~ThreadData(); 491 ~ThreadData();
462 492
463 // Push this instance to the head of all_thread_data_list_head_, linking it to 493 // Push this instance to the head of all_thread_data_list_head_, linking it to
(...skipping 16 matching lines...) Expand all
480 DurationInt queue_duration, 510 DurationInt queue_duration,
481 DurationInt duration); 511 DurationInt duration);
482 512
483 // Using our lock, make a copy of the specified maps. This call may be made 513 // Using our lock, make a copy of the specified maps. This call may be made
484 // on non-local threads, which necessitate the use of the lock to prevent 514 // on non-local threads, which necessitate the use of the lock to prevent
485 // the map(s) from being reallocaed while they are copied. If |reset_max| is 515 // the map(s) from being reallocaed while they are copied. If |reset_max| is
486 // true, then, just after we copy the DeathMap, we will set the max values to 516 // true, then, just after we copy the DeathMap, we will set the max values to
487 // zero in the active DeathMap (not the snapshot). 517 // zero in the active DeathMap (not the snapshot).
488 void SnapshotMaps(bool reset_max, 518 void SnapshotMaps(bool reset_max,
489 BirthMap* birth_map, 519 BirthMap* birth_map,
490 DeathMap* death_map); 520 DeathMap* death_map,
521 ParentChildSet* parent_child_set);
491 522
492 // Using our lock to protect the iteration, Clear all birth and death data. 523 // Using our lock to protect the iteration, Clear all birth and death data.
493 void Reset(); 524 void Reset();
494 525
495 // This method is called by the TLS system when a thread terminates. 526 // This method is called by the TLS system when a thread terminates.
496 // The argument may be NULL if this thread has never tracked a birth or death. 527 // The argument may be NULL if this thread has never tracked a birth or death.
497 static void OnThreadTermination(void* thread_data); 528 static void OnThreadTermination(void* thread_data);
498 529
499 // This method should be called when a worker thread terminates, so that we 530 // This method should be called when a worker thread terminates, so that we
500 // can save all the thread data into a cache of reusable ThreadData instances. 531 // can save all the thread data into a cache of reusable ThreadData instances.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // value is only accessed while the list_lock_ is held. 570 // value is only accessed while the list_lock_ is held.
540 static int incarnation_counter_; 571 static int incarnation_counter_;
541 572
542 // Protection for access to all_thread_data_list_head_, and to 573 // Protection for access to all_thread_data_list_head_, and to
543 // unregistered_thread_data_pool_. This lock is leaked at shutdown. 574 // unregistered_thread_data_pool_. This lock is leaked at shutdown.
544 // The lock is very infrequently used, so we can afford to just make a lazy 575 // The lock is very infrequently used, so we can afford to just make a lazy
545 // instance and be safe. 576 // instance and be safe.
546 static base::LazyInstance<base::Lock, 577 static base::LazyInstance<base::Lock,
547 base::LeakyLazyInstanceTraits<base::Lock> > list_lock_; 578 base::LeakyLazyInstanceTraits<base::Lock> > list_lock_;
548 579
549 // Record of what the incarnation_counter_ was when this instance was created.
550 // If the incarnation_counter_ has changed, then we avoid pushing into the
551 // pool (this is only critical in tests which go through multiple
552 // incarations).
553 int incarnation_count_for_pool_;
554
555 // We set status_ to SHUTDOWN when we shut down the tracking service. 580 // We set status_ to SHUTDOWN when we shut down the tracking service.
556 static Status status_; 581 static Status status_;
557 582
558 // Link to next instance (null terminated list). Used to globally track all 583 // Link to next instance (null terminated list). Used to globally track all
559 // registered instances (corresponds to all registered threads where we keep 584 // registered instances (corresponds to all registered threads where we keep
560 // data). 585 // data).
561 ThreadData* next_; 586 ThreadData* next_;
562 587
563 // Pointer to another ThreadData instance for a Worker-Thread that has been 588 // Pointer to another ThreadData instance for a Worker-Thread that has been
564 // retired (its thread was terminated). This value is non-NULL only for a 589 // retired (its thread was terminated). This value is non-NULL only for a
(...skipping 15 matching lines...) Expand all
580 // When a snapshot is needed, this structure can be locked in place for the 605 // When a snapshot is needed, this structure can be locked in place for the
581 // duration of the snapshotting activity. 606 // duration of the snapshotting activity.
582 BirthMap birth_map_; 607 BirthMap birth_map_;
583 608
584 // Similar to birth_map_, this records informations about death of tracked 609 // Similar to birth_map_, this records informations about death of tracked
585 // instances (i.e., when a tracked instance was destroyed on this thread). 610 // instances (i.e., when a tracked instance was destroyed on this thread).
586 // It is locked before changing, and hence other threads may access it by 611 // It is locked before changing, and hence other threads may access it by
587 // locking before reading it. 612 // locking before reading it.
588 DeathMap death_map_; 613 DeathMap death_map_;
589 614
615 // A set of parents that created children tasks on this thread. Each pair
616 // correnponds to potentially non local Births (location and thread), and a
617 // local Births (that took place on this thread).
618 ParentChildSet parent_child_set_;
619
590 // Lock to protect *some* access to BirthMap and DeathMap. The maps are 620 // Lock to protect *some* access to BirthMap and DeathMap. The maps are
591 // regularly read and written on this thread, but may only be read from other 621 // regularly read and written on this thread, but may only be read from other
592 // threads. To support this, we acquire this lock if we are writing from this 622 // threads. To support this, we acquire this lock if we are writing from this
593 // thread, or reading from another thread. For reading from this thread we 623 // thread, or reading from another thread. For reading from this thread we
594 // don't need a lock, as there is no potential for a conflict since the 624 // don't need a lock, as there is no potential for a conflict since the
595 // writing is only done from this thread. 625 // writing is only done from this thread.
596 mutable base::Lock map_lock_; 626 mutable base::Lock map_lock_;
597 627
628 // The stack of parents that are currently being profiled. This includes only
629 // tasks that have started a timer recently via NowForStartOfRun(), but not
630 // yet concluded with a NowForEndOfRun(). Usually this stack is one deep, but
631 // if a scoped region is profiled, or <sigh> a task runs a nested-message
632 // loop, then the stack can grow larger. Note that we don't try to deduct
633 // time in nested porfiles, as our current timer is based on wall-clock time,
634 // and not CPU time (and we're hopeful that nested timing won't be a
635 // significant additional cost).
636 ParentStack parent_stack_;
637
598 // A random number that we used to select decide which sample to keep as a 638 // A random number that we used to select decide which sample to keep as a
599 // representative sample in each DeathData instance. We can't start off with 639 // representative sample in each DeathData instance. We can't start off with
600 // much randomness (because we can't call RandInt() on all our threads), so 640 // much randomness (because we can't call RandInt() on all our threads), so
601 // we stir in more and more as we go. 641 // we stir in more and more as we go.
602 int32 random_number_; 642 int32 random_number_;
603 643
644 // Record of what the incarnation_counter_ was when this instance was created.
645 // If the incarnation_counter_ has changed, then we avoid pushing into the
646 // pool (this is only critical in tests which go through multiple
647 // incarations).
648 int incarnation_count_for_pool_;
649
604 DISALLOW_COPY_AND_ASSIGN(ThreadData); 650 DISALLOW_COPY_AND_ASSIGN(ThreadData);
605 }; 651 };
606 652
607 //------------------------------------------------------------------------------ 653 //------------------------------------------------------------------------------
608 // DataCollector is a container class for Snapshot and BirthOnThread count 654 // DataCollector is a container class for Snapshot and BirthOnThread count
609 // items. 655 // items.
610 656
611 class BASE_EXPORT DataCollector { 657 class BASE_EXPORT DataCollector {
612 public: 658 public:
613 typedef std::vector<Snapshot> Collection; 659 typedef std::vector<Snapshot> Collection;
614 660
615 // Construct with a list of how many threads should contribute. This helps us 661 // Construct with a list of how many threads should contribute. This helps us
616 // determine (in the async case) when we are done with all contributions. 662 // determine (in the async case) when we are done with all contributions.
617 DataCollector(); 663 DataCollector();
618 ~DataCollector(); 664 ~DataCollector();
619 665
620 // Adds all stats from the indicated thread into our arrays. Accepts copies 666 // Adds all stats from the indicated thread into our arrays. Accepts copies
621 // of the birth_map and death_map, so that the data will not change during the 667 // of the birth_map and death_map, so that the data will not change during the
622 // iterations and processing. 668 // iterations and processing.
623 void Append(const ThreadData &thread_data, 669 void Append(const ThreadData &thread_data,
624 const ThreadData::BirthMap &birth_map, 670 const ThreadData::BirthMap& birth_map,
625 const ThreadData::DeathMap &death_map); 671 const ThreadData::DeathMap& death_map,
672 const ThreadData::ParentChildSet& parent_child_set);
626 673
627 // After the accumulation phase, the following accessor is used to process the 674 // After the accumulation phase, the following accessor is used to process the
628 // data (i.e., sort it, filter it, etc.). 675 // data (i.e., sort it, filter it, etc.).
629 Collection* collection(); 676 Collection* collection();
630 677
631 // Adds entries for all the remaining living objects (objects that have 678 // Adds entries for all the remaining living objects (objects that have
632 // tallied a birth, but have not yet tallied a matching death, and hence must 679 // tallied a birth, but have not yet tallied a matching death, and hence must
633 // be either running, queued up, or being held in limbo for future posting). 680 // be either running, queued up, or being held in limbo for future posting).
634 // This should be called after all known ThreadData instances have been 681 // This should be called after all known ThreadData instances have been
635 // processed using Append(). 682 // processed using Append().
636 void AddListOfLivingObjects(); 683 void AddListOfLivingObjects();
637 684
638 // Generates a ListValue representation of the vector of snapshots. The caller 685 // Generates a ListValue representation of the vector of snapshots. The caller
639 // assumes ownership of the memory in the returned instance. 686 // assumes ownership of the memory in the returned instance.
640 base::ListValue* ToValue() const; 687 void ToValue(base::DictionaryValue* dictionary) const;
641 688
642 private: 689 private:
643 typedef std::map<const BirthOnThread*, int> BirthCount; 690 typedef std::map<const BirthOnThread*, int> BirthCount;
644 691
645 // The array that we collect data into. 692 // The array that we collect data into.
646 Collection collection_; 693 Collection collection_;
647 694
648 // The total number of births recorded at each location for which we have not 695 // The total number of births recorded at each location for which we have not
649 // seen a death count. This map changes as we do Append() calls, and is later 696 // seen a death count. This map changes as we do Append() calls, and is later
650 // used by AddListOfLivingObjects() to gather up unaccounted for births. 697 // used by AddListOfLivingObjects() to gather up unaccounted for births.
651 BirthCount global_birth_count_; 698 BirthCount global_birth_count_;
652 699
700 // The complete list of parent-child relatioships among tasks.
701 ThreadData::ParentChildSet parent_child_set_;
702
653 DISALLOW_COPY_AND_ASSIGN(DataCollector); 703 DISALLOW_COPY_AND_ASSIGN(DataCollector);
654 }; 704 };
655 705
656 //------------------------------------------------------------------------------ 706 //------------------------------------------------------------------------------
657 // Provide simple way to to start global tracking, and to tear down tracking 707 // Provide simple way to to start global tracking, and to tear down tracking
658 // when done. The design has evolved to *not* do any teardown (and just leak 708 // when done. The design has evolved to *not* do any teardown (and just leak
659 // all allocated data structures). As a result, we don't have any code in this 709 // all allocated data structures). As a result, we don't have any code in this
660 // destructor, and perhaps this whole class should go away. 710 // destructor, and perhaps this whole class should go away.
661 711
662 class BASE_EXPORT AutoTracking { 712 class BASE_EXPORT AutoTracking {
(...skipping 10 matching lines...) Expand all
673 } 723 }
674 724
675 private: 725 private:
676 726
677 DISALLOW_COPY_AND_ASSIGN(AutoTracking); 727 DISALLOW_COPY_AND_ASSIGN(AutoTracking);
678 }; 728 };
679 729
680 } // namespace tracked_objects 730 } // namespace tracked_objects
681 731
682 #endif // BASE_TRACKED_OBJECTS_H_ 732 #endif // BASE_TRACKED_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698