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

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

Issue 1460413002: [Offline pages] Properly informing observers when offline page is deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | components/offline_pages/offline_page_model_unittest.cc » ('j') | 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 "OfflinePages.DeletePage.LastOpenToCreated", 562 "OfflinePages.DeletePage.LastOpenToCreated",
563 (iter->second.last_access_time - iter->second.creation_time). 563 (iter->second.last_access_time - iter->second.creation_time).
564 InMinutes(), 564 InMinutes(),
565 1, 565 1,
566 base::TimeDelta::FromDays(365).InMinutes(), 566 base::TimeDelta::FromDays(365).InMinutes(),
567 100); 567 100);
568 UMA_HISTOGRAM_MEMORY_KB( 568 UMA_HISTOGRAM_MEMORY_KB(
569 "OfflinePages.DeletePage.PageSize", iter->second.file_size / 1024); 569 "OfflinePages.DeletePage.PageSize", iter->second.file_size / 1024);
570 UMA_HISTOGRAM_COUNTS( 570 UMA_HISTOGRAM_COUNTS(
571 "OfflinePages.DeletePage.AccessCount", iter->second.access_count); 571 "OfflinePages.DeletePage.AccessCount", iter->second.access_count);
572 // If the page is not marked for deletion at this point, the model has not
573 // yet informed the observer that the offline page is deleted.
574 if (!iter->second.IsMarkedForDeletion()) {
575 FOR_EACH_OBSERVER(Observer, observers_,
576 OfflinePageDeleted(iter->second.bookmark_id));
577 }
572 offline_pages_.erase(iter); 578 offline_pages_.erase(iter);
573 } 579 }
574 if (bookmark_ids.size() > 1) { 580 if (bookmark_ids.size() > 1) {
575 UMA_HISTOGRAM_COUNTS( 581 UMA_HISTOGRAM_COUNTS(
576 "OfflinePages.BatchDelete.Count", bookmark_ids.size()); 582 "OfflinePages.BatchDelete.Count", bookmark_ids.size());
577 UMA_HISTOGRAM_MEMORY_KB( 583 UMA_HISTOGRAM_MEMORY_KB(
578 "OfflinePages.BatchDelete.TotalPageSize", total_size / 1024); 584 "OfflinePages.BatchDelete.TotalPageSize", total_size / 1024);
579 } 585 }
580 // Deleting multiple pages always succeeds when it gets to this point. 586 // Deleting multiple pages always succeeds when it gets to this point.
581 InformDeletePageDone( 587 InformDeletePageDone(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 664 }
659 665
660 void OfflinePageModel::CacheLoadedData( 666 void OfflinePageModel::CacheLoadedData(
661 const std::vector<OfflinePageItem>& offline_pages) { 667 const std::vector<OfflinePageItem>& offline_pages) {
662 offline_pages_.clear(); 668 offline_pages_.clear();
663 for (const auto& offline_page : offline_pages) 669 for (const auto& offline_page : offline_pages)
664 offline_pages_[offline_page.bookmark_id] = offline_page; 670 offline_pages_[offline_page.bookmark_id] = offline_page;
665 } 671 }
666 672
667 } // namespace offline_pages 673 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/offline_page_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698