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

Side by Side Diff: components/offline_pages/request_header/offline_page_header.h

Issue 2337363002: Load live version when reloading an offline page on connected network (Closed)
Patch Set: 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_
6 #define COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_
7
8 #include <string>
9
10 namespace offline_pages {
11
12 // Header that indicates that the offline page should be loaded if it exists
13 // regardless current network conditions. Its value is a comma/space separated
14 // name-value pair that may provide reason or define custom behavior.
15 extern const char kOfflinePageHeader[];
16 // The name used in name-value pair of kOfflinePageHeader to tell if the offline
17 // info in this header should be persisted across session restore.
18 extern const char kOfflinePageHeaderPersistKey[];
19 // The name used in name-value pair of kOfflinePageHeader to denote the reason
20 // for loading offline page.
21 extern const char kOfflinePageHeaderReasonKey[];
22 // Possible values in name-value pair that denote the reason for loading offline
23 // page.
24 extern const char kOfflinePageHeaderReasonValueDueToNetError[];
25 extern const char kOfflinePageHeaderReasonValueFromDownload[];
Dmitry Titov 2016/09/16 21:37:23 These two values shoudl be commented.
jianli 2016/09/16 23:08:48 Done.
26 extern const char kOfflinePageHeaderReasonValueReload[];
27 // The name used in name-value pair of kOfflinePageHeader to denote the offline
28 // ID of the offline page to load.
29 extern const char kOfflinePageHeaderIDKey[];
30
31 // Used to parse the extra request header string that defines offline page
32 // loading behaviors.
33 struct OfflinePageHeader {
34 public:
35 enum class Reason {
36 NONE,
37 NET_ERROR,
38 DOWNLOAD,
39 RELOAD,
40 UNKNOWN
41 };
42
43 OfflinePageHeader();
44 ~OfflinePageHeader();
45
46 // Parses from the header value string.
47 bool ParseFromHeaderValue(const std::string& header_value);
Dmitry Titov 2016/09/16 21:37:23 Why not just have an explicit ctor from a string?
jianli 2016/09/16 23:08:48 If we use an explicit ctor from a string, we need
48
49 // Returns the full header string, including both key and value, that could be
50 // passed to set extra request header.
51 std::string ToFullHeaderString() const;
Dmitry Titov 2016/09/16 21:37:23 GetCompleteHeaderString ?
jianli 2016/09/16 23:08:48 Done.
52
53 void Clear();
54
55 // Flag to indicate if the header should be persisted across session restore.
56 bool need_to_persist;
57
58 // Describes the reason to load offline page.
59 Reason reason;
60
61 // The offline ID of the page to load.
62 std::string id;
63 };
64
65 } // namespace offline_pages
66
67 #endif // COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698