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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_tamper_detection.cc

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/data_reduction_proxy/browser/data_reduction_proxy_tamper_de tection.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_tamper_de tection.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 std::string mime_type; 299 std::string mime_type;
300 response_headers_->GetMimeType(&mime_type); 300 response_headers_->GetMimeType(&mime_type);
301 301
302 std::string JS1 = "text/javascript"; 302 std::string JS1 = "text/javascript";
303 std::string JS2 = "application/x-javascript"; 303 std::string JS2 = "application/x-javascript";
304 std::string JS3 = "application/javascript"; 304 std::string JS3 = "application/javascript";
305 std::string CSS = "text/css"; 305 std::string CSS = "text/css";
306 std::string IMAGE = "image/"; 306 std::string IMAGE = "image/";
307 307
308 size_t mime_type_size = mime_type.size(); 308 size_t mime_type_size = mime_type.size();
309 if ((mime_type_size >= JS1.size() && LowerCaseEqualsASCII(mime_type.begin(), 309 if ((mime_type_size >= JS1.size() &&
310 base::LowerCaseEqualsASCII(mime_type.begin(),
310 mime_type.begin() + JS1.size(), JS1.c_str())) || 311 mime_type.begin() + JS1.size(), JS1.c_str())) ||
311 (mime_type_size >= JS2.size() && LowerCaseEqualsASCII(mime_type.begin(), 312 (mime_type_size >= JS2.size() &&
313 base::LowerCaseEqualsASCII(mime_type.begin(),
312 mime_type.begin() + JS2.size(), JS2.c_str())) || 314 mime_type.begin() + JS2.size(), JS2.c_str())) ||
313 (mime_type_size >= JS3.size() && LowerCaseEqualsASCII(mime_type.begin(), 315 (mime_type_size >= JS3.size() &&
316 base::LowerCaseEqualsASCII(mime_type.begin(),
314 mime_type.begin() + JS3.size(), JS3.c_str()))) { 317 mime_type.begin() + JS3.size(), JS3.c_str()))) {
315 REPORT_TAMPER_DETECTION_UMA( 318 REPORT_TAMPER_DETECTION_UMA(
316 scheme_is_https_, 319 scheme_is_https_,
317 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_JS", 320 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_JS",
318 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_JS", 321 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_JS",
319 carrier_id_); 322 carrier_id_);
320 } else if (mime_type_size >= CSS.size() && 323 } else if (mime_type_size >= CSS.size() &&
321 LowerCaseEqualsASCII(mime_type.begin(), 324 base::LowerCaseEqualsASCII(mime_type.begin(),
322 mime_type.begin() + CSS.size(), CSS.c_str())) { 325 mime_type.begin() + CSS.size(), CSS.c_str())) {
323 REPORT_TAMPER_DETECTION_UMA( 326 REPORT_TAMPER_DETECTION_UMA(
324 scheme_is_https_, 327 scheme_is_https_,
325 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_CSS", 328 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_CSS",
326 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_CSS", 329 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_CSS",
327 carrier_id_); 330 carrier_id_);
328 } else if (mime_type_size >= IMAGE.size() && 331 } else if (mime_type_size >= IMAGE.size() &&
329 LowerCaseEqualsASCII(mime_type.begin(), 332 base::LowerCaseEqualsASCII(mime_type.begin(),
330 mime_type.begin() + IMAGE.size(), IMAGE.c_str())) { 333 mime_type.begin() + IMAGE.size(), IMAGE.c_str())) {
331 REPORT_TAMPER_DETECTION_UMA( 334 REPORT_TAMPER_DETECTION_UMA(
332 scheme_is_https_, 335 scheme_is_https_,
333 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Image", 336 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Image",
334 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_Image", 337 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_Image",
335 carrier_id_); 338 carrier_id_);
336 } else { 339 } else {
337 REPORT_TAMPER_DETECTION_UMA( 340 REPORT_TAMPER_DETECTION_UMA(
338 scheme_is_https_, 341 scheme_is_https_,
339 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Other", 342 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Other",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 std::vector<std::string> values; 378 std::vector<std::string> values;
376 std::string value; 379 std::string value;
377 void* iter = NULL; 380 void* iter = NULL;
378 while (headers->EnumerateHeader(&iter, header_name, &value)) { 381 while (headers->EnumerateHeader(&iter, header_name, &value)) {
379 values.push_back(value); 382 values.push_back(value);
380 } 383 }
381 return values; 384 return values;
382 } 385 }
383 386
384 } // namespace data_reduction_proxy 387 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698