OLD | NEW |
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 <string> | 10 #include <string> |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 // Provide simple way to to start global tracking, and to tear down tracking | 623 // Provide simple way to to start global tracking, and to tear down tracking |
624 // when done. Note that construction and destruction of this object must be | 624 // when done. Note that construction and destruction of this object must be |
625 // done when running in threaded mode (before spawning a lot of threads | 625 // done when running in threaded mode (before spawning a lot of threads |
626 // for construction, and after shutting down all the threads for destruction). | 626 // for construction, and after shutting down all the threads for destruction). |
627 | 627 |
628 // To prevent grabbing thread local store resources time and again if someone | 628 // To prevent grabbing thread local store resources time and again if someone |
629 // chooses to try to re-run the browser many times, we maintain global state and | 629 // chooses to try to re-run the browser many times, we maintain global state and |
630 // only allow the tracking system to be started up at most once, and shutdown | 630 // only allow the tracking system to be started up at most once, and shutdown |
631 // at most once. See bug 31344 for an example. | 631 // at most once. See bug 31344 for an example. |
632 | 632 |
633 class AutoTracking { | 633 class BASE_API AutoTracking { |
634 public: | 634 public: |
635 AutoTracking() { | 635 AutoTracking() { |
636 if (state_ != kNeverBeenRun) | 636 if (state_ != kNeverBeenRun) |
637 return; | 637 return; |
638 ThreadData::StartTracking(true); | 638 ThreadData::StartTracking(true); |
639 state_ = kRunning; | 639 state_ = kRunning; |
640 } | 640 } |
641 | 641 |
642 ~AutoTracking() { | 642 ~AutoTracking() { |
643 #ifndef NDEBUG | 643 #ifndef NDEBUG |
(...skipping 14 matching lines...) Expand all Loading... |
658 }; | 658 }; |
659 static State state_; | 659 static State state_; |
660 | 660 |
661 DISALLOW_COPY_AND_ASSIGN(AutoTracking); | 661 DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
662 }; | 662 }; |
663 | 663 |
664 | 664 |
665 } // namespace tracked_objects | 665 } // namespace tracked_objects |
666 | 666 |
667 #endif // BASE_TRACKED_OBJECTS_H_ | 667 #endif // BASE_TRACKED_OBJECTS_H_ |
OLD | NEW |