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

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

Issue 2336813002: [Offline pages] OPMStoreSQL: Upgrade to M55, Upgrade refactoring, conversion refactoring (Closed)
Patch Set: Addressing CR feedback Created 4 years, 3 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 "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 {
12 const int kCurrentVersion = 1;
13 }
14
15 ClientId::ClientId() : name_space(""), id("") {} 11 ClientId::ClientId() : name_space(""), id("") {}
16 12
17 ClientId::ClientId(std::string name_space, std::string id) 13 ClientId::ClientId(std::string name_space, std::string id)
18 : name_space(name_space), id(id) {} 14 : name_space(name_space), id(id) {}
19 15
20 bool ClientId::operator==(const ClientId& client_id) const { 16 bool ClientId::operator==(const ClientId& client_id) const {
21 return name_space == client_id.name_space && id == client_id.id; 17 return name_space == client_id.name_space && id == client_id.id;
22 } 18 }
23 19
24 bool ClientId::operator<(const ClientId& client_id) const { 20 bool ClientId::operator<(const ClientId& client_id) const {
25 if (name_space == client_id.name_space) 21 if (name_space == client_id.name_space)
26 return (id < client_id.id); 22 return (id < client_id.id);
27 23
28 return name_space < client_id.name_space; 24 return name_space < client_id.name_space;
29 } 25 }
30 26
31 OfflinePageItem::OfflinePageItem() 27 OfflinePageItem::OfflinePageItem()
32 : version(kCurrentVersion), 28 : file_size(0), access_count(0), flags(NO_FLAG) {}
33 file_size(0),
34 access_count(0),
35 flags(NO_FLAG) {
36 }
37 29
38 OfflinePageItem::OfflinePageItem(const GURL& url, 30 OfflinePageItem::OfflinePageItem(const GURL& url,
39 int64_t offline_id, 31 int64_t offline_id,
40 const ClientId& client_id, 32 const ClientId& client_id,
41 const base::FilePath& file_path, 33 const base::FilePath& file_path,
42 int64_t file_size) 34 int64_t file_size)
43 : url(url), 35 : url(url),
44 offline_id(offline_id), 36 offline_id(offline_id),
45 client_id(client_id), 37 client_id(client_id),
46 version(kCurrentVersion),
47 file_path(file_path), 38 file_path(file_path),
48 file_size(file_size), 39 file_size(file_size),
49 access_count(0), 40 access_count(0),
50 flags(NO_FLAG) {} 41 flags(NO_FLAG) {}
51 42
52 OfflinePageItem::OfflinePageItem(const GURL& url, 43 OfflinePageItem::OfflinePageItem(const GURL& url,
53 int64_t offline_id, 44 int64_t offline_id,
54 const ClientId& client_id, 45 const ClientId& client_id,
55 const base::FilePath& file_path, 46 const base::FilePath& file_path,
56 int64_t file_size, 47 int64_t file_size,
57 const base::Time& creation_time) 48 const base::Time& creation_time)
58 : url(url), 49 : url(url),
59 offline_id(offline_id), 50 offline_id(offline_id),
60 client_id(client_id), 51 client_id(client_id),
61 version(kCurrentVersion),
62 file_path(file_path), 52 file_path(file_path),
63 file_size(file_size), 53 file_size(file_size),
64 creation_time(creation_time), 54 creation_time(creation_time),
65 last_access_time(creation_time), 55 last_access_time(creation_time),
66 access_count(0), 56 access_count(0),
67 flags(NO_FLAG) {} 57 flags(NO_FLAG) {}
68 58
69 OfflinePageItem::OfflinePageItem(const OfflinePageItem& other) = default; 59 OfflinePageItem::OfflinePageItem(const OfflinePageItem& other) = default;
70 60
71 OfflinePageItem::~OfflinePageItem() { 61 OfflinePageItem::~OfflinePageItem() {
72 } 62 }
73 63
74 GURL OfflinePageItem::GetOfflineURL() const { 64 GURL OfflinePageItem::GetOfflineURL() const {
75 return net::FilePathToFileURL(file_path); 65 return net::FilePathToFileURL(file_path);
76 } 66 }
77 67
78 bool OfflinePageItem::IsExpired() const { 68 bool OfflinePageItem::IsExpired() const {
79 return creation_time < expiration_time; 69 return creation_time < expiration_time;
80 } 70 }
81 71
82 } // namespace offline_pages 72 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698