diff options
author | tanviraumi <tanviraumi@google.com> | 2014-08-29 12:04:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-29 19:26:11 +0000 |
commit | 387f633d1205ae65bacb5e4a0c4d174f32862874 (patch) | |
tree | f9a73116d9b7c852725c2c68b6b0a1b5e61722ae /components/precache | |
parent | 67fa5e94bdbd9eb7bce39c0cd6922321cf4998c9 (diff) | |
download | chromium_src-387f633d1205ae65bacb5e4a0c4d174f32862874.zip chromium_src-387f633d1205ae65bacb5e4a0c4d174f32862874.tar.gz chromium_src-387f633d1205ae65bacb5e4a0c4d174f32862874.tar.bz2 |
Check if precaching is allowed for the current browser context before
measuring any precache-related metrics.
BUG=309216
Review URL: https://codereview.chromium.org/514353002
Cr-Commit-Position: refs/heads/master@{#292677}
Diffstat (limited to 'components/precache')
-rw-r--r-- | components/precache/content/DEPS | 2 | ||||
-rw-r--r-- | components/precache/content/precache_manager.cc | 13 | ||||
-rw-r--r-- | components/precache/content/precache_manager.h | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/components/precache/content/DEPS b/components/precache/content/DEPS index 9ed9740..a62c4eb 100644 --- a/components/precache/content/DEPS +++ b/components/precache/content/DEPS @@ -1,5 +1,7 @@ include_rules = [ + "+components/data_reduction_proxy/common", "+components/keyed_service", + "+components/user_prefs", "+content/public/browser", "+net/base", ] diff --git a/components/precache/content/precache_manager.cc b/components/precache/content/precache_manager.cc index 2998eb1..f222163 100644 --- a/components/precache/content/precache_manager.cc +++ b/components/precache/content/precache_manager.cc @@ -9,10 +9,13 @@ #include "base/files/file_path.h" #include "base/logging.h" #include "base/metrics/field_trial.h" +#include "base/prefs/pref_service.h" #include "base/time/time.h" +#include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names.h" #include "components/precache/core/precache_database.h" #include "components/precache/core/precache_switches.h" #include "components/precache/core/url_list_provider.h" +#include "components/user_prefs/user_prefs.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "net/base/network_change_notifier.h" @@ -50,6 +53,16 @@ bool PrecacheManager::IsPrecachingEnabled() { CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePrecache); } +bool PrecacheManager::IsPrecachingAllowed() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +#if defined(SPDY_PROXY_AUTH_ORIGIN) + return user_prefs::UserPrefs::Get(browser_context_)->GetBoolean( + data_reduction_proxy::prefs::kDataReductionProxyEnabled); +#else + return false; +#endif +} + void PrecacheManager::StartPrecaching( const PrecacheCompletionCallback& precache_completion_callback, URLListProvider* url_list_provider) { diff --git a/components/precache/content/precache_manager.h b/components/precache/content/precache_manager.h index 552af2a..e274881 100644 --- a/components/precache/content/precache_manager.h +++ b/components/precache/content/precache_manager.h @@ -49,6 +49,9 @@ class PrecacheManager : public KeyedService, // command line flag. This method can be called on any thread. static bool IsPrecachingEnabled(); + // Returns true if precaching is allowed for the browser context. + bool IsPrecachingAllowed(); + // Starts precaching resources that the user is predicted to fetch in the // future. If precaching is already currently in progress, then this method // does nothing. The |precache_completion_callback| will be run when |