| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 12 | 13 |
| 13 class GURL; | 14 class GURL; |
| 14 | 15 |
| 15 namespace offline_pages { | 16 namespace offline_pages { |
| 16 | 17 |
| 17 struct OfflinePageItem; | 18 struct OfflinePageItem; |
| 19 class OfflinePageMetadataStore; |
| 18 | 20 |
| 19 // Serivce for saving pages offline, storing the offline copy and metadata, and | 21 // Serivce for saving pages offline, storing the offline copy and metadata, and |
| 20 // retrieving them upon request. | 22 // retrieving them upon request. |
| 21 class OfflinePageModel : public KeyedService { | 23 class OfflinePageModel : public KeyedService { |
| 22 public: | 24 public: |
| 23 OfflinePageModel(); | 25 OfflinePageModel(); |
| 24 ~OfflinePageModel() override; | 26 ~OfflinePageModel() override; |
| 25 | 27 |
| 26 // KeyedService: | 28 // KeyedService: |
| 27 void Shutdown() override; | 29 void Shutdown() override; |
| 28 | 30 |
| 31 // Initializes the offline page model with a store to use for persisting |
| 32 // offline page metadata. |
| 33 void Initialize(scoped_ptr<OfflinePageMetadataStore> store); |
| 34 |
| 29 // Saves the page loaded in the web contents offline. | 35 // Saves the page loaded in the web contents offline. |
| 30 void SavePageOffline(const GURL& url); | 36 void SavePageOffline(const GURL& url); |
| 31 | 37 |
| 32 // Gets a set of all offline pages metadata. | 38 // Gets a set of all offline pages metadata. |
| 33 std::vector<OfflinePageItem> GetAllOfflinePages(); | 39 std::vector<OfflinePageItem> GetAllOfflinePages(); |
| 34 | 40 |
| 41 // Methods for testing only: |
| 42 OfflinePageMetadataStore* GetStoreForTesting(); |
| 43 |
| 35 private: | 44 private: |
| 45 // Persistent store for offline page metadata. |
| 46 scoped_ptr<OfflinePageMetadataStore> store_; |
| 47 |
| 36 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); | 48 DISALLOW_COPY_AND_ASSIGN(OfflinePageModel); |
| 37 }; | 49 }; |
| 38 | 50 |
| 39 } // namespace offline_pages | 51 } // namespace offline_pages |
| 40 | 52 |
| 41 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ | 53 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_MODEL_H_ |
| OLD | NEW |