| 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_ITEM_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace offline_pages { | 17 namespace offline_pages { |
| 18 | 18 |
| 19 struct ClientId { |
| 20 // The namespace for the id (of course 'namespace' is a reserved word, so...) |
| 21 std::string name_space; |
| 22 // The id in the client's namespace. Opaque to us. |
| 23 std::string id; |
| 24 |
| 25 ClientId(); |
| 26 ClientId(std::string name_space, std::string id); |
| 27 |
| 28 bool operator==(const ClientId& client_id) const; |
| 29 }; |
| 30 |
| 19 // Metadata of the offline page. | 31 // Metadata of the offline page. |
| 20 struct OfflinePageItem { | 32 struct OfflinePageItem { |
| 21 public: | 33 public: |
| 22 // Note that this should match with Flags enum in offline_pages.proto. | 34 // Note that this should match with Flags enum in offline_pages.proto. |
| 23 enum Flags { | 35 enum Flags { |
| 24 NO_FLAG = 0, | 36 NO_FLAG = 0, |
| 25 MARKED_FOR_DELETION = 0x1, | 37 MARKED_FOR_DELETION = 0x1, |
| 26 }; | 38 }; |
| 27 | 39 |
| 28 OfflinePageItem(); | 40 OfflinePageItem(); |
| 29 OfflinePageItem(const GURL& url, | 41 OfflinePageItem(const GURL& url, |
| 30 int64_t bookmark_id, | 42 int64_t offline_id, |
| 43 const ClientId& client_id, |
| 31 const base::FilePath& file_path, | 44 const base::FilePath& file_path, |
| 32 int64_t file_size); | 45 int64_t file_size); |
| 33 OfflinePageItem(const GURL& url, | 46 OfflinePageItem(const GURL& url, |
| 34 int64_t bookmark_id, | 47 int64_t offline_id, |
| 48 const ClientId& client_id, |
| 35 const base::FilePath& file_path, | 49 const base::FilePath& file_path, |
| 36 int64_t file_size, | 50 int64_t file_size, |
| 37 const base::Time& creation_time); | 51 const base::Time& creation_time); |
| 38 OfflinePageItem(const OfflinePageItem& other); | 52 OfflinePageItem(const OfflinePageItem& other); |
| 39 ~OfflinePageItem(); | 53 ~OfflinePageItem(); |
| 40 | 54 |
| 41 // Gets a URL of the file under |file_path|. | 55 // Gets a URL of the file under |file_path|. |
| 42 GURL GetOfflineURL() const; | 56 GURL GetOfflineURL() const; |
| 43 | 57 |
| 44 // Returns true if the page has been marked for deletion. This allows an undo | 58 // Returns true if the page has been marked for deletion. This allows an undo |
| 45 // in a short time period. After that, the marked page will be deleted. | 59 // in a short time period. After that, the marked page will be deleted. |
| 46 bool IsMarkedForDeletion() const; | 60 bool IsMarkedForDeletion() const; |
| 47 | 61 |
| 48 // Sets/clears the mark for deletion. | 62 // Sets/clears the mark for deletion. |
| 49 void MarkForDeletion(); | 63 void MarkForDeletion(); |
| 50 void ClearMarkForDeletion(); | 64 void ClearMarkForDeletion(); |
| 51 | 65 |
| 52 // The URL of the page. | 66 // The URL of the page. |
| 53 GURL url; | 67 GURL url; |
| 54 // The Bookmark ID related to the offline page. | 68 // The primary key/ID for this page in offline pages internal database. |
| 55 int64_t bookmark_id; | 69 int64_t offline_id; |
| 70 |
| 71 // The Client ID (external) related to the offline page. This is opaque |
| 72 // to our system, but useful for users of offline pages who want to map |
| 73 // their ids to our saved pages. |
| 74 ClientId client_id; |
| 75 |
| 56 // Version of the offline page item. | 76 // Version of the offline page item. |
| 57 int version; | 77 int version; |
| 58 // The file path to the archive with a local copy of the page. | 78 // The file path to the archive with a local copy of the page. |
| 59 base::FilePath file_path; | 79 base::FilePath file_path; |
| 60 // The size of the offline copy. | 80 // The size of the offline copy. |
| 61 int64_t file_size; | 81 int64_t file_size; |
| 62 // The time when the offline archive was created. | 82 // The time when the offline archive was created. |
| 63 base::Time creation_time; | 83 base::Time creation_time; |
| 64 // The time when the offline archive was last accessed. | 84 // The time when the offline archive was last accessed. |
| 65 base::Time last_access_time; | 85 base::Time last_access_time; |
| 66 // Number of times that the offline archive has been accessed. | 86 // Number of times that the offline archive has been accessed. |
| 67 int access_count; | 87 int access_count; |
| 68 // Flags about the state and behavior of the offline page. | 88 // Flags about the state and behavior of the offline page. |
| 69 Flags flags; | 89 Flags flags; |
| 70 }; | 90 }; |
| 71 | 91 |
| 72 } // namespace offline_pages | 92 } // namespace offline_pages |
| 73 | 93 |
| 74 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ | 94 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ |
| OLD | NEW |