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

Unified Diff: base/stats_table.cc

Issue 8751: Port last remaining test case in base/stats_table_unittest.cc, and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: base/stats_table.cc
===================================================================
--- base/stats_table.cc (revision 4223)
+++ base/stats_table.cc (working copy)
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/platform_thread.h"
+#include "base/process_util.h"
#include "base/shared_memory.h"
#include "base/string_util.h"
#include "base/thread_local_storage.h"
@@ -91,16 +92,6 @@
int slot;
};
-// The SlotReturnFunction is called at thread exit for each thread
-// which used the StatsTable.
-static void SlotReturnFunction(void* data) {
- StatsTableTLSData* tls_data = static_cast<StatsTableTLSData*>(data);
- if (tls_data) {
- DCHECK(tls_data->table);
- tls_data->table->UnregisterThread();
- }
-}
-
} // namespace
// The StatsTablePrivate maintains convenience pointers into the
@@ -313,12 +304,7 @@
base::wcslcpy(impl_->thread_name(slot), thread_name.c_str(),
kMaxThreadNameLength);
*(impl_->thread_tid(slot)) = PlatformThread::CurrentId();
- // TODO(pinkerton): these should go into process_utils when it's ported
-#if defined(OS_WIN)
- *(impl_->thread_pid(slot)) = GetCurrentProcessId();
-#elif defined(OS_POSIX)
- *(impl_->thread_pid(slot)) = getpid();
-#endif
+ *(impl_->thread_pid(slot)) = process_util::GetCurrentProcId();
}
// Set our thread local storage.
@@ -341,7 +327,10 @@
}
void StatsTable::UnregisterThread() {
- StatsTableTLSData* data = GetTLSData();
+ UnregisterThread(GetTLSData());
+}
+
+void StatsTable::UnregisterThread(StatsTableTLSData* data) {
if (!data)
return;
DCHECK(impl_);
@@ -355,6 +344,14 @@
delete data;
}
Dean McNamee 2008/10/31 19:20:37 Is this because you can no longer access the TLS k
+void StatsTable::SlotReturnFunction(void* data) {
+ StatsTableTLSData* tls_data = static_cast<StatsTableTLSData*>(data);
+ if (tls_data) {
+ DCHECK(tls_data->table);
+ tls_data->table->UnregisterThread(tls_data);
+ }
+}
+
int StatsTable::CountThreadsRegistered() const {
if (!impl_)
return 0;

Powered by Google App Engine
This is Rietveld 408576698