OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/reading_list/reading_list_download_service.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_download_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void ReadingListDownloadService::RemoveDownloadedEntry(const GURL& url) { | 226 void ReadingListDownloadService::RemoveDownloadedEntry(const GURL& url) { |
227 DCHECK(reading_list_model_->loaded()); | 227 DCHECK(reading_list_model_->loaded()); |
228 url_downloader_->RemoveOfflineURL(url); | 228 url_downloader_->RemoveOfflineURL(url); |
229 } | 229 } |
230 | 230 |
231 void ReadingListDownloadService::OnDownloadEnd( | 231 void ReadingListDownloadService::OnDownloadEnd( |
232 const GURL& url, | 232 const GURL& url, |
233 const GURL& distilled_url, | 233 const GURL& distilled_url, |
234 URLDownloader::SuccessState success, | 234 URLDownloader::SuccessState success, |
235 const base::FilePath& distilled_path, | 235 const base::FilePath& distilled_path, |
| 236 int64_t size, |
236 const std::string& title) { | 237 const std::string& title) { |
237 DCHECK(reading_list_model_->loaded()); | 238 DCHECK(reading_list_model_->loaded()); |
238 URLDownloader::SuccessState real_success_value = success; | 239 URLDownloader::SuccessState real_success_value = success; |
239 if (distilled_path.empty()) { | 240 if (distilled_path.empty()) { |
240 real_success_value = URLDownloader::ERROR; | 241 real_success_value = URLDownloader::ERROR; |
241 } | 242 } |
242 switch (real_success_value) { | 243 switch (real_success_value) { |
243 case URLDownloader::DOWNLOAD_SUCCESS: | 244 case URLDownloader::DOWNLOAD_SUCCESS: |
244 case URLDownloader::DOWNLOAD_EXISTS: { | 245 case URLDownloader::DOWNLOAD_EXISTS: { |
| 246 int64_t now = |
| 247 (base::Time::Now() - base::Time::UnixEpoch()).InMicroseconds(); |
245 reading_list_model_->SetEntryDistilledInfo(url, distilled_path, | 248 reading_list_model_->SetEntryDistilledInfo(url, distilled_path, |
246 distilled_url); | 249 distilled_url, size, now); |
247 | 250 |
248 std::string trimmed_title = base::CollapseWhitespaceASCII(title, false); | 251 std::string trimmed_title = base::CollapseWhitespaceASCII(title, false); |
249 if (!trimmed_title.empty()) | 252 if (!trimmed_title.empty()) |
250 reading_list_model_->SetEntryTitle(url, trimmed_title); | 253 reading_list_model_->SetEntryTitle(url, trimmed_title); |
251 | 254 |
252 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); | 255 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); |
253 if (entry) | 256 if (entry) |
254 UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures", | 257 UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures", |
255 entry->FailedDownloadCounter()); | 258 entry->FailedDownloadCounter()); |
256 UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", SUCCESS, | 259 UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", SUCCESS, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 for (auto& url : url_to_download_cellular_) { | 297 for (auto& url : url_to_download_cellular_) { |
295 ScheduleDownloadEntry(url); | 298 ScheduleDownloadEntry(url); |
296 } | 299 } |
297 } | 300 } |
298 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) { | 301 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) { |
299 for (auto& url : url_to_download_wifi_) { | 302 for (auto& url : url_to_download_wifi_) { |
300 ScheduleDownloadEntry(url); | 303 ScheduleDownloadEntry(url); |
301 } | 304 } |
302 } | 305 } |
303 } | 306 } |
OLD | NEW |