| OLD | NEW |
| 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 "net/base/sdch_manager.h" | 5 #include "net/base/sdch_manager.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/base64url.h" | 11 #include "base/base64url.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/time/default_clock.h" | 16 #include "base/time/default_clock.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "crypto/sha2.h" | 18 #include "crypto/sha2.h" |
| 19 #include "net/base/parse_number.h" |
| 19 #include "net/base/sdch_observer.h" | 20 #include "net/base/sdch_observer.h" |
| 20 #include "net/url_request/url_request_http_job.h" | 21 #include "net/url_request/url_request_http_job.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 void StripTrailingDot(GURL* gurl) { | 25 void StripTrailingDot(GURL* gurl) { |
| 25 std::string host(gurl->host()); | 26 std::string host(gurl->host()); |
| 26 | 27 |
| 27 if (host.empty()) | 28 if (host.empty()) |
| 28 return; | 29 return; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 name = base::ToLowerASCII(name); | 370 name = base::ToLowerASCII(name); |
| 370 if (name == "domain") { | 371 if (name == "domain") { |
| 371 domain = value; | 372 domain = value; |
| 372 } else if (name == "path") { | 373 } else if (name == "path") { |
| 373 path = value; | 374 path = value; |
| 374 } else if (name == "format-version") { | 375 } else if (name == "format-version") { |
| 375 if (value != "1.0") | 376 if (value != "1.0") |
| 376 return SDCH_DICTIONARY_UNSUPPORTED_VERSION; | 377 return SDCH_DICTIONARY_UNSUPPORTED_VERSION; |
| 377 } else if (name == "max-age") { | 378 } else if (name == "max-age") { |
| 378 int64_t seconds; | 379 int64_t seconds; |
| 380 // TODO(eroman): crbug.com/596541 -- should not accept a leading +. |
| 379 base::StringToInt64(value, &seconds); | 381 base::StringToInt64(value, &seconds); |
| 380 expiration = base::Time::Now() + base::TimeDelta::FromSeconds(seconds); | 382 expiration = base::Time::Now() + base::TimeDelta::FromSeconds(seconds); |
| 381 } else if (name == "port") { | 383 } else if (name == "port") { |
| 382 int port; | 384 int port; |
| 383 base::StringToInt(value, &port); | 385 if (ParseNonNegativeDecimalInt(value, &port)) |
| 384 if (port >= 0) | |
| 385 ports.insert(port); | 386 ports.insert(port); |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 389 if (line_end >= header_end) | 390 if (line_end >= header_end) |
| 390 break; | 391 break; |
| 391 line_start = line_end + 1; | 392 line_start = line_end + 1; |
| 392 } | 393 } |
| 393 | 394 |
| 394 // Narrow fix for http://crbug.com/389451. | 395 // Narrow fix for http://crbug.com/389451. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 entry_dict->SetInteger("tries", it->second.count); | 474 entry_dict->SetInteger("tries", it->second.count); |
| 474 entry_dict->SetInteger("reason", it->second.reason); | 475 entry_dict->SetInteger("reason", it->second.reason); |
| 475 entry_list->Append(std::move(entry_dict)); | 476 entry_list->Append(std::move(entry_dict)); |
| 476 } | 477 } |
| 477 value->Set("blacklisted", std::move(entry_list)); | 478 value->Set("blacklisted", std::move(entry_list)); |
| 478 | 479 |
| 479 return std::move(value); | 480 return std::move(value); |
| 480 } | 481 } |
| 481 | 482 |
| 482 } // namespace net | 483 } // namespace net |
| OLD | NEW |