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

Side by Side Diff: components/offline_pages/core/request_header/offline_page_header.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years 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 2016 The Chromium Authors. All rights reserved. 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 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/request_header/offline_page_header.h" 5 #include "components/offline_pages/core/request_header/offline_page_header.h"
6 6
7 #include "base/strings/string_tokenizer.h" 7 #include "base/strings/string_tokenizer.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 9
10 namespace offline_pages { 10 namespace offline_pages {
11 11
12 const char kOfflinePageHeader[] = "X-Chrome-offline"; 12 const char kOfflinePageHeader[] = "X-Chrome-offline";
13 const char kOfflinePageHeaderReasonKey[] = "reason"; 13 const char kOfflinePageHeaderReasonKey[] = "reason";
14 const char kOfflinePageHeaderReasonValueDueToNetError[] = "error"; 14 const char kOfflinePageHeaderReasonValueDueToNetError[] = "error";
15 const char kOfflinePageHeaderReasonValueFromDownload[] = "download"; 15 const char kOfflinePageHeaderReasonValueFromDownload[] = "download";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 NOTREACHED(); 75 NOTREACHED();
76 return ""; 76 return "";
77 } 77 }
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 OfflinePageHeader::OfflinePageHeader() 82 OfflinePageHeader::OfflinePageHeader()
83 : did_fail_parsing_for_test(false), 83 : did_fail_parsing_for_test(false),
84 need_to_persist(false), 84 need_to_persist(false),
85 reason(Reason::NONE) { 85 reason(Reason::NONE) {}
86 }
87 86
88 OfflinePageHeader::OfflinePageHeader(const std::string& header_value) 87 OfflinePageHeader::OfflinePageHeader(const std::string& header_value)
89 : did_fail_parsing_for_test(false), 88 : did_fail_parsing_for_test(false),
90 need_to_persist(false), 89 need_to_persist(false),
91 reason(Reason::NONE) { 90 reason(Reason::NONE) {
92 if (!ParseOfflineHeaderValue(header_value, &need_to_persist, &reason, &id)) { 91 if (!ParseOfflineHeaderValue(header_value, &need_to_persist, &reason, &id)) {
93 did_fail_parsing_for_test = true; 92 did_fail_parsing_for_test = true;
94 Clear(); 93 Clear();
95 } 94 }
96 } 95 }
97 96
98 OfflinePageHeader::~OfflinePageHeader() {} 97 OfflinePageHeader::~OfflinePageHeader() {}
99 98
100 std::string OfflinePageHeader::GetCompleteHeaderString() const { 99 std::string OfflinePageHeader::GetCompleteHeaderString() const {
101 if (reason == Reason::NONE) 100 if (reason == Reason::NONE)
102 return std::string(); 101 return std::string();
103 102
104 std::string value(kOfflinePageHeader); 103 std::string value(kOfflinePageHeader);
105 value += ": "; 104 value += ": ";
106 105
107 value += kOfflinePageHeaderPersistKey; 106 value += kOfflinePageHeaderPersistKey;
108 value += "="; 107 value += "=";
109 value += need_to_persist ? "1" : "0"; 108 value += need_to_persist ? "1" : "0";
110 109
111 value += " " ; 110 value += " ";
112 value += kOfflinePageHeaderReasonKey; 111 value += kOfflinePageHeaderReasonKey;
113 value += "="; 112 value += "=";
114 value += ReasonToString(reason); 113 value += ReasonToString(reason);
115 114
116 if (!id.empty()) { 115 if (!id.empty()) {
117 value += " " ; 116 value += " ";
118 value += kOfflinePageHeaderIDKey; 117 value += kOfflinePageHeaderIDKey;
119 value += "="; 118 value += "=";
120 value += id; 119 value += id;
121 } 120 }
122 121
123 return value; 122 return value;
124 } 123 }
125 124
126 void OfflinePageHeader::Clear() { 125 void OfflinePageHeader::Clear() {
127 reason = Reason::NONE; 126 reason = Reason::NONE;
128 need_to_persist = false; 127 need_to_persist = false;
129 id.clear(); 128 id.clear();
130 } 129 }
131 130
132 } // namespace offline_pages 131 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698