| 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(); | 52 ~OfflinePageItem(); |
| 39 | 53 |
| 40 // Gets a URL of the file under |file_path|. | 54 // Gets a URL of the file under |file_path|. |
| 41 GURL GetOfflineURL() const; | 55 GURL GetOfflineURL() const; |
| 42 | 56 |
| 43 // Returns true if the page has been marked for deletion. This allows an undo | 57 // Returns true if the page has been marked for deletion. This allows an undo |
| 44 // in a short time period. After that, the marked page will be deleted. | 58 // in a short time period. After that, the marked page will be deleted. |
| 45 bool IsMarkedForDeletion() const; | 59 bool IsMarkedForDeletion() const; |
| 46 | 60 |
| 47 // Sets/clears the mark for deletion. | 61 // Sets/clears the mark for deletion. |
| 48 void MarkForDeletion(); | 62 void MarkForDeletion(); |
| 49 void ClearMarkForDeletion(); | 63 void ClearMarkForDeletion(); |
| 50 | 64 |
| 51 // The URL of the page. | 65 // The URL of the page. |
| 52 GURL url; | 66 GURL url; |
| 53 // The Bookmark ID related to the offline page. | 67 // The primary key/ID for this page in offline pages internal database. |
| 54 int64_t bookmark_id; | 68 int64_t offline_id; |
| 69 |
| 70 // The Client ID (external) related to the offline page. This is opaque |
| 71 // to our system, but useful for users of offline pages who want to map |
| 72 // their ids to our saved pages. |
| 73 ClientId client_id; |
| 74 |
| 55 // Version of the offline page item. | 75 // Version of the offline page item. |
| 56 int version; | 76 int version; |
| 57 // The file path to the archive with a local copy of the page. | 77 // The file path to the archive with a local copy of the page. |
| 58 base::FilePath file_path; | 78 base::FilePath file_path; |
| 59 // The size of the offline copy. | 79 // The size of the offline copy. |
| 60 int64_t file_size; | 80 int64_t file_size; |
| 61 // The time when the offline archive was created. | 81 // The time when the offline archive was created. |
| 62 base::Time creation_time; | 82 base::Time creation_time; |
| 63 // The time when the offline archive was last accessed. | 83 // The time when the offline archive was last accessed. |
| 64 base::Time last_access_time; | 84 base::Time last_access_time; |
| 65 // Number of times that the offline archive has been accessed. | 85 // Number of times that the offline archive has been accessed. |
| 66 int access_count; | 86 int access_count; |
| 67 // Flags about the state and behavior of the offline page. | 87 // Flags about the state and behavior of the offline page. |
| 68 Flags flags; | 88 Flags flags; |
| 69 }; | 89 }; |
| 70 | 90 |
| 71 } // namespace offline_pages | 91 } // namespace offline_pages |
| 72 | 92 |
| 73 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ | 93 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ |
| OLD | NEW |