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

Side by Side Diff: components/offline_pages/core/offline_page_model_impl.cc

Issue 2856053003: [Offline pages] Fix order of error checking so URL mismatch would not override other error codes (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « components/offline_pages/core/offline_page_model_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/offline_pages/core/offline_page_model_impl.h" 5 #include "components/offline_pages/core/offline_page_model_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 return &offline_event_logger_; 681 return &offline_event_logger_;
682 } 682 }
683 683
684 void OfflinePageModelImpl::OnCreateArchiveDone( 684 void OfflinePageModelImpl::OnCreateArchiveDone(
685 const SavePageParams& save_page_params, 685 const SavePageParams& save_page_params,
686 int64_t offline_id, 686 int64_t offline_id,
687 const base::Time& start_time, 687 const base::Time& start_time,
688 const SavePageCallback& callback, 688 const SavePageCallback& callback,
689 OfflinePageArchiver* archiver, 689 OfflinePageArchiver* archiver,
690 ArchiverResult archiver_result, 690 ArchiverResult archiver_result,
691 const GURL& url, 691 const GURL& saved_url,
692 const base::FilePath& file_path, 692 const base::FilePath& file_path,
693 const base::string16& title, 693 const base::string16& title,
694 int64_t file_size) { 694 int64_t file_size) {
695 if (save_page_params.url != url) {
696 DVLOG(1) << "Saved URL does not match requested URL.";
697 InformSavePageDone(callback, SavePageResult::ARCHIVE_CREATION_FAILED,
698 save_page_params.client_id, offline_id);
699 DeletePendingArchiver(archiver);
700 return;
701 }
702
703 if (archiver_result != ArchiverResult::SUCCESSFULLY_CREATED) { 695 if (archiver_result != ArchiverResult::SUCCESSFULLY_CREATED) {
704 SavePageResult result = ToSavePageResult(archiver_result); 696 SavePageResult result = ToSavePageResult(archiver_result);
705 InformSavePageDone( 697 InformSavePageDone(
706 callback, result, save_page_params.client_id, offline_id); 698 callback, result, save_page_params.client_id, offline_id);
707 DeletePendingArchiver(archiver); 699 DeletePendingArchiver(archiver);
708 return; 700 return;
709 } 701 }
710 OfflinePageItem offline_page_item(url, offline_id, save_page_params.client_id, 702
711 file_path, file_size, start_time); 703 if (save_page_params.url != saved_url) {
704 DVLOG(1) << "Saved URL does not match requested URL.";
705 InformSavePageDone(callback, SavePageResult::ARCHIVE_CREATION_FAILED,
706 save_page_params.client_id, offline_id);
707 DeletePendingArchiver(archiver);
708 return;
709 }
710
711 OfflinePageItem offline_page_item(saved_url, offline_id,
712 save_page_params.client_id, file_path,
713 file_size, start_time);
712 offline_page_item.title = title; 714 offline_page_item.title = title;
713 offline_page_item.original_url = save_page_params.original_url; 715 offline_page_item.original_url = save_page_params.original_url;
714 store_->AddOfflinePage(offline_page_item, 716 store_->AddOfflinePage(offline_page_item,
715 base::Bind(&OfflinePageModelImpl::OnAddOfflinePageDone, 717 base::Bind(&OfflinePageModelImpl::OnAddOfflinePageDone,
716 weak_ptr_factory_.GetWeakPtr(), archiver, 718 weak_ptr_factory_.GetWeakPtr(), archiver,
717 file_path, callback, offline_page_item)); 719 file_path, callback, offline_page_item));
718 } 720 }
719 721
720 void OfflinePageModelImpl::OnAddOfflinePageDone( 722 void OfflinePageModelImpl::OnAddOfflinePageDone(
721 OfflinePageArchiver* archiver, 723 OfflinePageArchiver* archiver,
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 } 1094 }
1093 1095
1094 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 1096 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
1095 } 1097 }
1096 1098
1097 base::Time OfflinePageModelImpl::GetCurrentTime() const { 1099 base::Time OfflinePageModelImpl::GetCurrentTime() const {
1098 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); 1100 return testing_clock_ ? testing_clock_->Now() : base::Time::Now();
1099 } 1101 }
1100 1102
1101 } // namespace offline_pages 1103 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/core/offline_page_model_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698