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

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 1764843003: Enable offline pages feature on trunk by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/offline_page_feature.cc ('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 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 "components/offline_pages/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 for (const auto& id_page_pair : offline_pages_) 277 for (const auto& id_page_pair : offline_pages_)
278 bookmark_ids.push_back(id_page_pair.first); 278 bookmark_ids.push_back(id_page_pair.first);
279 DeletePagesByBookmarkId( 279 DeletePagesByBookmarkId(
280 bookmark_ids, 280 bookmark_ids,
281 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll, 281 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
282 weak_ptr_factory_.GetWeakPtr(), 282 weak_ptr_factory_.GetWeakPtr(),
283 callback)); 283 callback));
284 } 284 }
285 285
286 bool OfflinePageModel::HasOfflinePages() const { 286 bool OfflinePageModel::HasOfflinePages() const {
287 DCHECK(is_loaded_); 287 // Since offline pages feature is enabled by default,
288 // NetErrorTabHelper::SetHasOfflinePages might call this before the model is
289 // fully loaded. If so, just bail out since this is most likely due to tests.
Dmitry Titov 2016/03/04 01:33:10 lets change the comment as discussed.
jianli 2016/03/04 02:01:07 Done.
290 if (!is_loaded_)
291 return false;
292
288 // Check that at least one page is not marked for deletion. Because we have 293 // Check that at least one page is not marked for deletion. Because we have
289 // pages marked for deletion, we cannot simply invert result of |empty()|. 294 // pages marked for deletion, we cannot simply invert result of |empty()|.
290 for (const auto& id_page_pair : offline_pages_) { 295 for (const auto& id_page_pair : offline_pages_) {
291 if (!id_page_pair.second.IsMarkedForDeletion()) 296 if (!id_page_pair.second.IsMarkedForDeletion())
292 return true; 297 return true;
293 } 298 }
294 return false; 299 return false;
295 } 300 }
296 301
297 const std::vector<OfflinePageItem> OfflinePageModel::GetAllPages() const { 302 const std::vector<OfflinePageItem> OfflinePageModel::GetAllPages() const {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 736 }
732 737
733 void OfflinePageModel::CacheLoadedData( 738 void OfflinePageModel::CacheLoadedData(
734 const std::vector<OfflinePageItem>& offline_pages) { 739 const std::vector<OfflinePageItem>& offline_pages) {
735 offline_pages_.clear(); 740 offline_pages_.clear();
736 for (const auto& offline_page : offline_pages) 741 for (const auto& offline_page : offline_pages)
737 offline_pages_[offline_page.bookmark_id] = offline_page; 742 offline_pages_[offline_page.bookmark_id] = offline_page;
738 } 743 }
739 744
740 } // namespace offline_pages 745 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_feature.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698