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 {
ActivityId PushActivity(const void* origin,
Activity::Type type,
const ActivityData& data) {
return PushActivity(::tracked_objects::GetProgramCounter(), origin, type,
data);
return PushActivity(GetProgramCounter(), origin, type, data);
}
// Changes the activity |type| and |data| of the top-most entry on the stack.
......@@ -1024,8 +1023,7 @@ class BASE_EXPORT GlobalActivityTracker {
// Record exception information for the current thread.
ALWAYS_INLINE
void RecordException(const void* origin, uint32_t code) {
return RecordExceptionImpl(::tracked_objects::GetProgramCounter(), origin,
code);
return RecordExceptionImpl(GetProgramCounter(), origin, code);
}
void RecordException(const void* pc, const void* origin, uint32_t code);
......@@ -1179,31 +1177,31 @@ class BASE_EXPORT GlobalActivityTracker {
const int64_t process_id_;
// 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.
std::atomic<int> thread_tracker_count_;
// A caching memory allocator for thread-tracker objects.
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.
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.
ThreadSafeUserData process_data_;
// A map of global module information, keyed by module path.
std::map<const std::string, ModuleInfoRecord*> modules_;
base::Lock modules_lock_;
Lock modules_lock_;
// The active global activity tracker.
static subtle::AtomicWord g_tracker_;
// 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.
std::map<int64_t, std::string> known_processes_;
......@@ -1242,10 +1240,7 @@ class BASE_EXPORT ScopedActivity
// }
ALWAYS_INLINE
ScopedActivity(uint8_t action, uint32_t id, int32_t info)
: ScopedActivity(::tracked_objects::GetProgramCounter(),
action,
id,
info) {}
: ScopedActivity(GetProgramCounter(), action, id, info) {}
ScopedActivity() : ScopedActivity(0, 0, 0) {}
// Changes the |action| and/or |info| of this activity on the stack. This
......@@ -1278,13 +1273,11 @@ class BASE_EXPORT ScopedTaskRunActivity
: public GlobalActivityTracker::ScopedThreadActivity {
public:
ALWAYS_INLINE
explicit ScopedTaskRunActivity(const base::PendingTask& task)
: ScopedTaskRunActivity(::tracked_objects::GetProgramCounter(),
task) {}
explicit ScopedTaskRunActivity(const PendingTask& task)
: ScopedTaskRunActivity(GetProgramCounter(), task) {}
private:
ScopedTaskRunActivity(const void* program_counter,
const base::PendingTask& task);
ScopedTaskRunActivity(const void* program_counter, const PendingTask& task);
DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunActivity);
};
......@@ -1293,8 +1286,7 @@ class BASE_EXPORT ScopedLockAcquireActivity
public:
ALWAYS_INLINE
explicit ScopedLockAcquireActivity(const base::internal::LockImpl* lock)
: ScopedLockAcquireActivity(::tracked_objects::GetProgramCounter(),
lock) {}
: ScopedLockAcquireActivity(GetProgramCounter(), lock) {}
private:
ScopedLockAcquireActivity(const void* program_counter,
......@@ -1306,13 +1298,12 @@ class BASE_EXPORT ScopedEventWaitActivity
: public GlobalActivityTracker::ScopedThreadActivity {
public:
ALWAYS_INLINE
explicit ScopedEventWaitActivity(const base::WaitableEvent* event)
: ScopedEventWaitActivity(::tracked_objects::GetProgramCounter(),
event) {}
explicit ScopedEventWaitActivity(const WaitableEvent* event)
: ScopedEventWaitActivity(GetProgramCounter(), event) {}
private:
ScopedEventWaitActivity(const void* program_counter,
const base::WaitableEvent* event);
const WaitableEvent* event);
DISALLOW_COPY_AND_ASSIGN(ScopedEventWaitActivity);
};
......@@ -1320,13 +1311,12 @@ class BASE_EXPORT ScopedThreadJoinActivity
: public GlobalActivityTracker::ScopedThreadActivity {
public:
ALWAYS_INLINE
explicit ScopedThreadJoinActivity(const base::PlatformThreadHandle* thread)
: ScopedThreadJoinActivity(::tracked_objects::GetProgramCounter(),
thread) {}
explicit ScopedThreadJoinActivity(const PlatformThreadHandle* thread)
: ScopedThreadJoinActivity(GetProgramCounter(), thread) {}
private:
ScopedThreadJoinActivity(const void* program_counter,
const base::PlatformThreadHandle* thread);
const PlatformThreadHandle* thread);
DISALLOW_COPY_AND_ASSIGN(ScopedThreadJoinActivity);
};
......@@ -1336,13 +1326,12 @@ class BASE_EXPORT ScopedProcessWaitActivity
: public GlobalActivityTracker::ScopedThreadActivity {
public:
ALWAYS_INLINE
explicit ScopedProcessWaitActivity(const base::Process* process)
: ScopedProcessWaitActivity(::tracked_objects::GetProgramCounter(),
process) {}
explicit ScopedProcessWaitActivity(const Process* process)
: ScopedProcessWaitActivity(GetProgramCounter(), process) {}
private:
ScopedProcessWaitActivity(const void* program_counter,
const base::Process* process);
const Process* process);
DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity);
};
#endif
......
......@@ -123,15 +123,6 @@ BASE_EXPORT const void* GetProgramCounter();
} // 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 {
// Specialization for using Location in hash tables.
......
......@@ -455,11 +455,9 @@ DeathDataSnapshot DeathDataSnapshot::Delta(
}
//------------------------------------------------------------------------------
BirthOnThread::BirthOnThread(const Location& location,
BirthOnThread::BirthOnThread(const base::Location& location,
const ThreadData& current)
: location_(location),
birth_thread_(&current) {
}
: location_(location), birth_thread_(&current) {}
//------------------------------------------------------------------------------
BirthOnThreadSnapshot::BirthOnThreadSnapshot() {
......@@ -473,9 +471,8 @@ BirthOnThreadSnapshot::~BirthOnThreadSnapshot() {
}
//------------------------------------------------------------------------------
Births::Births(const Location& location, const ThreadData& current)
: BirthOnThread(location, current),
birth_count_(1) { }
Births::Births(const base::Location& location, const ThreadData& current)
: BirthOnThread(location, current), birth_count_(1) {}
int Births::birth_count() const { return birth_count_; }
......@@ -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);
Births* child;
if (it != birth_map_.end()) {
......@@ -721,7 +718,7 @@ void ThreadData::TallyADeath(const Births& births,
}
// static
Births* ThreadData::TallyABirthIfActive(const Location& location) {
Births* ThreadData::TallyABirthIfActive(const base::Location& location) {
if (!TrackingStatus())
return NULL;
ThreadData* current_thread_data = Get();
......
......@@ -203,16 +203,16 @@ namespace tracked_objects {
class ThreadData;
class BASE_EXPORT BirthOnThread {
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_; }
private:
// 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
// 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
// allowed to update birth_count_ (which changes over time).
......@@ -238,7 +238,7 @@ struct BASE_EXPORT BirthOnThreadSnapshot {
class BASE_EXPORT Births: public BirthOnThread {
public:
Births(const Location& location, const ThreadData& current);
Births(const base::Location& location, const ThreadData& current);
int birth_count() const;
......@@ -549,7 +549,7 @@ class BASE_EXPORT ThreadData {
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;
// Initialize the current thread context with a new instance of ThreadData.
......@@ -583,7 +583,7 @@ class BASE_EXPORT ThreadData {
// Finds (or creates) a place to count births from the given location in this
// thread, and increment that tally.
// 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
// the instance, the |time_posted| records that instant, which is presumed to
......@@ -669,7 +669,7 @@ class BASE_EXPORT ThreadData {
// 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.
void TallyADeath(const Births& births,
......
......@@ -60,7 +60,8 @@ class TrackedObjectsTest : public testing::Test {
// Simulate a birth on the thread named |thread_name|, at the given
// |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
// name, so we're viewed as a worker thread.
if (!thread_name.empty())
......@@ -476,7 +477,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotWorkerThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
const char kFunction[] = "DeactivatedBirthOnlyToSnapshotWorkerThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber);
base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, std::string());
ProcessDataSnapshot process_data;
......@@ -498,7 +499,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToSnapshotMainThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED);
const char kFunction[] = "DeactivatedBirthOnlyToSnapshotMainThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber);
base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, kMainThreadName);
ProcessDataSnapshot process_data;
......@@ -519,7 +520,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotWorkerThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
const char kFunction[] = "BirthOnlyToSnapshotWorkerThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber);
base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, std::string());
ProcessDataSnapshot process_data;
......@@ -532,7 +533,7 @@ TEST_F(TrackedObjectsTest, BirthOnlyToSnapshotMainThread) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
const char kFunction[] = "BirthOnlyToSnapshotMainThread";
Location location(kFunction, kFile, kLineNumber, &kLineNumber);
base::Location location(kFunction, kFile, kLineNumber, &kLineNumber);
TallyABirth(location, kMainThreadName);
ProcessDataSnapshot process_data;
......
......@@ -73,7 +73,7 @@ class GenericScopedHandle {
if (Traits::IsHandleValid(handle)) {
handle_ = handle;
Verifier::StartTracking(handle, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
GetProgramCounter());
}
::SetLastError(last_error);
}
......@@ -89,7 +89,7 @@ class GenericScopedHandle {
handle_ = Traits::NullHandle();
if (Traits::IsHandleValid(temp)) {
Verifier::StopTracking(temp, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
GetProgramCounter());
}
return temp;
}
......@@ -98,7 +98,7 @@ class GenericScopedHandle {
void Close() {
if (Traits::IsHandleValid(handle_)) {
Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER,
tracked_objects::GetProgramCounter());
GetProgramCounter());
Traits::CloseHandle(handle_);
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