| 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 #include "components/offline_pages/offline_page_item.h" | 5 #include "components/offline_pages/offline_page_item.h" |
| 6 | 6 |
| 7 #include "components/offline_pages/proto/offline_pages.pb.h" |
| 7 #include "net/base/filename_util.h" | 8 #include "net/base/filename_util.h" |
| 8 | 9 |
| 9 namespace offline_pages { | 10 namespace offline_pages { |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 const int kCurrentVersion = 1; | 13 const int kCurrentVersion = 1; |
| 13 } | 14 } |
| 14 | 15 |
| 16 ClientId::ClientId() : name_space(""), id("") {} |
| 17 |
| 18 ClientId::ClientId(std::string name_space, std::string id) |
| 19 : name_space(name_space), id(id) {} |
| 20 |
| 21 bool ClientId::operator==(const ClientId& client_id) const { |
| 22 return name_space == client_id.name_space && id == client_id.id; |
| 23 } |
| 24 |
| 15 OfflinePageItem::OfflinePageItem() | 25 OfflinePageItem::OfflinePageItem() |
| 16 : version(kCurrentVersion), | 26 : version(kCurrentVersion), |
| 17 file_size(0), | 27 file_size(0), |
| 18 access_count(0), | 28 access_count(0), |
| 19 flags(NO_FLAG) { | 29 flags(NO_FLAG) { |
| 20 } | 30 } |
| 21 | 31 |
| 22 OfflinePageItem::OfflinePageItem(const GURL& url, | 32 OfflinePageItem::OfflinePageItem(const GURL& url, |
| 23 int64_t bookmark_id, | 33 int64_t offline_id, |
| 34 const ClientId& client_id, |
| 24 const base::FilePath& file_path, | 35 const base::FilePath& file_path, |
| 25 int64_t file_size) | 36 int64_t file_size) |
| 26 : url(url), | 37 : url(url), |
| 27 bookmark_id(bookmark_id), | 38 offline_id(offline_id), |
| 39 client_id(client_id), |
| 28 version(kCurrentVersion), | 40 version(kCurrentVersion), |
| 29 file_path(file_path), | 41 file_path(file_path), |
| 30 file_size(file_size), | 42 file_size(file_size), |
| 31 access_count(0), | 43 access_count(0), |
| 32 flags(NO_FLAG) {} | 44 flags(NO_FLAG) {} |
| 33 | 45 |
| 34 OfflinePageItem::OfflinePageItem(const GURL& url, | 46 OfflinePageItem::OfflinePageItem(const GURL& url, |
| 35 int64_t bookmark_id, | 47 int64_t offline_id, |
| 48 const ClientId& client_id, |
| 36 const base::FilePath& file_path, | 49 const base::FilePath& file_path, |
| 37 int64_t file_size, | 50 int64_t file_size, |
| 38 const base::Time& creation_time) | 51 const base::Time& creation_time) |
| 39 : url(url), | 52 : url(url), |
| 40 bookmark_id(bookmark_id), | 53 offline_id(offline_id), |
| 54 client_id(client_id), |
| 41 version(kCurrentVersion), | 55 version(kCurrentVersion), |
| 42 file_path(file_path), | 56 file_path(file_path), |
| 43 file_size(file_size), | 57 file_size(file_size), |
| 44 creation_time(creation_time), | 58 creation_time(creation_time), |
| 45 last_access_time(creation_time), | 59 last_access_time(creation_time), |
| 46 access_count(0), | 60 access_count(0), |
| 47 flags(NO_FLAG) {} | 61 flags(NO_FLAG) {} |
| 48 | 62 |
| 49 OfflinePageItem::OfflinePageItem(const OfflinePageItem& other) = default; | 63 OfflinePageItem::OfflinePageItem(const OfflinePageItem& other) = default; |
| 50 | 64 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 | 75 |
| 62 void OfflinePageItem::MarkForDeletion() { | 76 void OfflinePageItem::MarkForDeletion() { |
| 63 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); | 77 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); |
| 64 } | 78 } |
| 65 | 79 |
| 66 void OfflinePageItem::ClearMarkForDeletion() { | 80 void OfflinePageItem::ClearMarkForDeletion() { |
| 67 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); | 81 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); |
| 68 } | 82 } |
| 69 | 83 |
| 70 } // namespace offline_pages | 84 } // namespace offline_pages |
| OLD | NEW |