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_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 { | |
|
dewittj
2016/02/22 19:23:16
To me this name is a little confusing, it seems li
bburns
2016/02/22 21:02:31
This is the best I could come up with, I'm open to
| |
| 20 // The namespace for the id (of course 'namespace' is a reserved word, so...) | |
| 21 std::string space; | |
|
dewittj
2016/02/22 19:23:16
maybe name_space is a better option here.
bburns
2016/02/22 21:02:31
Done.
| |
| 22 // The id in the client's namespace. Opaque to us. | |
| 23 std::string id; | |
| 24 }; | |
| 25 | |
| 19 // Metadata of the offline page. | 26 // Metadata of the offline page. |
| 20 struct OfflinePageItem { | 27 struct OfflinePageItem { |
| 21 public: | 28 public: |
| 22 // Note that this should match with Flags enum in offline_pages.proto. | 29 // Note that this should match with Flags enum in offline_pages.proto. |
| 23 enum Flags { | 30 enum Flags { |
| 24 NO_FLAG = 0, | 31 NO_FLAG = 0, |
| 25 MARKED_FOR_DELETION = 0x1, | 32 MARKED_FOR_DELETION = 0x1, |
| 26 }; | 33 }; |
| 27 | 34 |
| 28 OfflinePageItem(); | 35 OfflinePageItem(); |
| 29 OfflinePageItem(const GURL& url, | 36 OfflinePageItem(const GURL& url, |
| 30 int64_t bookmark_id, | 37 int64_t offline_id, |
| 38 const ClientId& client_id, | |
| 31 const base::FilePath& file_path, | 39 const base::FilePath& file_path, |
| 32 int64_t file_size); | 40 int64_t file_size); |
| 33 OfflinePageItem(const GURL& url, | 41 OfflinePageItem(const GURL& url, |
| 34 int64_t bookmark_id, | 42 int64_t offline_id, |
| 43 const ClientId& client_id, | |
| 35 const base::FilePath& file_path, | 44 const base::FilePath& file_path, |
| 36 int64_t file_size, | 45 int64_t file_size, |
| 37 const base::Time& creation_time); | 46 const base::Time& creation_time); |
| 38 ~OfflinePageItem(); | 47 ~OfflinePageItem(); |
| 39 | 48 |
| 40 // Gets a URL of the file under |file_path|. | 49 // Gets a URL of the file under |file_path|. |
| 41 GURL GetOfflineURL() const; | 50 GURL GetOfflineURL() const; |
| 42 | 51 |
| 43 // Returns true if the page has been marked for deletion. This allows an undo | 52 // 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. | 53 // in a short time period. After that, the marked page will be deleted. |
| 45 bool IsMarkedForDeletion() const; | 54 bool IsMarkedForDeletion() const; |
| 46 | 55 |
| 47 // Sets/clears the mark for deletion. | 56 // Sets/clears the mark for deletion. |
| 48 void MarkForDeletion(); | 57 void MarkForDeletion(); |
| 49 void ClearMarkForDeletion(); | 58 void ClearMarkForDeletion(); |
| 50 | 59 |
| 51 // The URL of the page. | 60 // The URL of the page. |
| 52 GURL url; | 61 GURL url; |
| 53 // The Bookmark ID related to the offline page. | 62 // The Offline (internal) ID related to the offline page. |
| 54 int64_t bookmark_id; | 63 int64_t offline_id; |
| 64 | |
| 65 // The Client ID (external) related to the offline page. | |
| 66 std::string client_id_namespace; | |
|
dewittj
2016/02/22 19:23:16
if you rename ClientId.space -> ClientId.name_spac
bburns
2016/02/22 21:02:31
Done.
| |
| 67 std::string client_id; | |
| 68 | |
| 55 // Version of the offline page item. | 69 // Version of the offline page item. |
| 56 int version; | 70 int version; |
| 57 // The file path to the archive with a local copy of the page. | 71 // The file path to the archive with a local copy of the page. |
| 58 base::FilePath file_path; | 72 base::FilePath file_path; |
| 59 // The size of the offline copy. | 73 // The size of the offline copy. |
| 60 int64_t file_size; | 74 int64_t file_size; |
| 61 // The time when the offline archive was created. | 75 // The time when the offline archive was created. |
| 62 base::Time creation_time; | 76 base::Time creation_time; |
| 63 // The time when the offline archive was last accessed. | 77 // The time when the offline archive was last accessed. |
| 64 base::Time last_access_time; | 78 base::Time last_access_time; |
| 65 // Number of times that the offline archive has been accessed. | 79 // Number of times that the offline archive has been accessed. |
| 66 int access_count; | 80 int access_count; |
| 67 // Flags about the state and behavior of the offline page. | 81 // Flags about the state and behavior of the offline page. |
| 68 Flags flags; | 82 Flags flags; |
| 69 }; | 83 }; |
| 70 | 84 |
| 71 } // namespace offline_pages | 85 } // namespace offline_pages |
| 72 | 86 |
| 73 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ | 87 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ |
| OLD | NEW |