Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/offline_pages/offline_page_bookmark_observer.h" | |
| 6 | |
| 7 #include "chrome/browser/profiles/profile.h" | |
| 8 #include "components/bookmarks/browser/bookmark_node.h" | |
| 9 #include "components/offline_pages/client_namespace_constants.h" | |
| 10 #include "components/offline_pages/offline_page_model.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace offline_pages { | |
| 14 | |
| 15 OfflinePageBookmarkObserver::OfflinePageBookmarkObserver(Profile* profile) | |
|
Dmitry Titov
2016/08/26 23:08:58
I'd use BrowserContext* instead of Profile* here,
romax
2016/08/29 22:58:02
Done.
| |
| 16 : profile_(profile), offline_page_model_(nullptr) {} | |
| 17 | |
| 18 void OfflinePageBookmarkObserver::BookmarkNodeRemoved( | |
| 19 bookmarks::BookmarkModel* model, | |
| 20 const bookmarks::BookmarkNode* parent, | |
| 21 int old_index, | |
| 22 const bookmarks::BookmarkNode* node, | |
| 23 const std::set<GURL>& removed_urls) { | |
| 24 if (!offline_page_model_) { | |
| 25 offline_page_model_ = | |
| 26 OfflinePageModelFactory::GetForBrowserContext(profile_); | |
| 27 } | |
| 28 ClientId client_id = ClientId(kBookmarkNamespace, std::to_string(node->id())); | |
| 29 offline_page_model_->GetOfflineIdsForClientId( | |
| 30 client_id, | |
| 31 base::Bind(&OfflinePageBookmarkObserver::DoExpireRemovedBookmarkPages, | |
| 32 base::Unretained(this))); | |
|
Dmitry Titov
2016/08/26 23:08:59
Using unretained seems dangerous. What if this ins
romax
2016/08/29 22:58:02
Done.
| |
| 33 } | |
| 34 | |
| 35 void OfflinePageBookmarkObserver::DoExpireRemovedBookmarkPages( | |
| 36 const MultipleOfflineIdResult& offline_ids) { | |
| 37 offline_page_model_->ExpirePages( | |
| 38 offline_ids, base::Time::Now(), | |
| 39 base::Bind(&OfflinePageBookmarkObserver::OnExpireRemovedBookmarkPagesDone, | |
| 40 base::Unretained(this))); | |
|
Dmitry Titov
2016/08/26 23:08:59
Same here (unretained)
romax
2016/08/29 22:58:02
Done.
| |
| 41 } | |
| 42 | |
| 43 void OfflinePageBookmarkObserver::OnExpireRemovedBookmarkPagesDone( | |
| 44 bool result) {} | |
| 45 | |
| 46 } // namespace offline_pages | |
| OLD | NEW |