diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 11:38:17 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 11:38:17 +0000 |
commit | 65ae4bc4c122392ec5b85bbadc02e1b7d55623f6 (patch) | |
tree | 1787fd9a58a47465e6f4c3eb253effaa7a7ad715 /chrome | |
parent | e51a2c629fa50d90f608cb6775b54fc39a0b91a0 (diff) | |
download | chromium_src-65ae4bc4c122392ec5b85bbadc02e1b7d55623f6.zip chromium_src-65ae4bc4c122392ec5b85bbadc02e1b7d55623f6.tar.gz chromium_src-65ae4bc4c122392ec5b85bbadc02e1b7d55623f6.tar.bz2 |
Refactor thread naming in the DNS slaves.
BUG=1337196
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1219 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/dns_master.cc | 11 | ||||
-rw-r--r-- | chrome/browser/net/dns_master.h | 7 | ||||
-rw-r--r-- | chrome/browser/net/dns_slave.cc | 10 |
3 files changed, 10 insertions, 18 deletions
diff --git a/chrome/browser/net/dns_master.cc b/chrome/browser/net/dns_master.cc index 582c1e6..10d464f 100644 --- a/chrome/browser/net/dns_master.cc +++ b/chrome/browser/net/dns_master.cc @@ -35,7 +35,6 @@ #include "base/histogram.h" #include "base/stats_counters.h" -#include "base/string_util.h" #include "base/thread.h" #include "base/win_util.h" #include "chrome/browser/net/dns_slave.h" @@ -254,16 +253,6 @@ void DnsMaster::PreLockedResolve(const std::string& hostname) { name_buffer_.push(hostname); } -void DnsMaster::SetSlaveName(int slave_index) { - DCHECK(0 <= slave_index && kSlaveCountMax > slave_index); - - std::string name = StringPrintf("Dns Prefetcher thread %d of %d", - slave_index + 1, kSlaveCountMax); - - DLOG(INFO) << "Now Running " << name; - PlatformThread::SetName(thread_ids_[slave_index], name.c_str()); -} - // GetNextAssignment() is executed on the thread associated with // with a prefetch slave instance. // Return value of false indicates slave thread termination is needed. diff --git a/chrome/browser/net/dns_master.h b/chrome/browser/net/dns_master.h index 45dd00e..010f41c 100644 --- a/chrome/browser/net/dns_master.h +++ b/chrome/browser/net/dns_master.h @@ -61,6 +61,8 @@ typedef std::map<std::string, DnsHostInfo> Results; class DnsMaster { public: + // The number of slave processes that will do DNS prefetching + static const int kSlaveCountMax = 8; explicit DnsMaster(TimeDelta shutdown_wait_time); @@ -127,9 +129,6 @@ class DnsMaster { //---------------------------------------------------------------------------- // Methods below this line should only be called by slave processes. - // Thread names can only be set after the thread has been running a bit. - void SetSlaveName(int slave_index); - // GetNextAssignment() gets the next hostname from queue for processing // It is not meant to be public, and should only be used by the slave. // GetNextAssignment() waits on a condition variable if there are no more @@ -154,8 +153,6 @@ class DnsMaster { void PreLockedResolve(const std::string& hostname); bool PreLockedCreateNewSlaveIfNeeded(); // Lazy slave processes creation. - // The number of slave processes that will do DNS prefetching - static const int kSlaveCountMax = 8; // Number of slave processes started early (to help with startup prefetch). static const int kSlaveCountMin = 4; diff --git a/chrome/browser/net/dns_slave.cc b/chrome/browser/net/dns_slave.cc index c3ec818..c07b307 100644 --- a/chrome/browser/net/dns_slave.cc +++ b/chrome/browser/net/dns_slave.cc @@ -36,6 +36,8 @@ #include <Wspiapi.h> // Needed for win2k compatibility #include "base/logging.h" +#include "base/platform_thread.h" +#include "base/string_util.h" #include "chrome/browser/net/dns_host_info.h" #include "chrome/browser/net/dns_master.h" @@ -72,8 +74,12 @@ DWORD __stdcall DnsSlave::ThreadStart(void* pThis) { //------------------------------------------------------------------------------ unsigned DnsSlave::Run() { - // We have to be running to set the thread name. - master_->SetSlaveName(slave_index_); + DCHECK(slave_index_ >= 0 && slave_index_ < DnsMaster::kSlaveCountMax); + + std::string name = StringPrintf( + "dns_prefetcher_%d_of_%d", slave_index_ + 1, DnsMaster::kSlaveCountMax); + DLOG(INFO) << "Now Running " << name; + PlatformThread::SetName(PlatformThread::CurrentId(), name.c_str()); while (master_->GetNextAssignment(&hostname_)) { BlockingDnsLookup(); |