Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 9699004: Combine pref migration passes into a single common function, in preparation for adding some more mi… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
21 #include "base/time.h" 21 #include "base/time.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/io_thread.h" 23 #include "chrome/browser/io_thread.h"
24 #include "chrome/browser/net/preconnect.h" 24 #include "chrome/browser/net/preconnect.h"
25 #include "chrome/browser/prefs/browser_prefs.h" 25 #include "chrome/browser/prefs/browser_prefs.h"
willchan no longer on Chromium 2012/03/14 10:05:52 Do we need this #include anymore?
Peter Kasting 2012/03/14 16:29:56 Nope, good catch!
26 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
27 #include "chrome/browser/prefs/scoped_user_pref_update.h" 27 #include "chrome/browser/prefs/scoped_user_pref_update.h"
28 #include "chrome/browser/prefs/session_startup_pref.h" 28 #include "chrome/browser/prefs/session_startup_pref.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "net/base/address_list.h" 32 #include "net/base/address_list.h"
33 #include "net/base/completion_callback.h" 33 #include "net/base/completion_callback.h"
34 #include "net/base/host_port_pair.h" 34 #include "net/base/host_port_pair.h"
35 #include "net/base/host_resolver.h" 35 #include "net/base/host_resolver.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 url_request_context_getter_ = getter; 173 url_request_context_getter_ = getter;
174 174
175 // Gather the list of hostnames to prefetch on startup. 175 // Gather the list of hostnames to prefetch on startup.
176 UrlList urls = GetPredictedUrlListAtStartup(user_prefs, local_state); 176 UrlList urls = GetPredictedUrlListAtStartup(user_prefs, local_state);
177 177
178 base::ListValue* referral_list = 178 base::ListValue* referral_list =
179 static_cast<base::ListValue*>(user_prefs->GetList( 179 static_cast<base::ListValue*>(user_prefs->GetList(
180 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); 180 prefs::kDnsPrefetchingHostReferralList)->DeepCopy());
181 181
182 // Remove obsolete preferences from local state if necessary.
183 int current_version =
184 local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
185 if ((current_version & browser::DNS_PREFS) == 0) {
186 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList,
187 PrefService::UNSYNCABLE_PREF);
188 local_state->RegisterListPref(prefs::kDnsHostReferralList,
189 PrefService::UNSYNCABLE_PREF);
190 local_state->ClearPref(prefs::kDnsStartupPrefetchList);
191 local_state->ClearPref(prefs::kDnsHostReferralList);
192 local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
193 current_version | browser::DNS_PREFS);
194 }
195
196 BrowserThread::PostTask( 182 BrowserThread::PostTask(
197 BrowserThread::IO, 183 BrowserThread::IO,
198 FROM_HERE, 184 FROM_HERE,
199 base::Bind( 185 base::Bind(
200 &Predictor::FinalizeInitializationOnIOThread, 186 &Predictor::FinalizeInitializationOnIOThread,
201 base::Unretained(this), 187 base::Unretained(this),
202 urls, referral_list, 188 urls, referral_list,
203 io_thread, predictor_enabled)); 189 io_thread, predictor_enabled));
204 } 190 }
205 191
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 IOThread* io_thread, 1173 IOThread* io_thread,
1188 net::URLRequestContextGetter* getter) { 1174 net::URLRequestContextGetter* getter) {
1189 // Empty function for unittests. 1175 // Empty function for unittests.
1190 } 1176 }
1191 1177
1192 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { 1178 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) {
1193 SetShutdown(true); 1179 SetShutdown(true);
1194 } 1180 }
1195 1181
1196 } // namespace chrome_browser_net 1182 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698