summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authordbeam <dbeam@chromium.org>2015-05-04 16:00:04 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-04 23:00:36 +0000
commiteb1e4d1dd2511083e1d5506d1edfbdff68e133cc (patch)
tree7b8f2fdb338d07fc8cbfb2d7d37e90587b4b409e /base/threading
parentdb926e49caab1e225a5ea52764b8b7fefbc982d2 (diff)
downloadchromium_src-eb1e4d1dd2511083e1d5506d1edfbdff68e133cc.zip
chromium_src-eb1e4d1dd2511083e1d5506d1edfbdff68e133cc.tar.gz
chromium_src-eb1e4d1dd2511083e1d5506d1edfbdff68e133cc.tar.bz2
Revert of Revert some other possible suspects of a 0.43% size increase of setup.exe: https://build.chromium.o… (patchset #1 id:1 of https://codereview.chromium.org/1124563003/)
Reason for revert: Broke the compile because one of these CLs is already depended on (rch@'s bce10d97d6fc5233071427cf622aaad7abde9e19). Original issue's description: > Revert some other possible suspects of a 0.43% size increase of setup.exe: https://build.chromium.org/p/chromium/builders/Win/builds/31562 > > Revert "Add granular base::File tracing." > > This reverts commit a6e05c977096a03774e5406d63ad80c0166f9adc. > > Revert "Add AllReadDataConsumed and AllWriteDataConsumed methods to SocketDataProvider" > > This reverts commit bce10d97d6fc5233071427cf622aaad7abde9e19. > > Revert "Avoid unnecessary memory allocations at PlatformThread::SetName()" > > This reverts commit 4839a142bf95776323647c82ca9dc0725f7c4f15. > > TBR=tdresser@chromium.org > BUG=none > TEST=green sizes > > Committed: https://chromium.googlesource.com/chromium/src/+/c41830d6f55f85e2f5c8841db4b6ed81239b671d TBR=tdresser@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=none Review URL: https://codereview.chromium.org/1123833003 Cr-Commit-Position: refs/heads/master@{#328207}
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/platform_thread.h5
-rw-r--r--base/threading/platform_thread_android.cc4
-rw-r--r--base/threading/platform_thread_freebsd.cc4
-rw-r--r--base/threading/platform_thread_linux.cc4
-rw-r--r--base/threading/platform_thread_mac.mm4
-rw-r--r--base/threading/platform_thread_win.cc6
-rw-r--r--base/threading/simple_thread.cc2
-rw-r--r--base/threading/thread.cc2
-rw-r--r--base/threading/thread_id_name_manager.cc11
-rw-r--r--base/threading/thread_id_name_manager.h2
-rw-r--r--base/threading/watchdog.cc2
-rw-r--r--base/threading/worker_pool_posix.cc2
12 files changed, 23 insertions, 25 deletions
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h
index 653961d..d8f06e5 100644
--- a/base/threading/platform_thread.h
+++ b/base/threading/platform_thread.h
@@ -156,9 +156,8 @@ class BASE_EXPORT PlatformThread {
static void Sleep(base::TimeDelta duration);
// Sets the thread name visible to debuggers/tools. This has no effect
- // otherwise. This name pointer is not copied internally. Thus, it must stay
- // valid until the thread ends.
- static void SetName(const char* name);
+ // otherwise.
+ static void SetName(const std::string& name);
// Gets the thread name, if previously set by SetName.
static const char* GetName();
diff --git a/base/threading/platform_thread_android.cc b/base/threading/platform_thread_android.cc
index a31f659..11e5e2e 100644
--- a/base/threading/platform_thread_android.cc
+++ b/base/threading/platform_thread_android.cc
@@ -64,7 +64,7 @@ bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
} // namespace internal
-void PlatformThread::SetName(const char* name) {
+void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
@@ -76,7 +76,7 @@ void PlatformThread::SetName(const char* name) {
return;
// Set the name for the LWP (which gets truncated to 15 characters).
- int err = prctl(PR_SET_NAME, name);
+ int err = prctl(PR_SET_NAME, name.c_str());
if (err < 0 && errno != EPERM)
DPLOG(ERROR) << "prctl(PR_SET_NAME)";
}
diff --git a/base/threading/platform_thread_freebsd.cc b/base/threading/platform_thread_freebsd.cc
index 7ba4eed..f4fded0 100644
--- a/base/threading/platform_thread_freebsd.cc
+++ b/base/threading/platform_thread_freebsd.cc
@@ -69,7 +69,7 @@ bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
} // namespace internal
// static
-void PlatformThread::SetName(const char* name) {
+void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
@@ -80,7 +80,7 @@ void PlatformThread::SetName(const char* name) {
// killall to stop working.
if (PlatformThread::CurrentId() == getpid())
return;
- setproctitle("%s", name);
+ setproctitle("%s", name.c_str());
#endif // !defined(OS_NACL)
}
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc
index b72fb5b..9f74374 100644
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -70,7 +70,7 @@ bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
} // namespace internal
// static
-void PlatformThread::SetName(const char* name) {
+void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
@@ -87,7 +87,7 @@ void PlatformThread::SetName(const char* name) {
// Note that glibc also has a 'pthread_setname_np' api, but it may not be
// available everywhere and it's only benefit over using prctl directly is
// that it can set the name of threads other than the current thread.
- int err = prctl(PR_SET_NAME, name);
+ int err = prctl(PR_SET_NAME, name.c_str());
// We expect EPERM failures in sandboxed processes, just ignore those.
if (err < 0 && errno != EPERM)
DPLOG(ERROR) << "prctl(PR_SET_NAME)";
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm
index fd40d79..a9c347a 100644
--- a/base/threading/platform_thread_mac.mm
+++ b/base/threading/platform_thread_mac.mm
@@ -42,14 +42,14 @@ void InitThreading() {
}
// static
-void PlatformThread::SetName(const char* name) {
+void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
// Mac OS X does not expose the length limit of the name, so
// hardcode it.
const int kMaxNameLength = 63;
- std::string shortened_name = std::string(name).substr(0, kMaxNameLength);
+ std::string shortened_name = name.substr(0, kMaxNameLength);
// pthread_setname() fails (harmlessly) in the sandbox, ignore when it does.
// See http://crbug.com/47058
pthread_setname_np(shortened_name.c_str());
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index b9f7a56..4eb2cb2 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -154,7 +154,7 @@ void PlatformThread::Sleep(TimeDelta duration) {
}
// static
-void PlatformThread::SetName(const char* name) {
+void PlatformThread::SetName(const std::string& name) {
ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
// On Windows only, we don't need to tell the profiler about the "BrokerEvent"
@@ -163,7 +163,7 @@ void PlatformThread::SetName(const char* name) {
// which would also (as a side effect) initialize the profiler in this unused
// context, including setting up thread local storage, etc. The performance
// impact is not terrible, but there is no reason to do initialize it.
- if (0 != strcmp(name, "BrokerEvent"))
+ if (name != "BrokerEvent")
tracked_objects::ThreadData::InitializeThreadContext(name);
// The debugger needs to be around to catch the name in the exception. If
@@ -173,7 +173,7 @@ void PlatformThread::SetName(const char* name) {
if (!::IsDebuggerPresent() && !base::debug::IsBinaryInstrumented())
return;
- SetNameInternal(CurrentId(), name);
+ SetNameInternal(CurrentId(), name.c_str());
}
// static
diff --git a/base/threading/simple_thread.cc b/base/threading/simple_thread.cc
index 028d4f4..1bc3113 100644
--- a/base/threading/simple_thread.cc
+++ b/base/threading/simple_thread.cc
@@ -52,7 +52,7 @@ void SimpleThread::ThreadMain() {
// Construct our full name of the form "name_prefix_/TID".
name_.push_back('/');
name_.append(IntToString(tid_));
- PlatformThread::SetName(name_.c_str());
+ PlatformThread::SetName(name_);
// We've initialized our new thread, signal that we're done to Start().
event_.Signal();
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index bab3991..0e4aab2 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -208,7 +208,7 @@ void Thread::ThreadMain() {
// Complete the initialization of our Thread object.
thread_id_ = PlatformThread::CurrentId();
- PlatformThread::SetName(name_.c_str());
+ PlatformThread::SetName(name_);
ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector.
message_loop->set_thread_name(name_);
message_loop->SetTimerSlack(startup_data_->options.timer_slack);
diff --git a/base/threading/thread_id_name_manager.cc b/base/threading/thread_id_name_manager.cc
index 7c85c1b..56cfa27 100644
--- a/base/threading/thread_id_name_manager.cc
+++ b/base/threading/thread_id_name_manager.cc
@@ -48,17 +48,16 @@ void ThreadIdNameManager::RegisterThread(PlatformThreadHandle::Handle handle,
name_to_interned_name_[kDefaultName];
}
-void ThreadIdNameManager::SetName(PlatformThreadId id, const char* name) {
- std::string str_name(name);
-
+void ThreadIdNameManager::SetName(PlatformThreadId id,
+ const std::string& name) {
AutoLock locked(lock_);
- NameToInternedNameMap::iterator iter = name_to_interned_name_.find(str_name);
+ NameToInternedNameMap::iterator iter = name_to_interned_name_.find(name);
std::string* leaked_str = NULL;
if (iter != name_to_interned_name_.end()) {
leaked_str = iter->second;
} else {
- leaked_str = new std::string(str_name);
- name_to_interned_name_[str_name] = leaked_str;
+ leaked_str = new std::string(name);
+ name_to_interned_name_[name] = leaked_str;
}
ThreadIdToHandleMap::iterator id_to_handle_iter =
diff --git a/base/threading/thread_id_name_manager.h b/base/threading/thread_id_name_manager.h
index 0ea59df..927d25f 100644
--- a/base/threading/thread_id_name_manager.h
+++ b/base/threading/thread_id_name_manager.h
@@ -27,7 +27,7 @@ class BASE_EXPORT ThreadIdNameManager {
void RegisterThread(PlatformThreadHandle::Handle handle, PlatformThreadId id);
// Set the name for the given id.
- void SetName(PlatformThreadId id, const char* name);
+ void SetName(PlatformThreadId id, const std::string& name);
// Get the name for the given id.
const char* GetName(PlatformThreadId id);
diff --git a/base/threading/watchdog.cc b/base/threading/watchdog.cc
index 769119e..c063799 100644
--- a/base/threading/watchdog.cc
+++ b/base/threading/watchdog.cc
@@ -169,7 +169,7 @@ void Watchdog::ThreadDelegate::ThreadMain() {
void Watchdog::ThreadDelegate::SetThreadName() const {
std::string name = watchdog_->thread_watched_name_ + " Watchdog";
- PlatformThread::SetName(name.c_str());
+ PlatformThread::SetName(name);
DVLOG(1) << "Watchdog active: " << name;
}
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index 8c55a2c..349b5d7 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -77,7 +77,7 @@ void WorkerThread::ThreadMain() {
const std::string name = base::StringPrintf(
"%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId());
// Note |name.c_str()| must remain valid for for the whole life of the thread.
- PlatformThread::SetName(name.c_str());
+ PlatformThread::SetName(name);
for (;;) {
PendingTask pending_task = pool_->WaitForTask();