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: { |
245 reading_list_model_->SetEntryDistilledInfo(url, distilled_path, | 246 reading_list_model_->SetEntryDistilledInfo(url, distilled_path, |
246 distilled_url); | 247 distilled_url, size); |
247 | 248 |
248 std::string trimmed_title = base::CollapseWhitespaceASCII(title, false); | 249 std::string trimmed_title = base::CollapseWhitespaceASCII(title, false); |
249 if (!trimmed_title.empty()) | 250 if (!trimmed_title.empty()) |
250 reading_list_model_->SetEntryTitle(url, trimmed_title); | 251 reading_list_model_->SetEntryTitle(url, trimmed_title); |
251 | 252 |
252 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); | 253 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); |
253 if (entry) | 254 if (entry) |
254 UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures", | 255 UMA_HISTOGRAM_COUNTS_100("ReadingList.Download.Failures", |
255 entry->FailedDownloadCounter()); | 256 entry->FailedDownloadCounter()); |
256 UMA_HISTOGRAM_ENUMERATION("ReadingList.Download.Status", SUCCESS, | 257 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_) { | 295 for (auto& url : url_to_download_cellular_) { |
295 ScheduleDownloadEntry(url); | 296 ScheduleDownloadEntry(url); |
296 } | 297 } |
297 } | 298 } |
298 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) { | 299 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) { |
299 for (auto& url : url_to_download_wifi_) { | 300 for (auto& url : url_to_download_wifi_) { |
300 ScheduleDownloadEntry(url); | 301 ScheduleDownloadEntry(url); |
301 } | 302 } |
302 } | 303 } |
303 } | 304 } |
OLD | NEW |