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

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

Issue 1315643005: Use EnumerateHeaderLines to parse added headers in webRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 break; 354 break;
355 } 355 }
356 } 356 }
357 if (!header_found) 357 if (!header_found)
358 result->deleted_response_headers.push_back(ResponseHeader(name, value)); 358 result->deleted_response_headers.push_back(ResponseHeader(name, value));
359 } 359 }
360 } 360 }
361 361
362 // Find added headers (header keys are treated case insensitively). 362 // Find added headers (header keys are treated case insensitively).
363 { 363 {
364 for (ResponseHeaders::const_iterator i = new_response_headers->begin(); 364 for (const auto& i : *new_response_headers) {
365 i != new_response_headers->end(); ++i) { 365 std::string name_lowercase = base::ToLowerASCII(i.first);
366 void* iter = NULL; 366 void* iter = nullptr;
not at google - send to devlin 2015/09/08 22:55:34 I presume you don't need |iter| for anything?
robwu 2015/09/08 23:00:21 iter is just used to keep track of the header iter
367 std::string name;
367 std::string value; 368 std::string value;
368 bool header_found = false; 369 bool header_found = false;
369 while (old_response_headers->EnumerateHeader(&iter, i->first, &value) && 370 while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) {
370 !header_found) { 371 if (base::LowerCaseEqualsASCII(name, name_lowercase) &&
not at google - send to devlin 2015/09/08 22:55:34 Seems like you could use EqualsCaseInsensitiveASCI
robwu 2015/09/08 23:00:20 Possibly, but transforming once to lowercase and s
371 header_found = (value == i->second); 372 value == i.second) {
373 header_found = true;
374 break;
375 }
372 } 376 }
373 if (!header_found) 377 if (!header_found)
374 result->added_response_headers.push_back(*i); 378 result->added_response_headers.push_back(i);
375 } 379 }
376 } 380 }
377 381
378 return result; 382 return result;
379 } 383 }
380 384
381 EventResponseDelta* CalculateOnAuthRequiredDelta( 385 EventResponseDelta* CalculateOnAuthRequiredDelta(
382 const std::string& extension_id, 386 const std::string& extension_id,
383 const base::Time& extension_install_time, 387 const base::Time& extension_install_time,
384 bool cancel, 388 bool cancel,
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 std::find(kResourceTypeStrings, 1276 std::find(kResourceTypeStrings,
1273 kResourceTypeStrings + kResourceTypeStringsLength, 1277 kResourceTypeStrings + kResourceTypeStringsLength,
1274 type_str); 1278 type_str);
1275 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) 1279 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength))
1276 return false; 1280 return false;
1277 *type = kResourceTypeValues[iter - kResourceTypeStrings]; 1281 *type = kResourceTypeValues[iter - kResourceTypeStrings];
1278 return true; 1282 return true;
1279 } 1283 }
1280 1284
1281 } // namespace extension_web_request_api_helpers 1285 } // namespace extension_web_request_api_helpers
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698