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

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

Issue 1367063004: Support undoing offline page deletion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add the call to removeObserver Created 5 years, 2 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 { 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 } 20 }
20 21
21 OfflinePageItem::OfflinePageItem(const GURL& url, 22 OfflinePageItem::OfflinePageItem(const GURL& url,
22 int64 bookmark_id, 23 int64 bookmark_id,
23 const base::FilePath& file_path, 24 const base::FilePath& file_path,
24 int64 file_size) 25 int64 file_size)
25 : url(url), 26 : url(url),
26 bookmark_id(bookmark_id), 27 bookmark_id(bookmark_id),
27 version(kCurrentVersion), 28 version(kCurrentVersion),
28 file_path(file_path), 29 file_path(file_path),
29 file_size(file_size), 30 file_size(file_size),
30 access_count(0) { 31 access_count(0),
32 flags(NO_FLAG) {
31 } 33 }
32 34
33 OfflinePageItem::OfflinePageItem(const GURL& url, 35 OfflinePageItem::OfflinePageItem(const GURL& url,
34 int64 bookmark_id, 36 int64 bookmark_id,
35 const base::FilePath& file_path, 37 const base::FilePath& file_path,
36 int64 file_size, 38 int64 file_size,
37 const base::Time& creation_time) 39 const base::Time& creation_time)
38 : url(url), 40 : url(url),
39 bookmark_id(bookmark_id), 41 bookmark_id(bookmark_id),
40 version(kCurrentVersion), 42 version(kCurrentVersion),
41 file_path(file_path), 43 file_path(file_path),
42 file_size(file_size), 44 file_size(file_size),
43 creation_time(creation_time), 45 creation_time(creation_time),
44 last_access_time(creation_time), 46 last_access_time(creation_time),
45 access_count(0) { 47 access_count(0),
48 flags(NO_FLAG) {
46 } 49 }
47 50
48 OfflinePageItem::~OfflinePageItem() { 51 OfflinePageItem::~OfflinePageItem() {
49 } 52 }
50 53
51 GURL OfflinePageItem::GetOfflineURL() const { 54 GURL OfflinePageItem::GetOfflineURL() const {
52 return net::FilePathToFileURL(file_path); 55 return net::FilePathToFileURL(file_path);
53 } 56 }
54 57
58 bool OfflinePageItem::IsMarkedForDeletion() const {
59 return (static_cast<int>(flags) & MARKED_FOR_DELETION) != 0;
60 }
61
62 void OfflinePageItem::MarkForDeletion() {
63 flags = static_cast<Flags>(static_cast<int>(flags) | MARKED_FOR_DELETION);
64 }
65
66 void OfflinePageItem::ClearMarkForDeletion() {
67 flags = static_cast<Flags>(
68 static_cast<int>(flags) & ~(static_cast<int>(MARKED_FOR_DELETION)));
fgorski 2015/10/13 16:48:25 what about here? Is the cast needed here or not?
jianli 2015/10/14 21:37:21 Done.
69 }
70
55 } // namespace offline_pages 71 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698