Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: components/offline_pages/offline_page_item.cc

Issue 1694863003: Refactor the offline page storage to include client namespace and id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move id generation to C++, add DB migration Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
15 OfflinePageItem::OfflinePageItem() 16 OfflinePageItem::OfflinePageItem()
16 : version(kCurrentVersion), 17 : version(kCurrentVersion),
17 file_size(0), 18 file_size(0),
18 access_count(0), 19 access_count(0),
19 flags(NO_FLAG) { 20 flags(NO_FLAG) {
20 } 21 }
21 22
22 OfflinePageItem::OfflinePageItem(const GURL& url, 23 OfflinePageItem::OfflinePageItem(const GURL& url,
23 int64_t bookmark_id, 24 int64_t offline_id,
25 const ClientId& client_id,
24 const base::FilePath& file_path, 26 const base::FilePath& file_path,
25 int64_t file_size) 27 int64_t file_size)
26 : url(url), 28 : url(url),
27 bookmark_id(bookmark_id), 29 offline_id(offline_id),
30 client_id(client_id),
28 version(kCurrentVersion), 31 version(kCurrentVersion),
29 file_path(file_path), 32 file_path(file_path),
30 file_size(file_size), 33 file_size(file_size),
31 access_count(0), 34 access_count(0),
32 flags(NO_FLAG) {} 35 flags(NO_FLAG) {}
33 36
34 OfflinePageItem::OfflinePageItem(const GURL& url, 37 OfflinePageItem::OfflinePageItem(const GURL& url,
35 int64_t bookmark_id, 38 int64_t offline_id,
39 const ClientId& client_id,
36 const base::FilePath& file_path, 40 const base::FilePath& file_path,
37 int64_t file_size, 41 int64_t file_size,
38 const base::Time& creation_time) 42 const base::Time& creation_time)
39 : url(url), 43 : url(url),
40 bookmark_id(bookmark_id), 44 offline_id(offline_id),
45 client_id(client_id),
41 version(kCurrentVersion), 46 version(kCurrentVersion),
42 file_path(file_path), 47 file_path(file_path),
43 file_size(file_size), 48 file_size(file_size),
44 creation_time(creation_time), 49 creation_time(creation_time),
45 last_access_time(creation_time), 50 last_access_time(creation_time),
46 access_count(0), 51 access_count(0),
47 flags(NO_FLAG) {} 52 flags(NO_FLAG) {}
48 53
49 OfflinePageItem::~OfflinePageItem() { 54 OfflinePageItem::~OfflinePageItem() {
50 } 55 }
51 56
52 GURL OfflinePageItem::GetOfflineURL() const { 57 GURL OfflinePageItem::GetOfflineURL() const {
53 return net::FilePathToFileURL(file_path); 58 return net::FilePathToFileURL(file_path);
54 } 59 }
55 60
56 bool OfflinePageItem::IsMarkedForDeletion() const { 61 bool OfflinePageItem::IsMarkedForDeletion() const {
57 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0; 62 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0;
58 } 63 }
59 64
60 void OfflinePageItem::MarkForDeletion() { 65 void OfflinePageItem::MarkForDeletion() {
61 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); 66 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION);
62 } 67 }
63 68
64 void OfflinePageItem::ClearMarkForDeletion() { 69 void OfflinePageItem::ClearMarkForDeletion() {
65 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); 70 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION);
66 } 71 }
67 72
68 } // namespace offline_pages 73 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698