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

Side by Side Diff: extensions/browser/api/web_request/web_request_api_helpers.cc

Issue 1577673002: WebRequest API cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy GetSocketAddress().host instead of & to resolve win failure Created 4 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/web_request/web_request_api_helpers.h" 5 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 bool NullableEquals(const std::string* a, const std::string* b) { 132 bool NullableEquals(const std::string* a, const std::string* b) {
133 if ((a && !b) || (!a && b)) 133 if ((a && !b) || (!a && b))
134 return false; 134 return false;
135 return (!a) || (*a == *b); 135 return (!a) || (*a == *b);
136 } 136 }
137 137
138 } // namespace 138 } // namespace
139 139
140 bool ExtraInfoSpec::InitFromValue(const base::ListValue& value,
141 int* extra_info_spec) {
142 *extra_info_spec = 0;
143 for (size_t i = 0; i < value.GetSize(); ++i) {
144 std::string str;
145 if (!value.GetString(i, &str))
146 return false;
147
148 if (str == "requestHeaders")
149 *extra_info_spec |= REQUEST_HEADERS;
150 else if (str == "responseHeaders")
151 *extra_info_spec |= RESPONSE_HEADERS;
152 else if (str == "blocking")
153 *extra_info_spec |= BLOCKING;
154 else if (str == "asyncBlocking")
155 *extra_info_spec |= ASYNC_BLOCKING;
156 else if (str == "requestBody")
157 *extra_info_spec |= REQUEST_BODY;
158 else
159 return false;
160 }
161 // BLOCKING and ASYNC_BLOCKING are mutually exclusive.
162 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING))
163 return false;
164 return true;
165 }
166
140 RequestCookie::RequestCookie() {} 167 RequestCookie::RequestCookie() {}
141 RequestCookie::~RequestCookie() {} 168 RequestCookie::~RequestCookie() {}
142 169
143 bool NullableEquals(const RequestCookie* a, const RequestCookie* b) { 170 bool NullableEquals(const RequestCookie* a, const RequestCookie* b) {
144 if ((a && !b) || (!a && b)) 171 if ((a && !b) || (!a && b))
145 return false; 172 return false;
146 if (!a) 173 if (!a)
147 return true; 174 return true;
148 return NullableEquals(a->name.get(), b->name.get()) && 175 return NullableEquals(a->name.get(), b->name.get()) &&
149 NullableEquals(a->value.get(), b->value.get()); 176 NullableEquals(a->value.get(), b->value.get());
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 std::find(kResourceTypeStrings, 1313 std::find(kResourceTypeStrings,
1287 kResourceTypeStrings + kResourceTypeStringsLength, 1314 kResourceTypeStrings + kResourceTypeStringsLength,
1288 type_str); 1315 type_str);
1289 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) 1316 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength))
1290 return false; 1317 return false;
1291 *type = kResourceTypeValues[iter - kResourceTypeStrings]; 1318 *type = kResourceTypeValues[iter - kResourceTypeStrings];
1292 return true; 1319 return true;
1293 } 1320 }
1294 1321
1295 } // namespace extension_web_request_api_helpers 1322 } // namespace extension_web_request_api_helpers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698