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

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: address comments. 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_namespace(client_id.space),
31 client_id(client_id.id),
28 version(kCurrentVersion), 32 version(kCurrentVersion),
29 file_path(file_path), 33 file_path(file_path),
30 file_size(file_size), 34 file_size(file_size),
31 access_count(0), 35 access_count(0),
32 flags(NO_FLAG) {} 36 flags(NO_FLAG) {}
33 37
34 OfflinePageItem::OfflinePageItem(const GURL& url, 38 OfflinePageItem::OfflinePageItem(const GURL& url,
35 int64_t bookmark_id, 39 int64_t offline_id,
40 const ClientId& client_id,
36 const base::FilePath& file_path, 41 const base::FilePath& file_path,
37 int64_t file_size, 42 int64_t file_size,
38 const base::Time& creation_time) 43 const base::Time& creation_time)
39 : url(url), 44 : url(url),
40 bookmark_id(bookmark_id), 45 offline_id(offline_id),
46 client_id_namespace(client_id.space),
47 client_id(client_id.id),
41 version(kCurrentVersion), 48 version(kCurrentVersion),
42 file_path(file_path), 49 file_path(file_path),
43 file_size(file_size), 50 file_size(file_size),
44 creation_time(creation_time), 51 creation_time(creation_time),
45 last_access_time(creation_time), 52 last_access_time(creation_time),
46 access_count(0), 53 access_count(0),
47 flags(NO_FLAG) {} 54 flags(NO_FLAG) {}
48 55
49 OfflinePageItem::~OfflinePageItem() { 56 OfflinePageItem::~OfflinePageItem() {
50 } 57 }
51 58
52 GURL OfflinePageItem::GetOfflineURL() const { 59 GURL OfflinePageItem::GetOfflineURL() const {
53 return net::FilePathToFileURL(file_path); 60 return net::FilePathToFileURL(file_path);
54 } 61 }
55 62
56 bool OfflinePageItem::IsMarkedForDeletion() const { 63 bool OfflinePageItem::IsMarkedForDeletion() const {
57 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0; 64 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0;
58 } 65 }
59 66
60 void OfflinePageItem::MarkForDeletion() { 67 void OfflinePageItem::MarkForDeletion() {
61 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION); 68 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION);
62 } 69 }
63 70
64 void OfflinePageItem::ClearMarkForDeletion() { 71 void OfflinePageItem::ClearMarkForDeletion() {
65 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION); 72 flags = static_cast<Flags>(static_cast<int>(flags) & ~MARKED_FOR_DELETION);
66 } 73 }
67 74
68 } // namespace offline_pages 75 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698