From 6142debab3eab9d0007ef32ed13a24a585a86b45 Mon Sep 17 00:00:00 2001 From: "mbelshe@chromium.org" Date: Wed, 8 Sep 2010 23:21:18 +0000 Subject: Add a command line switch "--disable-background-networking", to be used in benchmarking when unexpected background networking can cause undesired vairance. The following systems are disabled via this flag: - IntranetRedirectDetector (requests randomURLs 2-5s after startup) - GoogleUrlTracker (searchdomaincheck) - SafeBrowsing updater - Extension updater BUG=none TEST=none Review URL: http://codereview.chromium.org/3312014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58892 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extension_updater.cc | 4 ++++ chrome/browser/google/google_url_tracker.cc | 6 ++++++ chrome/browser/intranet_redirect_detector.cc | 6 ++++++ chrome/browser/safe_browsing/safe_browsing_service.cc | 4 +++- 4 files changed, 19 insertions(+), 1 deletion(-) (limited to 'chrome/browser') diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 2e1b867..89bdecb 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -792,6 +792,10 @@ std::vector ExtensionUpdater::DetermineUpdates( } void ExtensionUpdater::StartUpdateCheck(ManifestFetchData* fetch_data) { + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableBackgroundNetworking)) + return; + std::deque::const_iterator i; for (i = manifests_pending_.begin(); i != manifests_pending_.end(); i++) { if (fetch_data->full_url() == (*i)->full_url()) { diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 606cc27..30956b6 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -7,6 +7,7 @@ #include #include "app/l10n_util.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -17,6 +18,7 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/net/url_fetcher_protect.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" @@ -188,6 +190,10 @@ void GoogleURLTracker::StartFetchIfDesirable() { !request_context_available_) return; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableBackgroundNetworking)) + return; + already_fetched_ = true; fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), URLFetcher::GET, this)); diff --git a/chrome/browser/intranet_redirect_detector.cc b/chrome/browser/intranet_redirect_detector.cc index b0e2995..481e8cf 100644 --- a/chrome/browser/intranet_redirect_detector.cc +++ b/chrome/browser/intranet_redirect_detector.cc @@ -4,12 +4,14 @@ #include "chrome/browser/intranet_redirect_detector.h" +#include "base/command_line.h" #include "base/rand_util.h" #include "base/stl_util-inl.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "net/base/load_flags.h" @@ -78,6 +80,10 @@ void IntranetRedirectDetector::StartFetchesIfPossible() { if (in_sleep_ || !request_context_available_) return; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableBackgroundNetworking)) + return; + DCHECK(fetchers_.empty() && resulting_origins_.empty()); // Start three fetchers on random hostnames. diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index d51f194..5f2d663 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -364,7 +364,9 @@ void SafeBrowsingService::OnIOInitialize( #endif #endif CommandLine* cmdline = CommandLine::ForCurrentProcess(); - bool disable_auto_update = cmdline->HasSwitch(switches::kSbDisableAutoUpdate); + bool disable_auto_update = + cmdline->HasSwitch(switches::kSbDisableAutoUpdate) || + cmdline->HasSwitch(switches::kDisableBackgroundNetworking); std::string info_url_prefix = cmdline->HasSwitch(switches::kSbInfoURLPrefix) ? cmdline->GetSwitchValueASCII(switches::kSbInfoURLPrefix) : -- cgit v1.1