Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: chrome/browser/net/predictor_api.cc

Issue 6720016: Get rid of PrefService::GetMutableDictionary/GetMutableList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/predictor_api.cc
diff --git a/chrome/browser/net/predictor_api.cc b/chrome/browser/net/predictor_api.cc
index 232cb9fffe3ca0795abe9e688b39af67a1709a05..d9434f308337b404efd80c0f90bcb86295b9856d 100644
--- a/chrome/browser/net/predictor_api.cc
+++ b/chrome/browser/net/predictor_api.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/net/url_info.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -407,7 +408,7 @@ static void InitNetworkPredictor(TimeDelta max_dns_queue_delay,
GetPredictedUrlListAtStartup(user_prefs, local_state);
ListValue* referral_list =
- static_cast<ListValue*>(user_prefs->GetMutableList(
+ static_cast<ListValue*>(user_prefs->GetList(
prefs::kDnsPrefetchingHostReferralList)->DeepCopy());
// Remove obsolete preferences from local state if necessary.
@@ -484,12 +485,15 @@ void SavePredictorStateForNextStartupAndTrim(PrefService* prefs) {
base::WaitableEvent completion(true, false);
+ ListPrefUpdate update_startup_list(prefs, prefs::kDnsPrefetchingStartupList);
+ ListPrefUpdate update_referral_list(prefs,
+ prefs::kDnsPrefetchingHostReferralList);
bool posted = BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
NewRunnableFunction(SaveDnsPrefetchStateForNextStartupAndTrimOnIOThread,
- prefs->GetMutableList(prefs::kDnsPrefetchingStartupList),
- prefs->GetMutableList(prefs::kDnsPrefetchingHostReferralList),
+ update_startup_list.Get(),
jar (doing other things) 2011/04/04 19:18:33 This makes very little sense to me. I'm *guessing
jar (doing other things) 2011/04/05 06:18:39 I suspect this may actually be the source of a lar
battre 2011/04/05 14:09:50 I thought about this. I think the code is safe be
jar (doing other things) 2011/04/05 16:03:11 <sigh> Ok... I'm convinced your change is correct
+ update_referral_list.Get(),
&completion));
DCHECK(posted);
@@ -505,11 +509,11 @@ static UrlList GetPredictedUrlListAtStartup(PrefService* user_prefs,
// This may catch secondary hostnames, pulled in by the homepages. It will
// also catch more of the "primary" home pages, since that was (presumably)
// rendered first (and will be rendered first this time too).
- ListValue* startup_list =
- user_prefs->GetMutableList(prefs::kDnsPrefetchingStartupList);
+ const ListValue* startup_list =
+ user_prefs->GetList(prefs::kDnsPrefetchingStartupList);
if (startup_list) {
- ListValue::iterator it = startup_list->begin();
+ ListValue::const_iterator it = startup_list->begin();
int format_version = -1;
if (it != startup_list->end() &&
(*it)->GetAsInteger(&format_version) &&
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698