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

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: Fix 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. To address this, we need to switch to asynchonous model
290 // (crbug.com/589526). But for now, we just bail out to work around the test
291 // issue.
292 if (!is_loaded_)
293 return false;
294
288 // Check that at least one page is not marked for deletion. Because we have 295 // 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()|. 296 // pages marked for deletion, we cannot simply invert result of |empty()|.
290 for (const auto& id_page_pair : offline_pages_) { 297 for (const auto& id_page_pair : offline_pages_) {
291 if (!id_page_pair.second.IsMarkedForDeletion()) 298 if (!id_page_pair.second.IsMarkedForDeletion())
292 return true; 299 return true;
293 } 300 }
294 return false; 301 return false;
295 } 302 }
296 303
297 const std::vector<OfflinePageItem> OfflinePageModel::GetAllPages() const { 304 const std::vector<OfflinePageItem> OfflinePageModel::GetAllPages() const {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 738 }
732 739
733 void OfflinePageModel::CacheLoadedData( 740 void OfflinePageModel::CacheLoadedData(
734 const std::vector<OfflinePageItem>& offline_pages) { 741 const std::vector<OfflinePageItem>& offline_pages) {
735 offline_pages_.clear(); 742 offline_pages_.clear();
736 for (const auto& offline_page : offline_pages) 743 for (const auto& offline_page : offline_pages)
737 offline_pages_[offline_page.bookmark_id] = offline_page; 744 offline_pages_[offline_page.bookmark_id] = offline_page;
738 } 745 }
739 746
740 } // namespace offline_pages 747 } // 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