Commit e48bbdc2 authored by Brett Wilson's avatar Brett Wilson Committed by Commit Bot

Finish moving Location and GetProgramCounter to base namespace

Cleans up the remaining references and removes the temporary using statement.

Bug: 763556
Change-Id: I25f3cc449bfb7b0da0bd113da3171105d2594188
Reviewed-on: https://chromium-review.googlesource.com/663792
Commit-Queue: Brett Wilson <brettw@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501519}
parent 6a3fddd4
...@@ -664,8 +664,7 @@ class BASE_EXPORT ThreadActivityTracker { ...@@ -664,8 +664,7 @@ class BASE_EXPORT ThreadActivityTracker {
ActivityId PushActivity(const void* origin, ActivityId PushActivity(const void* origin,
Activity::Type type, Activity::Type type,
const ActivityData& data) { const ActivityData& data) {
return PushActivity(::tracked_objects::GetProgramCounter(), origin, type, return PushActivity(GetProgramCounter(), origin, type, data);
data);
} }
// Changes the activity |type| and |data| of the top-most entry on the stack. // Changes the activity |type| and |data| of the top-most entry on the stack.
...@@ -1024,8 +1023,7 @@ class BASE_EXPORT GlobalActivityTracker { ...@@ -1024,8 +1023,7 @@ class BASE_EXPORT GlobalActivityTracker {
// Record exception information for the current thread. // Record exception information for the current thread.
ALWAYS_INLINE ALWAYS_INLINE
void RecordException(const void* origin, uint32_t code) { void RecordException(const void* origin, uint32_t code) {
return RecordExceptionImpl(::tracked_objects::GetProgramCounter(), origin, return RecordExceptionImpl(GetProgramCounter(), origin, code);
code);
} }
void RecordException(const void* pc, const void* origin, uint32_t code); void RecordException(const void* pc, const void* origin, uint32_t code);
...@@ -1179,31 +1177,31 @@ class BASE_EXPORT GlobalActivityTracker { ...@@ -1179,31 +1177,31 @@ class BASE_EXPORT GlobalActivityTracker {
const int64_t process_id_; const int64_t process_id_;
// The activity tracker for the currently executing thread. // The activity tracker for the currently executing thread.
base::ThreadLocalStorage::Slot this_thread_tracker_; ThreadLocalStorage::Slot this_thread_tracker_;
// The number of thread trackers currently active. // The number of thread trackers currently active.
std::atomic<int> thread_tracker_count_; std::atomic<int> thread_tracker_count_;
// A caching memory allocator for thread-tracker objects. // A caching memory allocator for thread-tracker objects.
ActivityTrackerMemoryAllocator thread_tracker_allocator_; ActivityTrackerMemoryAllocator thread_tracker_allocator_;
base::Lock thread_tracker_allocator_lock_; Lock thread_tracker_allocator_lock_;
// A caching memory allocator for user data attached to activity data. // A caching memory allocator for user data attached to activity data.
ActivityTrackerMemoryAllocator user_data_allocator_; ActivityTrackerMemoryAllocator user_data_allocator_;
base::Lock user_data_allocator_lock_; Lock user_data_allocator_lock_;
// An object for holding arbitrary key value pairs with thread-safe access. // An object for holding arbitrary key value pairs with thread-safe access.
ThreadSafeUserData process_data_; ThreadSafeUserData process_data_;
// A map of global module information, keyed by module path. // A map of global module information, keyed by module path.
std::map<const std::string, ModuleInfoRecord*> modules_; std::map<const std::string, ModuleInfoRecord*> modules_;
base::Lock modules_lock_; Lock modules_lock_;
// The active global activity tracker. // The active global activity tracker.
static subtle::AtomicWord g_tracker_; static subtle::AtomicWord g_tracker_;
// A lock that is used to protect access to the following fields. // A lock that is used to protect access to the following fields.
base::Lock global_tracker_lock_; Lock global_tracker_lock_;
// The collection of processes being tracked and their command-lines. // The collection of processes being tracked and their command-lines.
std::map<int64_t, std::string> known_processes_; std::map<int64_t, std::string> known_processes_;
...@@ -1242,10 +1240,7 @@ class BASE_EXPORT ScopedActivity ...@@ -1242,10 +1240,7 @@ class BASE_EXPORT ScopedActivity
// } // }
ALWAYS_INLINE ALWAYS_INLINE
ScopedActivity(uint8_t action, uint32_t id, int32_t info) ScopedActivity(uint8_t action, uint32_t id, int32_t info)
: ScopedActivity(::tracked_objects::GetProgramCounter(), : ScopedActivity(GetProgramCounter(), action, id, info) {}
action,
id,
info) {}
ScopedActivity() : ScopedActivity(0, 0, 0) {} ScopedActivity() : ScopedActivity(0, 0, 0) {}
// Changes the |action| and/or |info| of this activity on the stack. This // Changes the |action| and/or |info| of this activity on the stack. This
...@@ -1278,13 +1273,11 @@ class BASE_EXPORT ScopedTaskRunActivity ...@@ -1278,13 +1273,11 @@ class BASE_EXPORT ScopedTaskRunActivity
: public GlobalActivityTracker::ScopedThreadActivity { : public GlobalActivityTracker::ScopedThreadActivity {
public: public:
ALWAYS_INLINE ALWAYS_INLINE
explicit ScopedTaskRunActivity(const base::PendingTask& task) explicit ScopedTaskRunActivity(const PendingTask& task)
: ScopedTaskRunActivity(::tracked_objects::GetProgramCounter(), : ScopedTaskRunActivity(GetProgramCounter(), task) {}
task) {}
private: private:
ScopedTaskRunActivity(const void* program_counter, ScopedTaskRunActivity(const void* program_counter, const PendingTask& task);
const base::PendingTask& task);
DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunActivity); DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunActivity);
}; };
...@@ -1293,8 +1286,7 @@ class BASE_EXPORT ScopedLockAcquireActivity ...@@ -1293,8 +1286,7 @@ class BASE_EXPORT ScopedLockAcquireActivity
public: public:
ALWAYS_INLINE ALWAYS_INLINE
explicit ScopedLockAcquireActivity(const base::internal::LockImpl* lock) explicit ScopedLockAcquireActivity(const base::internal::LockImpl* lock)
: ScopedLockAcquireActivity(::tracked_objects::GetProgramCounter(), : ScopedLockAcquireActivity(GetProgramCounter(), lock) {}
lock) {}
private: private:
ScopedLockAcquireActivity(const void* program_counter, ScopedLockAcquireActivity(const void* program_counter,
...@@ -1306,13 +1298,12 @@ class BASE_EXPORT ScopedEventWaitActivity ...@@ -1306,13 +1298,12 @@ class BASE_EXPORT ScopedEventWaitActivity
: public GlobalActivityTracker::ScopedThreadActivity { : public GlobalActivityTracker::ScopedThreadActivity {
public: public:
ALWAYS_INLINE ALWAYS_INLINE
explicit ScopedEventWaitActivity(const base::WaitableEvent* event) explicit ScopedEventWaitActivity(const WaitableEvent* event)
: ScopedEventWaitActivity(::tracked_objects::GetProgramCounter(), : ScopedEventWaitActivity(GetProgramCounter(), event) {}
event) {}
private: private:
ScopedEventWaitActivity(const void* program_counter, ScopedEventWaitActivity(const void* program_counter,
const base::WaitableEvent* event); const WaitableEvent* event);
DISALLOW_COPY_AND_ASSIGN(ScopedEventWaitActivity); DISALLOW_COPY_AND_ASSIGN(ScopedEventWaitActivity);
}; };
...@@ -1320,13 +1311,12 @@ class BASE_EXPORT ScopedThreadJoinActivity ...@@ -1320,13 +1311,12 @@ class BASE_EXPORT ScopedThreadJoinActivity
: public GlobalActivityTracker::ScopedThreadActivity { : public GlobalActivityTracker::ScopedThreadActivity {
public: public:
ALWAYS_INLINE ALWAYS_INLINE
explicit ScopedThreadJoinActivity(const base::PlatformThreadHandle* thread) explicit ScopedThreadJoinActivity(const PlatformThreadHandle* thread)
: ScopedThreadJoinActivity(::tracked_objects::GetProgramCounter(), : ScopedThreadJoinActivity(GetProgramCounter(), thread) {}
thread) {}
private: private:
ScopedThreadJoinActivity(const void* program_counter, ScopedThreadJoinActivity(const void* program_counter,
const base::PlatformThreadHandle* thread); const PlatformThreadHandle* thread);
DISALLOW_COPY_AND_ASSIGN(ScopedThreadJoinActivity); DISALLOW_COPY_AND_ASSIGN(ScopedThreadJoinActivity);
}; };
...@@ -1336,13 +1326,12 @@ class BASE_EXPORT ScopedProcessWaitActivity ...@@ -1336,13 +1326,12 @@ class BASE_EXPORT ScopedProcessWaitActivity
: public GlobalActivityTracker::ScopedThreadActivity { : public GlobalActivityTracker::ScopedThreadActivity {
public: public:
ALWAYS_INLINE ALWAYS_INLINE
explicit ScopedProcessWaitActivity(const base::Process* process) explicit ScopedProcessWaitActivity(const Process* process)
: ScopedProcessWaitActivity(::tracked_objects::GetProgramCounter(), : ScopedProcessWaitActivity(GetProgramCounter(), process) {}
process) {}
private: private:
ScopedProcessWaitActivity(const void* program_counter, ScopedProcessWaitActivity(const void* program_counter,
const base::Process* process); const Process* process);
DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity);
}; };
#endif #endif
......
...@@ -123,15 +123,6 @@ BASE_EXPORT const void* GetProgramCounter(); ...@@ -123,15 +123,6 @@ BASE_EXPORT const void* GetProgramCounter();
} // namespace base } // namespace base
namespace tracked_objects {
// TODO(http://crbug.com/763556): Convert all uses of Location and
// GetProgramCounter to use the base namespace and remove these lines.
using ::base::Location;
using ::base::GetProgramCounter;
} // namespace tracked_objects
namespace std { namespace std {
// Specialization for using Location in hash tables. // Specialization for using Location in hash tables.
......
...@@ -455,11 +455,9 @@ DeathDataSnapshot DeathDataSnapshot::Delta( ...@@ -455,11 +455,9 @@ DeathDataSnapshot DeathDataSnapshot::Delta(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BirthOnThread::BirthOnThread(const Location& location, BirthOnThread::BirthOnThread(const base::Location& location,
const ThreadData& current) const ThreadData& current)
: location_(location), : location_(location), birth_thread_(&current) {}
birth_thread_(&current) {
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BirthOnThreadSnapshot::BirthOnThreadSnapshot() { BirthOnThreadSnapshot::BirthOnThreadSnapshot() {
...@@ -473,9 +471,8 @@ BirthOnThreadSnapshot::~BirthOnThreadSnapshot() { ...@@ -473,9 +471,8 @@ BirthOnThreadSnapshot::~BirthOnThreadSnapshot() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Births::Births(const Location& location, const ThreadData& current) Births::Births(const base::Location& location, const ThreadData& current)
: BirthOnThread(location, current), : BirthOnThread(location, current), birth_count_(1) {}
birth_count_(1) { }
int Births::birth_count() const { return birth_count_; } int Births::birth_count() const { return birth_count_; }
...@@ -665,7 +662,7 @@ void ThreadData::OnProfilingPhaseCompleted(int profiling_phase) { ...@@ -665,7 +662,7 @@ void ThreadData::OnProfilingPhaseCompleted(int profiling_phase) {
} }
} }
Births* ThreadData::TallyABirth(const Location& location) { Births* ThreadData::TallyABirth(const base::Location& location) {
BirthMap::iterator it = birth_map_.find(location); BirthMap::iterator it = birth_map_.find(location);
Births* child; Births* child;
if (it != birth_map_.end()) { if (it != birth_map_.end()) {
...@@ -721,7 +718,7 @@ void ThreadData::TallyADeath(const Births& births, ...@@ -721,7 +718,7 @@ void ThreadData::TallyADeath(const Births& births,
} }
// static // static
Births* ThreadData::TallyABirthIfActive(const Location& location) { Births* ThreadData::TallyABirthIfActive(const base::Location& location) {
if (!TrackingStatus()) if (!TrackingStatus())
return NULL; return NULL;
ThreadData* current_thread_data = Get(); ThreadData* current_thread_data = Get();
......
...@@ -203,16 +203,16 @@ namespace tracked_objects { ...@@ -203,16 +203,16 @@ namespace tracked_objects {
class ThreadData; class ThreadData;
class BASE_EXPORT BirthOnThread { class BASE_EXPORT BirthOnThread {
public: public:
BirthOnThread(const Location& location, const ThreadData& current); BirthOnThread(const base::Location& location, const ThreadData& current);
const Location& location() const { return location_; } const base::Location& location() const { return location_; }
const ThreadData* birth_thread() const { return birth_thread_; } const ThreadData* birth_thread() const { return birth_thread_; }
private: private:
// File/lineno of birth. This defines the essence of the task, as the context // File/lineno of birth. This defines the essence of the task, as the context
// of the birth (construction) often tell what the item is for. This field // of the birth (construction) often tell what the item is for. This field
// is const, and hence safe to access from any thread. // is const, and hence safe to access from any thread.
const Location location_; const base::Location location_;
// The thread that records births into this object. Only this thread is // The thread that records births into this object. Only this thread is
// allowed to update birth_count_ (which changes over time). // allowed to update birth_count_ (which changes over time).
...@@ -238,7 +238,7 @@ struct BASE_EXPORT BirthOnThreadSnapshot { ...@@ -238,7 +238,7 @@ struct BASE_EXPORT BirthOnThreadSnapshot {
class BASE_EXPORT Births: public BirthOnThread { class BASE_EXPORT Births: public BirthOnThread {
public: public:
Births(const Location& location, const ThreadData& current); Births(const base::Location& location, const ThreadData& current);
int birth_count() const; int birth_count() const;
...@@ -549,7 +549,7 @@ class BASE_EXPORT ThreadData { ...@@ -549,7 +549,7 @@ class BASE_EXPORT ThreadData {
STATUS_LAST = PROFILING_ACTIVE STATUS_LAST = PROFILING_ACTIVE
}; };
typedef std::unordered_map<Location, Births*> BirthMap; typedef std::unordered_map<base::Location, Births*> BirthMap;
typedef std::map<const Births*, DeathData> DeathMap; typedef std::map<const Births*, DeathData> DeathMap;
// Initialize the current thread context with a new instance of ThreadData. // Initialize the current thread context with a new instance of ThreadData.
...@@ -583,7 +583,7 @@ class BASE_EXPORT ThreadData { ...@@ -583,7 +583,7 @@ class BASE_EXPORT ThreadData {
// Finds (or creates) a place to count births from the given location in this // Finds (or creates) a place to count births from the given location in this
// thread, and increment that tally. // thread, and increment that tally.
// TallyABirthIfActive will returns NULL if the birth cannot be tallied. // TallyABirthIfActive will returns NULL if the birth cannot be tallied.
static Births* TallyABirthIfActive(const Location& location); static Births* TallyABirthIfActive(const base::Location& location);
// Record the end of a timed run of an object. The |birth| is the record for // Record the end of a timed run of an object. The |birth| is the record for
// the instance, the |time_posted| records that instant, which is presumed to // the instance, the |time_posted| records that instant, which is presumed to
...@@ -669,7 +669,7 @@ class BASE_EXPORT ThreadData { ...@@ -669,7 +669,7 @@ class BASE_EXPORT ThreadData {
// In this thread's data, record a new birth. // In this thread's data, record a new birth.
Births* TallyABirth(const Location& location); Births* TallyABirth(const base::Location& location);
// Find a place to record a death on this thread. // Find a place to record a death on this thread.
void TallyADeath(const Births& births, void TallyADeath(const Births& births,
......
...@@ -60,7 +60,8 @@ class TrackedObjectsTest : public testing::Test { ...@@ -60,7 +60,8 @@ class TrackedObjectsTest : public testing::Test {
// Simulate a birth on the thread named |thread_name|, at the given // Simulate a birth on the thread named |thread_name|, at the given
// |location|. // |location|.
void TallyABirth(const Location& location, const std::string& thread_name) { void TallyABirth(const base::Location& location,
const std::string& thread_name) {
// If the |thread_name| is empty, we don't initialize system with a thread // If the |thread_name| is empty, we don't initialize system with a thread
// name, so we're viewed as a worker thread. // name, so we're viewed as a worker thread.
if (!thread_name.empty()) if (!thread_name.empty())
...@@ -476,7 +477,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotWorkerThread) { ...@@ -476,7 +477,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotWorkerThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread"; const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber); base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, std::string()); TallyABirth(location, std::string());
ProcessDataSnapshot process_data; ProcessDataSnapshot process_data;
...@@ -498,7 +499,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) { ...@@ -498,7 +499,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED); ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread"; const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber); base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, kMainThreadName); TallyABirth(location, kMainThreadName);
ProcessDataSnapshot process_data; ProcessDataSnapshot process_data;
...@@ -519,7 +520,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) { ...@@ -519,7 +520,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
const char kFunction[] = "BirthOnlyToSnapshotWorkerThread"; const char kFunction[] = "BirthOnlyToSnapshotWorkerThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber); base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, std::string()); TallyABirth(location, std::string());
ProcessDataSnapshot process_data; ProcessDataSnapshot process_data;
...@@ -532,7 +533,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotMainThread) { ...@@ -532,7 +533,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotMainThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE); ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
const char kFunction[] = "BirthOnlyToSnapshotMainThread"; const char kFunction[] = "BirthOnlyToSnapshotMainThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber); base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, kMainThreadName); TallyABirth(location, kMainThreadName);
ProcessDataSnapshot process_data; ProcessDataSnapshot process_data;
......
...@@ -73,7 +73,7 @@ class GenericScopedHandle { ...@@ -73,7 +73,7 @@ class GenericScopedHandle {
if (Traits::IsHandleValid(handle)) { if (Traits::IsHandleValid(handle)) {
handle_ = handle; handle_ = handle;
Verifier::StartTracking(handle, this, BASE_WIN_GET_CALLER, Verifier::StartTracking(handle, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter()); GetProgramCounter());
} }
::SetLastError(last_error); ::SetLastError(last_error);
} }
...@@ -89,7 +89,7 @@ class GenericScopedHandle { ...@@ -89,7 +89,7 @@ class GenericScopedHandle {
handle_ = Traits::NullHandle(); handle_ = Traits::NullHandle();
if (Traits::IsHandleValid(temp)) { if (Traits::IsHandleValid(temp)) {
Verifier::StopTracking(temp, this, BASE_WIN_GET_CALLER, Verifier::StopTracking(temp, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter()); GetProgramCounter());
} }
return temp; return temp;
} }
...@@ -98,7 +98,7 @@ class GenericScopedHandle { ...@@ -98,7 +98,7 @@ class GenericScopedHandle {
void Close() { void Close() {
if (Traits::IsHandleValid(handle_)) { if (Traits::IsHandleValid(handle_)) {
Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER, Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter()); GetProgramCounter());
Traits::CloseHandle(handle_); Traits::CloseHandle(handle_);
handle_ = Traits::NullHandle(); handle_ = Traits::NullHandle();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment