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

Side by Side Diff: components/offline_pages/offline_page_model_impl.h

Issue 2185973003: [Offline Pages] Delete associated page along with bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unintended changes. Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 21 matching lines...) Expand all
32 #include "components/offline_pages/offline_page_types.h" 32 #include "components/offline_pages/offline_page_types.h"
33 33
34 class GURL; 34 class GURL;
35 namespace base { 35 namespace base {
36 class SequencedTaskRunner; 36 class SequencedTaskRunner;
37 class Time; 37 class Time;
38 class TimeDelta; 38 class TimeDelta;
39 class TimeTicks; 39 class TimeTicks;
40 } // namespace base 40 } // namespace base
41 41
42 namespace bookmarks {
43 class BookmarkNode;
44 } // namespace bookmarks
45
42 namespace offline_pages { 46 namespace offline_pages {
43 47
44 static const int64_t kInvalidOfflineId = 0; 48 static const int64_t kInvalidOfflineId = 0;
45 49
46 struct ClientId; 50 struct ClientId;
47 struct OfflinePageItem; 51 struct OfflinePageItem;
48 52
49 class ArchiveManager; 53 class ArchiveManager;
50 class ClientPolicyController; 54 class ClientPolicyController;
55 class OfflinePageBookmarkObserver;
51 class OfflinePageMetadataStore; 56 class OfflinePageMetadataStore;
52 class OfflinePageStorageManager; 57 class OfflinePageStorageManager;
53 58
54 // Implementation of service for saving pages offline, storing the offline 59 // Implementation of service for saving pages offline, storing the offline
55 // copy and metadata, and retrieving them upon request. 60 // copy and metadata, and retrieving them upon request.
56 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { 61 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService {
57 public: 62 public:
58 // All blocking calls/disk access will happen on the provided |task_runner|. 63 // All blocking calls/disk access will happen on the provided |task_runner|.
59 OfflinePageModelImpl( 64 OfflinePageModelImpl(
60 std::unique_ptr<OfflinePageMetadataStore> store, 65 std::unique_ptr<OfflinePageMetadataStore> store,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const MultipleOfflinePageItemCallback& callback) override; 108 const MultipleOfflinePageItemCallback& callback) override;
104 void GetBestPageForOnlineURL( 109 void GetBestPageForOnlineURL(
105 const GURL& online_url, 110 const GURL& online_url,
106 const SingleOfflinePageItemCallback callback) override; 111 const SingleOfflinePageItemCallback callback) override;
107 const OfflinePageItem* MaybeGetBestPageForOnlineURL( 112 const OfflinePageItem* MaybeGetBestPageForOnlineURL(
108 const GURL& online_url) const override; 113 const GURL& online_url) const override;
109 void CheckMetadataConsistency() override; 114 void CheckMetadataConsistency() override;
110 void ExpirePages(const std::vector<int64_t>& offline_ids, 115 void ExpirePages(const std::vector<int64_t>& offline_ids,
111 const base::Time& expiration_time, 116 const base::Time& expiration_time,
112 const base::Callback<void(bool)>& callback) override; 117 const base::Callback<void(bool)>& callback) override;
118 void ExpireRemovedBookmarkPage(const bookmarks::BookmarkNode* node) override;
119 OfflinePageBookmarkObserver* GetBookmarkObserver() override;
113 ClientPolicyController* GetPolicyController() override; 120 ClientPolicyController* GetPolicyController() override;
114 121
115 // Methods for testing only: 122 // Methods for testing only:
116 OfflinePageMetadataStore* GetStoreForTesting(); 123 OfflinePageMetadataStore* GetStoreForTesting();
117 124
118 OfflinePageStorageManager* GetStorageManager(); 125 OfflinePageStorageManager* GetStorageManager();
119 126
120 bool is_loaded() const override; 127 bool is_loaded() const override;
121 128
122 OfflineEventLogger* GetLogger() override; 129 OfflineEventLogger* GetLogger() override;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void ClearStorageIfNeeded( 264 void ClearStorageIfNeeded(
258 const OfflinePageStorageManager::ClearStorageCallback& callback); 265 const OfflinePageStorageManager::ClearStorageCallback& callback);
259 266
260 // Callback completing storage clearing. 267 // Callback completing storage clearing.
261 void OnStorageCleared(size_t expired_page_count, 268 void OnStorageCleared(size_t expired_page_count,
262 OfflinePageStorageManager::ClearStorageResult result); 269 OfflinePageStorageManager::ClearStorageResult result);
263 270
264 // Post task to clear storage. 271 // Post task to clear storage.
265 void PostClearStorageIfNeededTask(); 272 void PostClearStorageIfNeededTask();
266 273
274 // Expire associate pages when a bookmark gets deleted.
275 void DoExpireRemovedBookmarkPages(const std::vector<int64_t>& offline_ids);
276 void OnRemovedBookmarkPagesExpired(bool result);
277
267 void RunWhenLoaded(const base::Closure& job); 278 void RunWhenLoaded(const base::Closure& job);
268 279
269 // Persistent store for offline page metadata. 280 // Persistent store for offline page metadata.
270 std::unique_ptr<OfflinePageMetadataStore> store_; 281 std::unique_ptr<OfflinePageMetadataStore> store_;
271 282
272 // Location where all of the archive files will be stored. 283 // Location where all of the archive files will be stored.
273 base::FilePath archives_dir_; 284 base::FilePath archives_dir_;
274 285
275 // The observers. 286 // The observers.
276 base::ObserverList<Observer> observers_; 287 base::ObserverList<Observer> observers_;
(...skipping 12 matching lines...) Expand all
289 // Controller of the client policies. 300 // Controller of the client policies.
290 std::unique_ptr<ClientPolicyController> policy_controller_; 301 std::unique_ptr<ClientPolicyController> policy_controller_;
291 302
292 // Manager for the storage consumed by archives and responsible for 303 // Manager for the storage consumed by archives and responsible for
293 // automatic page clearing. 304 // automatic page clearing.
294 std::unique_ptr<OfflinePageStorageManager> storage_manager_; 305 std::unique_ptr<OfflinePageStorageManager> storage_manager_;
295 306
296 // Manager for the offline archive files and directory. 307 // Manager for the offline archive files and directory.
297 std::unique_ptr<ArchiveManager> archive_manager_; 308 std::unique_ptr<ArchiveManager> archive_manager_;
298 309
310 // Observer listening events from bookmark model.
311 std::unique_ptr<OfflinePageBookmarkObserver> bookmark_observer_;
312
299 // Logger to facilitate recording of events. 313 // Logger to facilitate recording of events.
300 OfflinePageModelEventLogger offline_event_logger_; 314 OfflinePageModelEventLogger offline_event_logger_;
301 315
302 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; 316 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_;
303 317
304 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); 318 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl);
305 }; 319 };
306 320
307 } // namespace offline_pages 321 } // namespace offline_pages
308 322
309 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_ 323 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698