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

Side by Side Diff: base/tracked.cc

Issue 7375006: Startup race fixes to tracked objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ajwong comments Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/tracked.h ('k') | no next file » | 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 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(COMPILER_MSVC) 7 #if defined(COMPILER_MSVC)
8 // MSDN says to #include <intrin.h>, but that breaks the VS2005 build. 8 // MSDN says to #include <intrin.h>, but that breaks the VS2005 build.
9 extern "C" { 9 extern "C" {
10 void* _ReturnAddress(); 10 void* _ReturnAddress();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return _ReturnAddress(); 79 return _ReturnAddress();
80 #elif defined(COMPILER_GCC) 80 #elif defined(COMPILER_GCC)
81 return __builtin_extract_return_addr(__builtin_return_address(0)); 81 return __builtin_extract_return_addr(__builtin_return_address(0));
82 #endif // COMPILER_GCC 82 #endif // COMPILER_GCC
83 83
84 return NULL; 84 return NULL;
85 } 85 }
86 86
87 //------------------------------------------------------------------------------ 87 //------------------------------------------------------------------------------
88 88
89 #ifndef TRACK_ALL_TASK_OBJECTS 89 #if !defined(TRACK_ALL_TASK_OBJECTS)
90 90
91 Tracked::Tracked() : birth_program_counter_(NULL) {} 91 Tracked::Tracked() : birth_program_counter_(NULL) {}
92 Tracked::~Tracked() {} 92 Tracked::~Tracked() {}
93 93
94 void Tracked::SetBirthPlace(const Location& from_here) { 94 void Tracked::SetBirthPlace(const Location& from_here) {
95 birth_program_counter_ = from_here.program_counter(); 95 birth_program_counter_ = from_here.program_counter();
96 } 96 }
97 97
98 const Location Tracked::GetBirthPlace() const { 98 const Location Tracked::GetBirthPlace() const {
99 static Location kNone("NoFunctionName", "NeedToSetBirthPlace", -1, NULL); 99 static Location kNone("NoFunctionName", "NeedToSetBirthPlace", -1, NULL);
100 return kNone; 100 return kNone;
101 } 101 }
102 bool Tracked::MissingBirthplace() const { return false; } 102 bool Tracked::MissingBirthPlace() const { return false; }
103 void Tracked::ResetBirthTime() {} 103 void Tracked::ResetBirthTime() {}
104 104
105 #else 105 #else
106 106
107 Tracked::Tracked() 107 Tracked::Tracked()
108 : tracked_births_(NULL), 108 : tracked_births_(NULL),
109 tracked_birth_time_(TimeTicks::Now()) { 109 tracked_birth_time_(TimeTicks::Now()) {
110 } 110 }
111 111
112 Tracked::~Tracked() { 112 Tracked::~Tracked() {
(...skipping 10 matching lines...) Expand all
123 tracked_births_->ForgetBirth(); 123 tracked_births_->ForgetBirth();
124 ThreadData* current_thread_data = ThreadData::current(); 124 ThreadData* current_thread_data = ThreadData::current();
125 if (!current_thread_data) 125 if (!current_thread_data)
126 return; // Shutdown started, and this thread wasn't registered. 126 return; // Shutdown started, and this thread wasn't registered.
127 tracked_births_ = current_thread_data->TallyABirth(from_here); 127 tracked_births_ = current_thread_data->TallyABirth(from_here);
128 128
129 birth_program_counter_ = from_here.program_counter(); 129 birth_program_counter_ = from_here.program_counter();
130 } 130 }
131 131
132 const Location Tracked::GetBirthPlace() const { 132 const Location Tracked::GetBirthPlace() const {
133 return tracked_births_->location(); 133 static Location kNone("UnknownFunctionName", "UnknownFile", -1, NULL);
134 return tracked_births_ ? tracked_births_->location() : kNone;
134 } 135 }
135 136
136 void Tracked::ResetBirthTime() { 137 void Tracked::ResetBirthTime() {
137 tracked_birth_time_ = TimeTicks::Now(); 138 tracked_birth_time_ = TimeTicks::Now();
138 } 139 }
139 140
140 bool Tracked::MissingBirthplace() const { 141 bool Tracked::MissingBirthPlace() const {
141 return -1 == tracked_births_->location().line_number(); 142 return !tracked_births_ || tracked_births_->location().line_number() == -1;
142 } 143 }
143 144
144 #endif // NDEBUG 145 #endif // defined(TRACK_ALL_TASK_OBJECTS)
awong 2011/07/14 21:02:04 !
joth 2011/07/15 07:57:24 Done.
145 146
146 } // namespace tracked_objects 147 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698