summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/field_trial.cc19
-rw-r--r--base/field_trial.h11
-rw-r--r--chrome/browser/browser_main.cc18
-rw-r--r--chrome/browser/net/dns_global.cc6
-rw-r--r--net/http/http_network_transaction.cc9
5 files changed, 46 insertions, 17 deletions
diff --git a/base/field_trial.cc b/base/field_trial.cc
index 901ba16..d0085e6 100644
--- a/base/field_trial.cc
+++ b/base/field_trial.cc
@@ -63,6 +63,7 @@ FieldTrialList::FieldTrialList()
}
FieldTrialList::~FieldTrialList() {
+ AutoLock auto_lock(lock_);
while (!registered_.empty()) {
RegistrationList::iterator it = registered_.begin();
it->second->Release();
@@ -74,8 +75,8 @@ FieldTrialList::~FieldTrialList() {
// static
void FieldTrialList::Register(FieldTrial* trial) {
- DCHECK(global_->CalledOnValidThread());
- DCHECK(!Find(trial->name()));
+ AutoLock auto_lock(global_->lock_);
+ DCHECK(!global_->PreLockedFind(trial->name()));
trial->AddRef();
global_->registered_[trial->name()] = trial;
}
@@ -96,11 +97,17 @@ std::string FieldTrialList::FindFullName(const std::string& name) {
return "";
}
- // static
+// static
FieldTrial* FieldTrialList::Find(const std::string& name) {
- DCHECK(global_->CalledOnValidThread());
- RegistrationList::iterator it = global_->registered_.find(name);
- if (global_->registered_.end() == it)
+ if (!global_)
+ return NULL;
+ AutoLock auto_lock(global_->lock_);
+ return global_->PreLockedFind(name);
+}
+
+FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) {
+ RegistrationList::iterator it = registered_.find(name);
+ if (registered_.end() == it)
return NULL;
return it->second;
}
diff --git a/base/field_trial.h b/base/field_trial.h
index bde6717..3d922d1 100644
--- a/base/field_trial.h
+++ b/base/field_trial.h
@@ -47,7 +47,7 @@
// happened (randomly) to be assigned to:
// HISTOGRAM_COUNTS(FieldTrial::MakeName("Memory.RendererTotal",
-// "MemoryExperiment"), count);
+// "MemoryExperiment").data(), count);
// The above code will create 3 distinct histograms, with each run of the
// application being assigned to of of teh three groups, and for each group, the
@@ -65,6 +65,7 @@
#include <map>
#include <string>
+#include "base/lock.h"
#include "base/non_thread_safe.h"
#include "base/ref_counted.h"
#include "base/time.h"
@@ -140,7 +141,7 @@ class FieldTrial : public base::RefCounted<FieldTrial> {
// Class with a list of all active field trials. A trial is active if it has
// been registered, which includes evaluating its state based on its probaility.
// Only one instance of this class exists.
-class FieldTrialList : NonThreadSafe {
+class FieldTrialList {
public:
// This singleton holds the global list of registered FieldTrials.
FieldTrialList();
@@ -172,11 +173,17 @@ class FieldTrialList : NonThreadSafe {
}
private:
+ // Helper function should be called only while holding lock_.
+ FieldTrial* PreLockedFind(const std::string& name);
+
typedef std::map<std::string, FieldTrial*> RegistrationList;
static FieldTrialList* global_; // The singleton of this class.
base::Time application_start_time_;
+
+ // Lock for access to registered_.
+ Lock lock_;
RegistrationList registered_;
DISALLOW_COPY_AND_ASSIGN(FieldTrialList);
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 4309f9d..1ef1f74 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -439,10 +439,20 @@ int BrowserMain(const MainFunctionParams& parameters) {
net::EnsureWinsockInit();
#endif // defined(OS_WIN)
- // Initialize the DNS prefetch system
- chrome_browser_net::DnsPrefetcherInit dns_prefetch_init(user_prefs);
- chrome_browser_net::DnsPrefetchHostNamesAtStartup(user_prefs, local_state);
- chrome_browser_net::RestoreSubresourceReferrers(local_state);
+ // Set up a field trial.
+ FieldTrial::Probability kDIVISOR = 100;
+ FieldTrial::Probability kDISABLE = 1; // 1%.
+ scoped_refptr<FieldTrial> dns_trial = new FieldTrial("DnsImpact", kDIVISOR);
+ int disabled_group = dns_trial->AppendGroup("_disabled_prefetch", kDISABLE);
+
+ scoped_ptr<chrome_browser_net::DnsPrefetcherInit> dns_prefetch_init;
+ if (dns_trial->group() != disabled_group) {
+ // Initialize the DNS prefetch system
+ dns_prefetch_init.reset(
+ new chrome_browser_net::DnsPrefetcherInit(user_prefs));
+ chrome_browser_net::DnsPrefetchHostNamesAtStartup(user_prefs, local_state);
+ chrome_browser_net::RestoreSubresourceReferrers(local_state);
+ }
#if defined(OS_WIN)
// Init common control sex.
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc
index c8df241..0dbba5d 100644
--- a/chrome/browser/net/dns_global.cc
+++ b/chrome/browser/net/dns_global.cc
@@ -81,11 +81,9 @@ void DnsPrefetchList(const NameList& hostnames) {
static void DnsPrefetchMotivatedList(
const NameList& hostnames,
DnsHostInfo::ResolutionMotivation motivation) {
- if (!dns_prefetch_enabled)
+ if (!dns_prefetch_enabled || NULL == dns_master)
return;
- DCHECK(NULL != dns_master);
- if (NULL != dns_master)
- dns_master->ResolveList(hostnames, motivation);
+ dns_master->ResolveList(hostnames, motivation);
}
// This API is used by the autocomplete popup box (where URLs are typed).
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 2a41c6a..4337905 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -6,6 +6,7 @@
#include "base/scoped_ptr.h"
#include "base/compiler_specific.h"
+#include "base/field_trial.h"
#include "base/string_util.h"
#include "base/trace_event.h"
#include "build/build_config.h"
@@ -947,7 +948,13 @@ void HttpNetworkTransaction::LogTransactionMetrics() const {
base::TimeDelta duration = base::Time::Now() - response_.request_time;
if (60 < duration.InMinutes())
return;
- UMA_HISTOGRAM_LONG_TIMES("Net.Transaction_Latency", duration);
+
+ UMA_HISTOGRAM_LONG_TIMES(FieldTrial::MakeName("Net.Transaction_Latency",
+ "DnsImpact").data(), duration);
+ UMA_HISTOGRAM_CLIPPED_TIMES(FieldTrial::MakeName(
+ "Net.Transaction_Latency_Under_10", "DnsImpact").data(), duration,
+ base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(10),
+ 100);
if (!duration.InMilliseconds())
return;
UMA_HISTOGRAM_COUNTS("Net.Transaction_Bandwidth",