| OLD | NEW |
| 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return; | 470 return; |
| 471 } | 471 } |
| 472 MarkPageForDeletion(node->id(), base::Bind(&EmptyDeleteCallback)); | 472 MarkPageForDeletion(node->id(), base::Bind(&EmptyDeleteCallback)); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void OfflinePageModel::BookmarkNodeChanged( | 475 void OfflinePageModel::BookmarkNodeChanged( |
| 476 bookmarks::BookmarkModel* model, | 476 bookmarks::BookmarkModel* model, |
| 477 const bookmarks::BookmarkNode* node) { | 477 const bookmarks::BookmarkNode* node) { |
| 478 // BookmarkNodeChanged could be triggered if title or URL gets changed. If | 478 // BookmarkNodeChanged could be triggered if title or URL gets changed. If |
| 479 // the latter, we need to invalidate the offline copy. | 479 // the latter, we need to invalidate the offline copy. |
| 480 DCHECK(offline_pages_.count(node->id()) > 0); | 480 auto iter = offline_pages_.find(node->id()); |
| 481 if (offline_pages_[node->id()].url != node->url()) | 481 if (iter != offline_pages_.end() && iter->second.url != node->url()) |
| 482 DeletePageByBookmarkId(node->id(), DeletePageCallback()); | 482 DeletePageByBookmarkId(node->id(), DeletePageCallback()); |
| 483 } | 483 } |
| 484 | 484 |
| 485 void OfflinePageModel::OnEnsureArchivesDirCreatedDone() { | 485 void OfflinePageModel::OnEnsureArchivesDirCreatedDone() { |
| 486 store_->Load(base::Bind(&OfflinePageModel::OnLoadDone, | 486 store_->Load(base::Bind(&OfflinePageModel::OnLoadDone, |
| 487 weak_ptr_factory_.GetWeakPtr())); | 487 weak_ptr_factory_.GetWeakPtr())); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void OfflinePageModel::OnLoadDone( | 490 void OfflinePageModel::OnLoadDone( |
| 491 OfflinePageMetadataStore::LoadStatus load_status, | 491 OfflinePageMetadataStore::LoadStatus load_status, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 } | 674 } |
| 675 | 675 |
| 676 void OfflinePageModel::CacheLoadedData( | 676 void OfflinePageModel::CacheLoadedData( |
| 677 const std::vector<OfflinePageItem>& offline_pages) { | 677 const std::vector<OfflinePageItem>& offline_pages) { |
| 678 offline_pages_.clear(); | 678 offline_pages_.clear(); |
| 679 for (const auto& offline_page : offline_pages) | 679 for (const auto& offline_page : offline_pages) |
| 680 offline_pages_[offline_page.bookmark_id] = offline_page; | 680 offline_pages_[offline_page.bookmark_id] = offline_page; |
| 681 } | 681 } |
| 682 | 682 |
| 683 } // namespace offline_pages | 683 } // namespace offline_pages |
| OLD | NEW |