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

Side by Side Diff: chrome/browser/android/popular_sites.cc

Issue 1340493002: Add initial version of chrome://popular-sites-internals page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@finch_country_version
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/popular_sites.h" 5 #include "chrome/browser/android/popular_sites.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 url(url), 148 url(url),
149 favicon_url(favicon_url), 149 favicon_url(favicon_url),
150 thumbnail_url(thumbnail_url) {} 150 thumbnail_url(thumbnail_url) {}
151 151
152 PopularSites::Site::~Site() {} 152 PopularSites::Site::~Site() {}
153 153
154 PopularSites::PopularSites(Profile* profile, 154 PopularSites::PopularSites(Profile* profile,
155 const std::string& override_country, 155 const std::string& override_country,
156 const std::string& override_version, 156 const std::string& override_version,
157 const std::string& override_filename, 157 const std::string& override_filename,
158 bool force_download,
158 const FinishedCallback& callback) 159 const FinishedCallback& callback)
159 : callback_(callback), weak_ptr_factory_(this) { 160 : callback_(callback), weak_ptr_factory_(this) {
160 base::FilePath path = GetPopularSitesPath(); 161 base::FilePath path = GetPopularSitesPath();
161 // Re-download the file once on every Chrome startup, but use the cached 162 // Re-download the file once on every Chrome startup, but use the cached
162 // local file afterwards. 163 // local file afterwards.
163 static bool overwrite = true; 164 static bool overwrite = true;
Bernhard Bauer 2015/09/11 16:00:05 Given that this does now not directly control anym
Marc Treib 2015/09/22 11:13:56 Done.
164 downloader_.reset(new FileDownloader( 165 downloader_.reset(new FileDownloader(
165 GetPopularSitesURL( 166 GetPopularSitesURL(
166 profile, override_country, override_version, override_filename), 167 profile, override_country, override_version, override_filename),
167 path, overwrite, profile->GetRequestContext(), 168 path, overwrite || force_download, profile->GetRequestContext(),
168 base::Bind(&PopularSites::OnDownloadDone, base::Unretained(this), path))); 169 base::Bind(&PopularSites::OnDownloadDone, base::Unretained(this), path)));
169 overwrite = false; 170 overwrite = false;
170 } 171 }
171 172
172 PopularSites::~PopularSites() {} 173 PopularSites::~PopularSites() {}
173 174
174 void PopularSites::OnDownloadDone(const base::FilePath& path, bool success) { 175 void PopularSites::OnDownloadDone(const base::FilePath& path, bool success) {
175 if (success) { 176 if (success) {
176 base::PostTaskAndReplyWithResult( 177 base::PostTaskAndReplyWithResult(
177 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 178 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
(...skipping 10 matching lines...) Expand all
188 downloader_.reset(); 189 downloader_.reset();
189 } 190 }
190 191
191 void PopularSites::OnJsonParsed(scoped_ptr<std::vector<Site>> sites) { 192 void PopularSites::OnJsonParsed(scoped_ptr<std::vector<Site>> sites) {
192 if (sites) 193 if (sites)
193 sites_.swap(*sites); 194 sites_.swap(*sites);
194 else 195 else
195 sites_.clear(); 196 sites_.clear();
196 callback_.Run(!!sites); 197 callback_.Run(!!sites);
197 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698