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

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

Issue 2040163003: Refactors offline page tab helper to stash the offline page item on redirect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@single-result
Patch Set: Add a dedicated test. Created 4 years, 6 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 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/supports_user_data.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace offline_pages { 18 namespace offline_pages {
18 19
19 struct ClientId { 20 struct ClientId {
20 // The namespace for the id (of course 'namespace' is a reserved word, so...) 21 // The namespace for the id (of course 'namespace' is a reserved word, so...)
21 std::string name_space; 22 std::string name_space;
22 // The id in the client's namespace. Opaque to us. 23 // The id in the client's namespace. Opaque to us.
23 std::string id; 24 std::string id;
24 25
25 ClientId(); 26 ClientId();
26 ClientId(std::string name_space, std::string id); 27 ClientId(std::string name_space, std::string id);
27 28
28 bool operator==(const ClientId& client_id) const; 29 bool operator==(const ClientId& client_id) const;
29 }; 30 };
30 31
31 // Metadata of the offline page. 32 // Metadata of the offline page.
32 struct OfflinePageItem { 33 struct OfflinePageItem : public base::SupportsUserData::Data {
33 public: 34 public:
34 // Note that this should match with Flags enum in offline_pages.proto. 35 // Note that this should match with Flags enum in offline_pages.proto.
35 enum Flags { 36 enum Flags {
36 NO_FLAG = 0, 37 NO_FLAG = 0,
37 MARKED_FOR_DELETION = 0x1, 38 MARKED_FOR_DELETION = 0x1,
38 }; 39 };
39 40
40 OfflinePageItem(); 41 OfflinePageItem();
41 OfflinePageItem(const GURL& url, 42 OfflinePageItem(const GURL& url,
42 int64_t offline_id, 43 int64_t offline_id,
43 const ClientId& client_id, 44 const ClientId& client_id,
44 const base::FilePath& file_path, 45 const base::FilePath& file_path,
45 int64_t file_size); 46 int64_t file_size);
46 OfflinePageItem(const GURL& url, 47 OfflinePageItem(const GURL& url,
47 int64_t offline_id, 48 int64_t offline_id,
48 const ClientId& client_id, 49 const ClientId& client_id,
49 const base::FilePath& file_path, 50 const base::FilePath& file_path,
50 int64_t file_size, 51 int64_t file_size,
51 const base::Time& creation_time); 52 const base::Time& creation_time);
52 OfflinePageItem(const OfflinePageItem& other); 53 OfflinePageItem(const OfflinePageItem& other);
53 ~OfflinePageItem(); 54 ~OfflinePageItem() override;
54 55
55 // Gets a URL of the file under |file_path|. 56 // Gets a URL of the file under |file_path|.
56 GURL GetOfflineURL() const; 57 GURL GetOfflineURL() const;
57 58
58 // Returns whether the offline page is expired. 59 // Returns whether the offline page is expired.
59 bool IsExpired() const; 60 bool IsExpired() const;
60 61
61 // The URL of the page. 62 // The URL of the page.
62 GURL url; 63 GURL url;
63 // The primary key/ID for this page in offline pages internal database. 64 // The primary key/ID for this page in offline pages internal database.
(...skipping 18 matching lines...) Expand all
82 base::Time expiration_time; 83 base::Time expiration_time;
83 // Number of times that the offline archive has been accessed. 84 // Number of times that the offline archive has been accessed.
84 int access_count; 85 int access_count;
85 // Flags about the state and behavior of the offline page. 86 // Flags about the state and behavior of the offline page.
86 Flags flags; 87 Flags flags;
87 }; 88 };
88 89
89 } // namespace offline_pages 90 } // namespace offline_pages
90 91
91 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_ 92 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698