| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/ntp/popular_sites.h" | 5 #include "chrome/browser/android/ntp/popular_sites.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 PopularSites::PopularSites(PrefService* prefs, | 189 PopularSites::PopularSites(PrefService* prefs, |
| 190 const TemplateURLService* template_url_service, | 190 const TemplateURLService* template_url_service, |
| 191 VariationsService* variations_service, | 191 VariationsService* variations_service, |
| 192 net::URLRequestContextGetter* download_context, | 192 net::URLRequestContextGetter* download_context, |
| 193 const base::FilePath& directory, | 193 const base::FilePath& directory, |
| 194 const std::string& variation_param_country, | 194 const std::string& variation_param_country, |
| 195 const std::string& variation_param_version, | 195 const std::string& variation_param_version, |
| 196 bool force_download, | 196 bool force_download, |
| 197 const FinishedCallback& callback) | 197 const FinishedCallback& callback) |
| 198 : PopularSites(prefs, | 198 : PopularSites(prefs, |
| 199 template_url_service, | |
| 200 download_context, | 199 download_context, |
| 201 directory, | 200 directory, |
| 202 GetCountryToUse(prefs, | 201 GetCountryToUse(prefs, |
| 203 template_url_service, | 202 template_url_service, |
| 204 variations_service, | 203 variations_service, |
| 205 variation_param_country), | 204 variation_param_country), |
| 206 GetVersionToUse(prefs, variation_param_version), | 205 GetVersionToUse(prefs, variation_param_version), |
| 207 GURL(), | 206 GURL(), |
| 208 force_download, | 207 force_download, |
| 209 callback) {} | 208 callback) {} |
| 210 | 209 |
| 211 PopularSites::PopularSites(PrefService* prefs, | 210 PopularSites::PopularSites(PrefService* prefs, |
| 212 const TemplateURLService* template_url_service, | |
| 213 net::URLRequestContextGetter* download_context, | 211 net::URLRequestContextGetter* download_context, |
| 214 const base::FilePath& directory, | 212 const base::FilePath& directory, |
| 215 const GURL& url, | 213 const GURL& url, |
| 216 const FinishedCallback& callback) | 214 const FinishedCallback& callback) |
| 217 : PopularSites(prefs, | 215 : PopularSites(prefs, |
| 218 template_url_service, | |
| 219 download_context, | 216 download_context, |
| 220 directory, | 217 directory, |
| 221 std::string(), | 218 std::string(), |
| 222 std::string(), | 219 std::string(), |
| 223 url, | 220 url, |
| 224 true, | 221 true, |
| 225 callback) {} | 222 callback) {} |
| 226 | 223 |
| 227 PopularSites::~PopularSites() {} | 224 PopularSites::~PopularSites() {} |
| 228 | 225 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 241 std::string()); | 238 std::string()); |
| 242 user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideVersion, | 239 user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideVersion, |
| 243 std::string()); | 240 std::string()); |
| 244 | 241 |
| 245 user_prefs->RegisterInt64Pref(kPopularSitesLastDownloadPref, 0); | 242 user_prefs->RegisterInt64Pref(kPopularSitesLastDownloadPref, 0); |
| 246 user_prefs->RegisterStringPref(kPopularSitesCountryPref, std::string()); | 243 user_prefs->RegisterStringPref(kPopularSitesCountryPref, std::string()); |
| 247 user_prefs->RegisterStringPref(kPopularSitesVersionPref, std::string()); | 244 user_prefs->RegisterStringPref(kPopularSitesVersionPref, std::string()); |
| 248 } | 245 } |
| 249 | 246 |
| 250 PopularSites::PopularSites(PrefService* prefs, | 247 PopularSites::PopularSites(PrefService* prefs, |
| 251 const TemplateURLService* template_url_service, | |
| 252 net::URLRequestContextGetter* download_context, | 248 net::URLRequestContextGetter* download_context, |
| 253 const base::FilePath& directory, | 249 const base::FilePath& directory, |
| 254 const std::string& country, | 250 const std::string& country, |
| 255 const std::string& version, | 251 const std::string& version, |
| 256 const GURL& override_url, | 252 const GURL& override_url, |
| 257 bool force_download, | 253 bool force_download, |
| 258 const FinishedCallback& callback) | 254 const FinishedCallback& callback) |
| 259 : callback_(callback), | 255 : callback_(callback), |
| 260 is_fallback_(false), | 256 is_fallback_(false), |
| 261 pending_country_(country), | 257 pending_country_(country), |
| 262 pending_version_(version), | 258 pending_version_(version), |
| 263 local_path_(directory.empty() | 259 local_path_(directory.empty() |
| 264 ? base::FilePath() | 260 ? base::FilePath() |
| 265 : directory.AppendASCII(kPopularSitesLocalFilename)), | 261 : directory.AppendASCII(kPopularSitesLocalFilename)), |
| 266 prefs_(prefs), | 262 prefs_(prefs), |
| 267 template_url_service_(template_url_service), | |
| 268 download_context_(download_context), | 263 download_context_(download_context), |
| 269 runner_( | 264 runner_( |
| 270 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 265 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
| 271 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)), | 266 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)), |
| 272 weak_ptr_factory_(this) { | 267 weak_ptr_factory_(this) { |
| 273 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 268 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 274 const base::Time last_download_time = base::Time::FromInternalValue( | 269 const base::Time last_download_time = base::Time::FromInternalValue( |
| 275 prefs_->GetInt64(kPopularSitesLastDownloadPref)); | 270 prefs_->GetInt64(kPopularSitesLastDownloadPref)); |
| 276 const base::TimeDelta time_since_last_download = | 271 const base::TimeDelta time_since_last_download = |
| 277 base::Time::Now() - last_download_time; | 272 base::Time::Now() - last_download_time; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 DLOG(WARNING) << "Download country site list failed"; | 395 DLOG(WARNING) << "Download country site list failed"; |
| 401 is_fallback_ = true; | 396 is_fallback_ = true; |
| 402 pending_country_ = kPopularSitesDefaultCountryCode; | 397 pending_country_ = kPopularSitesDefaultCountryCode; |
| 403 pending_version_ = kPopularSitesDefaultVersion; | 398 pending_version_ = kPopularSitesDefaultVersion; |
| 404 FetchPopularSites(GetPopularSitesURL()); | 399 FetchPopularSites(GetPopularSitesURL()); |
| 405 } else { | 400 } else { |
| 406 DLOG(WARNING) << "Download fallback site list failed"; | 401 DLOG(WARNING) << "Download fallback site list failed"; |
| 407 callback_.Run(false); | 402 callback_.Run(false); |
| 408 } | 403 } |
| 409 } | 404 } |
| OLD | NEW |