diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 16:08:52 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 16:08:52 +0000 |
commit | 81bb1092f354f3cb3c597ab3c9ed568905078e49 (patch) | |
tree | 7e8c5f324f49fc7302e6f1ee742c39169340e03f /chrome/browser/web_resource/web_resource_service.cc | |
parent | 96dcc176c46003af0176f0f4772affc741aa772a (diff) | |
download | chromium_src-81bb1092f354f3cb3c597ab3c9ed568905078e49.zip chromium_src-81bb1092f354f3cb3c597ab3c9ed568905078e49.tar.gz chromium_src-81bb1092f354f3cb3c597ab3c9ed568905078e49.tar.bz2 |
Detach the PromoResourceService and WebResourceService from the Profile; have them store web resource data in local state instead.
We don't need multiple services for different Profiles; instead, there is a single service that captures data in local_state. The only preference stored in the Profile about the promo will be a bool indicating whether it's been closed or not, which will now be set outside the service.
Reviewers:
arv for general changes to PromoResourceService, & unittest.
erg for pulling the service out of the Profile and serving it up as a Singleton.
zmo for the changes I made to gpu_data_manager.
jstritar FYI, for changes to the PromoResourceService.
BUG=77155
TEST=promo resource service unittests.
Review URL: http://codereview.chromium.org/6736028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource/web_resource_service.cc')
-rw-r--r-- | chrome/browser/web_resource/web_resource_service.cc | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc index 717c850..27118ac 100644 --- a/chrome/browser/web_resource/web_resource_service.cc +++ b/chrome/browser/web_resource/web_resource_service.cc @@ -14,7 +14,6 @@ #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" @@ -67,13 +66,12 @@ class WebResourceService::WebResourceFetcher url_fetcher_.reset(new URLFetcher(GURL( web_resource_server), URLFetcher::GET, this)); - // Do not let url fetcher affect existing state in profile (by setting - // cookies, for example. + // Do not let url fetcher affect existing state (by setting cookies, for + // example). url_fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SAVE_COOKIES); - net::URLRequestContextGetter* url_request_context_getter = - web_resource_service_->profile_->GetRequestContext(); - url_fetcher_->set_request_context(url_request_context_getter); + url_fetcher_->set_request_context( + g_browser_process->system_request_context()); url_fetcher_->Start(); } @@ -197,17 +195,13 @@ class WebResourceService::UnpackerClient }; WebResourceService::WebResourceService( - Profile* profile, - PrefService* prefs, const char* web_resource_server, bool apply_locale_to_url, NotificationType::Type notification_type, const char* last_update_time_pref_name, int start_fetch_delay, int cache_update_delay) - : prefs_(prefs), - profile_(profile), - ALLOW_THIS_IN_INITIALIZER_LIST(service_factory_(this)), + : ALLOW_THIS_IN_INITIALIZER_LIST(service_factory_(this)), in_fetch_(false), web_resource_server_(web_resource_server), apply_locale_to_url_(apply_locale_to_url), @@ -216,9 +210,9 @@ WebResourceService::WebResourceService( start_fetch_delay_(start_fetch_delay), cache_update_delay_(cache_update_delay), web_resource_update_scheduled_(false) { - DCHECK(prefs); - DCHECK(profile); - prefs_->RegisterStringPref(last_update_time_pref_name, "0"); + PrefService* local_state = g_browser_process->local_state(); + DCHECK(local_state); + local_state->RegisterStringPref(last_update_time_pref_name, "0"); resource_dispatcher_host_ = g_browser_process->resource_dispatcher_host(); web_resource_fetcher_.reset(new WebResourceFetcher(this)); } @@ -262,9 +256,10 @@ void WebResourceService::StartAfterDelay() { int64 delay = start_fetch_delay_; // Check whether we have ever put a value in the web resource cache; // if so, pull it out and see if it's time to update again. - if (prefs_->HasPrefPath(last_update_time_pref_name_)) { + PrefService* local_state = g_browser_process->local_state(); + if (local_state->HasPrefPath(last_update_time_pref_name_)) { std::string last_update_pref = - prefs_->GetString(last_update_time_pref_name_); + local_state->GetString(last_update_time_pref_name_); if (!last_update_pref.empty()) { double last_update_value; base::StringToDouble(last_update_pref, &last_update_value); @@ -285,6 +280,6 @@ void WebResourceService::UpdateResourceCache(const std::string& json_data) { client->Start(); // Set cache update time in preferences. - prefs_->SetString(last_update_time_pref_name_, + g_browser_process->local_state()->SetString(last_update_time_pref_name_, base::DoubleToString(base::Time::Now().ToDoubleT())); } |