OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 10 #include <string> |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // items. It protects the gathering under locks, so that it could be called via | 286 // items. It protects the gathering under locks, so that it could be called via |
287 // Posttask on any threads, or passed to all the target threads in parallel. | 287 // Posttask on any threads, or passed to all the target threads in parallel. |
288 | 288 |
289 class DataCollector { | 289 class DataCollector { |
290 public: | 290 public: |
291 typedef std::vector<Snapshot> Collection; | 291 typedef std::vector<Snapshot> Collection; |
292 | 292 |
293 // Construct with a list of how many threads should contribute. This helps us | 293 // Construct with a list of how many threads should contribute. This helps us |
294 // determine (in the async case) when we are done with all contributions. | 294 // determine (in the async case) when we are done with all contributions. |
295 DataCollector(); | 295 DataCollector(); |
| 296 ~DataCollector(); |
296 | 297 |
297 // Add all stats from the indicated thread into our arrays. This function is | 298 // Add all stats from the indicated thread into our arrays. This function is |
298 // mutex protected, and *could* be called from any threads (although current | 299 // mutex protected, and *could* be called from any threads (although current |
299 // implementation serialized calls to Append). | 300 // implementation serialized calls to Append). |
300 void Append(const ThreadData& thread_data); | 301 void Append(const ThreadData& thread_data); |
301 | 302 |
302 // After the accumulation phase, the following accessor is used to process the | 303 // After the accumulation phase, the following accessor is used to process the |
303 // data. | 304 // data. |
304 Collection* collection(); | 305 Collection* collection(); |
305 | 306 |
(...skipping 20 matching lines...) Expand all Loading... |
326 | 327 |
327 DISALLOW_COPY_AND_ASSIGN(DataCollector); | 328 DISALLOW_COPY_AND_ASSIGN(DataCollector); |
328 }; | 329 }; |
329 | 330 |
330 //------------------------------------------------------------------------------ | 331 //------------------------------------------------------------------------------ |
331 // Aggregation contains summaries (totals and subtotals) of groups of Snapshot | 332 // Aggregation contains summaries (totals and subtotals) of groups of Snapshot |
332 // instances to provide printing of these collections on a single line. | 333 // instances to provide printing of these collections on a single line. |
333 | 334 |
334 class Aggregation: public DeathData { | 335 class Aggregation: public DeathData { |
335 public: | 336 public: |
336 Aggregation() : birth_count_(0) {} | 337 Aggregation(); |
| 338 ~Aggregation(); |
337 | 339 |
338 void AddDeathSnapshot(const Snapshot& snapshot); | 340 void AddDeathSnapshot(const Snapshot& snapshot); |
339 void AddBirths(const Births& births); | 341 void AddBirths(const Births& births); |
340 void AddBirth(const BirthOnThread& birth); | 342 void AddBirth(const BirthOnThread& birth); |
341 void AddBirthPlace(const Location& location); | 343 void AddBirthPlace(const Location& location); |
342 void Write(std::string* output) const; | 344 void Write(std::string* output) const; |
343 void Clear(); | 345 void Clear(); |
344 | 346 |
345 private: | 347 private: |
346 int birth_count_; | 348 int birth_count_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 //------------------------------------------------------------------------------ | 464 //------------------------------------------------------------------------------ |
463 // For each thread, we have a ThreadData that stores all tracking info generated | 465 // For each thread, we have a ThreadData that stores all tracking info generated |
464 // on this thread. This prevents the need for locking as data accumulates. | 466 // on this thread. This prevents the need for locking as data accumulates. |
465 | 467 |
466 class ThreadData { | 468 class ThreadData { |
467 public: | 469 public: |
468 typedef std::map<Location, Births*> BirthMap; | 470 typedef std::map<Location, Births*> BirthMap; |
469 typedef std::map<const Births*, DeathData> DeathMap; | 471 typedef std::map<const Births*, DeathData> DeathMap; |
470 | 472 |
471 ThreadData(); | 473 ThreadData(); |
| 474 ~ThreadData(); |
472 | 475 |
473 // Using Thread Local Store, find the current instance for collecting data. | 476 // Using Thread Local Store, find the current instance for collecting data. |
474 // If an instance does not exist, construct one (and remember it for use on | 477 // If an instance does not exist, construct one (and remember it for use on |
475 // this thread. | 478 // this thread. |
476 // If shutdown has already started, and we don't yet have an instance, then | 479 // If shutdown has already started, and we don't yet have an instance, then |
477 // return null. | 480 // return null. |
478 static ThreadData* current(); | 481 static ThreadData* current(); |
479 | 482 |
480 // For a given about:objects URL, develop resulting HTML, and append to | 483 // For a given about:objects URL, develop resulting HTML, and append to |
481 // output. | 484 // output. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 }; | 662 }; |
660 static State state_; | 663 static State state_; |
661 | 664 |
662 DISALLOW_COPY_AND_ASSIGN(AutoTracking); | 665 DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
663 }; | 666 }; |
664 | 667 |
665 | 668 |
666 } // namespace tracked_objects | 669 } // namespace tracked_objects |
667 | 670 |
668 #endif // BASE_TRACKED_OBJECTS_H_ | 671 #endif // BASE_TRACKED_OBJECTS_H_ |
OLD | NEW |