| 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 "net/base/filename_util.h" | 7 #include "net/base/filename_util.h" |
| 8 | 8 |
| 9 namespace offline_pages { | 9 namespace offline_pages { |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 const int kCurrentVersion = 1; | 12 const int kCurrentVersion = 1; |
| 13 } | 13 } |
| 14 | 14 |
| 15 OfflinePageItem::OfflinePageItem() | 15 OfflinePageItem::OfflinePageItem() |
| 16 : version(kCurrentVersion), | 16 : version(kCurrentVersion), |
| 17 file_size(0), | 17 file_size(0), |
| 18 access_count(0), | 18 access_count(0), |
| 19 flags(NO_FLAG) { | 19 flags(NO_FLAG) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 OfflinePageItem::OfflinePageItem(const GURL& url, | 22 OfflinePageItem::OfflinePageItem(const GURL& url, |
| 23 int64 bookmark_id, | 23 int64_t bookmark_id, |
| 24 const base::FilePath& file_path, | 24 const base::FilePath& file_path, |
| 25 int64 file_size) | 25 int64_t file_size) |
| 26 : url(url), | 26 : url(url), |
| 27 bookmark_id(bookmark_id), | 27 bookmark_id(bookmark_id), |
| 28 version(kCurrentVersion), | 28 version(kCurrentVersion), |
| 29 file_path(file_path), | 29 file_path(file_path), |
| 30 file_size(file_size), | 30 file_size(file_size), |
| 31 access_count(0), | 31 access_count(0), |
| 32 flags(NO_FLAG) { | 32 flags(NO_FLAG) {} |
| 33 } | |
| 34 | 33 |
| 35 OfflinePageItem::OfflinePageItem(const GURL& url, | 34 OfflinePageItem::OfflinePageItem(const GURL& url, |
| 36 int64 bookmark_id, | 35 int64_t bookmark_id, |
| 37 const base::FilePath& file_path, | 36 const base::FilePath& file_path, |
| 38 int64 file_size, | 37 int64_t file_size, |
| 39 const base::Time& creation_time) | 38 const base::Time& creation_time) |
| 40 : url(url), | 39 : url(url), |
| 41 bookmark_id(bookmark_id), | 40 bookmark_id(bookmark_id), |
| 42 version(kCurrentVersion), | 41 version(kCurrentVersion), |
| 43 file_path(file_path), | 42 file_path(file_path), |
| 44 file_size(file_size), | 43 file_size(file_size), |
| 45 creation_time(creation_time), | 44 creation_time(creation_time), |
| 46 last_access_time(creation_time), | 45 last_access_time(creation_time), |
| 47 access_count(0), | 46 access_count(0), |
| 48 flags(NO_FLAG) { | 47 flags(NO_FLAG) {} |
| 49 } | |
| 50 | 48 |
| 51 OfflinePageItem::~OfflinePageItem() { | 49 OfflinePageItem::~OfflinePageItem() { |
| 52 } | 50 } |
| 53 | 51 |
| 54 GURL OfflinePageItem::GetOfflineURL() const { | 52 GURL OfflinePageItem::GetOfflineURL() const { |
| 55 return net::FilePathToFileURL(file_path); | 53 return net::FilePathToFileURL(file_path); |
| 56 } | 54 } |
| 57 | 55 |
| 58 bool OfflinePageItem::IsMarkedForDeletion() const { | 56 bool OfflinePageItem::IsMarkedForDeletion() const { |
| 59 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0; | 57 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0; |
| 60 } | 58 } |
| 61 | 59 |
| 62 void OfflinePageItem::MarkForDeletion() { | 60 void OfflinePageItem::MarkForDeletion() { |
| 63 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); | 61 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); |
| 64 } | 62 } |
| 65 | 63 |
| 66 void OfflinePageItem::ClearMarkForDeletion() { | 64 void OfflinePageItem::ClearMarkForDeletion() { |
| 67 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); | 65 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); |
| 68 } | 66 } |
| 69 | 67 |
| 70 } // namespace offline_pages | 68 } // namespace offline_pages |
| OLD | NEW |