Chromium Code Reviews| 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 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 class TimeDelta; | 35 class TimeDelta; |
| 36 class TimeTicks; | 36 class TimeTicks; |
| 37 } // namespace base | 37 } // namespace base |
| 38 | 38 |
| 39 namespace offline_pages { | 39 namespace offline_pages { |
| 40 | 40 |
| 41 static const char* const kBookmarkNamespace = "bookmark"; | 41 static const char* const kBookmarkNamespace = "bookmark"; |
| 42 static const int64_t kInvalidOfflineId = 0; | 42 static const int64_t kInvalidOfflineId = 0; |
| 43 | 43 |
| 44 struct ClientId; | 44 struct ClientId; |
| 45 struct OfflinePageItem; | |
| 45 | 46 |
| 47 class ArchiveManager; | |
| 46 class ClientPolicyController; | 48 class ClientPolicyController; |
| 47 struct OfflinePageItem; | |
| 48 class OfflinePageMetadataStore; | 49 class OfflinePageMetadataStore; |
| 49 class OfflinePageStorageManager; | 50 class OfflinePageStorageManager; |
| 50 | 51 |
| 51 // Service for saving pages offline, storing the offline copy and metadata, and | 52 // Service for saving pages offline, storing the offline copy and metadata, and |
| 52 // retrieving them upon request. | 53 // retrieving them upon request. |
| 53 // | 54 // |
| 54 // Example usage: | 55 // Example usage: |
| 55 // class ArchiverImpl : public OfflinePageArchiver { | 56 // class ArchiverImpl : public OfflinePageArchiver { |
| 56 // // This is a class that knows how to create archiver | 57 // // This is a class that knows how to create archiver |
| 57 // void CreateArchiver(...) override; | 58 // void CreateArchiver(...) override; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 const OfflinePageItem& offline_page, | 293 const OfflinePageItem& offline_page, |
| 293 bool success); | 294 bool success); |
| 294 void InformSavePageDone(const SavePageCallback& callback, | 295 void InformSavePageDone(const SavePageCallback& callback, |
| 295 SavePageResult result, | 296 SavePageResult result, |
| 296 int64_t offline_id); | 297 int64_t offline_id); |
| 297 void DeletePendingArchiver(OfflinePageArchiver* archiver); | 298 void DeletePendingArchiver(OfflinePageArchiver* archiver); |
| 298 | 299 |
| 299 // Steps for deleting files and data for an offline page. | 300 // Steps for deleting files and data for an offline page. |
| 300 void OnDeleteArchiveFilesDone(const std::vector<int64_t>& offline_ids, | 301 void OnDeleteArchiveFilesDone(const std::vector<int64_t>& offline_ids, |
| 301 const DeletePageCallback& callback, | 302 const DeletePageCallback& callback, |
| 302 const bool* success); | 303 bool success); |
| 303 void OnRemoveOfflinePagesDone(const std::vector<int64_t>& offline_ids, | 304 void OnRemoveOfflinePagesDone(const std::vector<int64_t>& offline_ids, |
| 304 const DeletePageCallback& callback, | 305 const DeletePageCallback& callback, |
| 305 bool success); | 306 bool success); |
| 306 void InformDeletePageDone(const DeletePageCallback& callback, | 307 void InformDeletePageDone(const DeletePageCallback& callback, |
| 307 DeletePageResult result); | 308 DeletePageResult result); |
| 308 | 309 |
| 309 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, | 310 void OnMarkPageAccesseDone(const OfflinePageItem& offline_page_item, |
| 310 bool success); | 311 bool success); |
| 311 | 312 |
| 312 // Callbacks for checking if offline pages are missing archive files. | 313 // Callbacks for checking if offline pages are missing archive files. |
| 313 void OnFindPagesMissingArchiveFile( | 314 void ScanForMissingArchivePaths( |
| 314 const std::vector<int64_t>* ids_of_pages_missing_archive_file); | 315 const std::set<base::FilePath>& archive_paths); |
| 315 void OnRemoveOfflinePagesMissingArchiveFileDone( | 316 void OnRemoveOfflinePagesMissingArchiveFileDone( |
| 316 const std::vector<std::pair<int64_t, ClientId>>& offline_client_id_pairs, | 317 const std::vector<std::pair<int64_t, ClientId>>& offline_client_id_pairs, |
| 317 DeletePageResult result); | 318 DeletePageResult result); |
| 318 | 319 |
| 319 // Steps for clearing all. | 320 // Steps for clearing all. |
| 320 void OnRemoveAllFilesDoneForClearAll(const base::Closure& callback, | 321 void OnRemoveAllFilesDoneForClearAll(const base::Closure& callback, |
| 321 DeletePageResult result); | 322 DeletePageResult result); |
| 322 void OnResetStoreDoneForClearAll(const base::Closure& callback, bool success); | 323 void OnResetStoreDoneForClearAll(const base::Closure& callback, bool success); |
| 323 void OnReloadStoreDoneForClearAll( | 324 void OnReloadStoreDoneForClearAll( |
| 324 const base::Closure& callback, | 325 const base::Closure& callback, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 345 base::FilePath archives_dir_; | 346 base::FilePath archives_dir_; |
| 346 | 347 |
| 347 // The observers. | 348 // The observers. |
| 348 base::ObserverList<Observer> observers_; | 349 base::ObserverList<Observer> observers_; |
| 349 | 350 |
| 350 bool is_loaded_; | 351 bool is_loaded_; |
| 351 | 352 |
| 352 // In memory copy of the offline page metadata, keyed by bookmark IDs. | 353 // In memory copy of the offline page metadata, keyed by bookmark IDs. |
| 353 std::map<int64_t, OfflinePageItem> offline_pages_; | 354 std::map<int64_t, OfflinePageItem> offline_pages_; |
| 354 | 355 |
| 355 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
| 356 | |
| 357 // Pending archivers owned by this model. | 356 // Pending archivers owned by this model. |
| 358 PendingArchivers pending_archivers_; | 357 PendingArchivers pending_archivers_; |
| 359 | 358 |
| 360 // Delayed tasks that should be invoked after the loading is done. | 359 // Delayed tasks that should be invoked after the loading is done. |
| 361 std::vector<base::Closure> delayed_tasks_; | 360 std::vector<base::Closure> delayed_tasks_; |
| 362 | 361 |
| 363 // Controller of the client policies. | 362 // Controller of the client policies. |
| 364 std::unique_ptr<ClientPolicyController> policy_controller_; | 363 std::unique_ptr<ClientPolicyController> policy_controller_; |
| 365 | 364 |
| 366 // Manager for the storage consumed by archives and responsible for | 365 // Manager for the storage consumed by archives and responsible for |
| 367 // automatic page clearing. | 366 // automatic page clearing. |
| 368 std::unique_ptr<OfflinePageStorageManager> storage_manager_; | 367 std::unique_ptr<OfflinePageStorageManager> storage_manager_; |
| 369 | 368 |
| 369 // Manager for the offline archive files and directory, where these files are | |
|
jianli
2016/05/17 21:48:13
I think you can skip "directory, where ..." in the
fgorski
2016/05/17 22:50:29
Done.
| |
| 370 // stored. | |
| 371 std::unique_ptr<ArchiveManager> archive_manager_; | |
| 372 | |
| 370 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; | 373 base::WeakPtrFactory<OfflinePageModel> weak_ptr_factory_; |
| 371 | 374 |
| 372 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 375 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 373 }; | 376 }; |
| 374 | 377 |
| 375 } // namespace offline_pages | 378 } // namespace offline_pages |
| 376 | 379 |
| 377 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 380 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |