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

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

Issue 2889663004: [DO NOT COMMIT][Offline Pages] Moving Offline Page Cache to cache directory.
Patch Set: again? Created 3 years, 7 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_CORE_OFFLINE_PAGE_MODEL_IMPL_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_IMPL_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_IMPL_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 class OfflinePageModelQuery; 50 class OfflinePageModelQuery;
51 class OfflinePageStorageManager; 51 class OfflinePageStorageManager;
52 52
53 // Implementation of service for saving pages offline, storing the offline 53 // Implementation of service for saving pages offline, storing the offline
54 // copy and metadata, and retrieving them upon request. 54 // copy and metadata, and retrieving them upon request.
55 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService { 55 class OfflinePageModelImpl : public OfflinePageModel, public KeyedService {
56 public: 56 public:
57 // All blocking calls/disk access will happen on the provided |task_runner|. 57 // All blocking calls/disk access will happen on the provided |task_runner|.
58 OfflinePageModelImpl( 58 OfflinePageModelImpl(
59 std::unique_ptr<OfflinePageMetadataStore> store, 59 std::unique_ptr<OfflinePageMetadataStore> store,
60 const base::FilePath& archives_dir, 60 const ArchiveDirectories& archive_dirs,
61 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 61 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
62 ~OfflinePageModelImpl() override; 62 ~OfflinePageModelImpl() override;
63 63
64 // Implemented methods: 64 // Implemented methods:
65 void AddObserver(Observer* observer) override; 65 void AddObserver(Observer* observer) override;
66 void RemoveObserver(Observer* observer) override; 66 void RemoveObserver(Observer* observer) override;
67 void SavePage(const SavePageParams& save_page_params, 67 void SavePage(const SavePageParams& save_page_params,
68 std::unique_ptr<OfflinePageArchiver> archiver, 68 std::unique_ptr<OfflinePageArchiver> archiver,
69 const SavePageCallback& callback) override; 69 const SavePageCallback& callback) override;
70 void MarkPageAccessed(int64_t offline_id) override; 70 void MarkPageAccessed(int64_t offline_id) override;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Callback completing storage clearing. 238 // Callback completing storage clearing.
239 void OnStorageCleared(size_t cleared_page_count, 239 void OnStorageCleared(size_t cleared_page_count,
240 OfflinePageStorageManager::ClearStorageResult result); 240 OfflinePageStorageManager::ClearStorageResult result);
241 241
242 // Post task to clear storage. 242 // Post task to clear storage.
243 void PostClearStorageIfNeededTask(bool delayed); 243 void PostClearStorageIfNeededTask(bool delayed);
244 244
245 // Check if |offline_page| should be removed on cache reset by user. 245 // Check if |offline_page| should be removed on cache reset by user.
246 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const; 246 bool IsRemovedOnCacheReset(const OfflinePageItem& offline_page) const;
247 247
248 // Get the archive directory based on namespace.
249 const base::FilePath& GetArchiveDirectory(
250 const std::string& name_space) const;
251
248 void RunWhenLoaded(const base::Closure& job); 252 void RunWhenLoaded(const base::Closure& job);
249 253
250 base::Time GetCurrentTime() const; 254 base::Time GetCurrentTime() const;
251 255
252 // Persistent store for offline page metadata. 256 // Persistent store for offline page metadata.
253 std::unique_ptr<OfflinePageMetadataStore> store_; 257 std::unique_ptr<OfflinePageMetadataStore> store_;
254 258
255 // Location where all of the archive files will be stored. 259 // Location where all of the archive files will be stored.
256 base::FilePath archives_dir_; 260 ArchiveDirectories archive_dirs_;
257 261
258 // The observers. 262 // The observers.
259 base::ObserverList<Observer> observers_; 263 base::ObserverList<Observer> observers_;
260 264
261 bool is_loaded_; 265 bool is_loaded_;
262 266
263 // In memory copy of the offline page metadata, keyed by offline IDs. 267 // In memory copy of the offline page metadata, keyed by offline IDs.
264 std::map<int64_t, OfflinePageItem> offline_pages_; 268 std::map<int64_t, OfflinePageItem> offline_pages_;
265 269
266 // Pending archivers owned by this model. 270 // Pending archivers owned by this model.
(...skipping 20 matching lines...) Expand all
287 base::Clock* testing_clock_; 291 base::Clock* testing_clock_;
288 292
289 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_; 293 base::WeakPtrFactory<OfflinePageModelImpl> weak_ptr_factory_;
290 294
291 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl); 295 DISALLOW_COPY_AND_ASSIGN(OfflinePageModelImpl);
292 }; 296 };
293 297
294 } // namespace offline_pages 298 } // namespace offline_pages
295 299
296 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_IMPL_H_ 300 #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_PAGE_MODEL_IMPL_H_
OLDNEW
« no previous file with comments | « components/offline_pages/core/archive_manager_unittest.cc ('k') | components/offline_pages/core/offline_page_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698