Chromium Code Reviews| Index: components/offline_pages/request_header/offline_page_header.h |
| diff --git a/components/offline_pages/request_header/offline_page_header.h b/components/offline_pages/request_header/offline_page_header.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..17ddc33ad796e4f72d6c8d633b890dbc14a1fc2f |
| --- /dev/null |
| +++ b/components/offline_pages/request_header/offline_page_header.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_ |
| +#define COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_ |
| + |
| +#include <string> |
| + |
| +namespace offline_pages { |
| + |
| +// Header that indicates that the offline page should be loaded if it exists |
| +// regardless current network conditions. Its value is a comma/space separated |
| +// name-value pair that may provide reason or define custom behavior. |
| +extern const char kOfflinePageHeader[]; |
| +// The name used in name-value pair of kOfflinePageHeader to tell if the offline |
| +// info in this header should be persisted across session restore. |
| +extern const char kOfflinePageHeaderPersistKey[]; |
| +// The name used in name-value pair of kOfflinePageHeader to denote the reason |
| +// for loading offline page. |
| +extern const char kOfflinePageHeaderReasonKey[]; |
| +// Possible values in name-value pair that denote the reason for loading offline |
| +// page. |
| +extern const char kOfflinePageHeaderReasonValueDueToNetError[]; |
| +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.
|
| +extern const char kOfflinePageHeaderReasonValueReload[]; |
| +// The name used in name-value pair of kOfflinePageHeader to denote the offline |
| +// ID of the offline page to load. |
| +extern const char kOfflinePageHeaderIDKey[]; |
| + |
| +// Used to parse the extra request header string that defines offline page |
| +// loading behaviors. |
| +struct OfflinePageHeader { |
| + public: |
| + enum class Reason { |
| + NONE, |
| + NET_ERROR, |
| + DOWNLOAD, |
| + RELOAD, |
| + UNKNOWN |
| + }; |
| + |
| + OfflinePageHeader(); |
| + ~OfflinePageHeader(); |
| + |
| + // Parses from the header value string. |
| + 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
|
| + |
| + // Returns the full header string, including both key and value, that could be |
| + // passed to set extra request header. |
| + std::string ToFullHeaderString() const; |
|
Dmitry Titov
2016/09/16 21:37:23
GetCompleteHeaderString ?
jianli
2016/09/16 23:08:48
Done.
|
| + |
| + void Clear(); |
| + |
| + // Flag to indicate if the header should be persisted across session restore. |
| + bool need_to_persist; |
| + |
| + // Describes the reason to load offline page. |
| + Reason reason; |
| + |
| + // The offline ID of the page to load. |
| + std::string id; |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // COMPONENTS_OFFLINE_PAGES_REQUEST_HEADER_OFFLINE_PAGE_HEADER_H_ |