| 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/parse_number.h" |
| 20 #include "net/base/sdch_net_log_params.h" |
| 20 #include "net/base/sdch_observer.h" | 21 #include "net/base/sdch_observer.h" |
| 21 #include "net/url_request/url_request_http_job.h" | 22 #include "net/url_request/url_request_http_job.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 void StripTrailingDot(GURL* gurl) { | 26 void StripTrailingDot(GURL* gurl) { |
| 26 std::string host(gurl->host()); | 27 std::string host(gurl->host()); |
| 27 | 28 |
| 28 if (host.empty()) | 29 if (host.empty()) |
| 29 return; | 30 return; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return SDCH_DICTIONARY_HASH_NOT_FOUND; | 436 return SDCH_DICTIONARY_HASH_NOT_FOUND; |
| 436 | 437 |
| 437 dictionaries_.erase(server_hash); | 438 dictionaries_.erase(server_hash); |
| 438 | 439 |
| 439 FOR_EACH_OBSERVER(SdchObserver, observers_, OnDictionaryRemoved(server_hash)); | 440 FOR_EACH_OBSERVER(SdchObserver, observers_, OnDictionaryRemoved(server_hash)); |
| 440 | 441 |
| 441 return SDCH_OK; | 442 return SDCH_OK; |
| 442 } | 443 } |
| 443 | 444 |
| 444 // static | 445 // static |
| 446 void SdchManager::LogSdchProblem(NetLogWithSource netlog, |
| 447 SdchProblemCode problem) { |
| 448 SdchManager::SdchErrorRecovery(problem); |
| 449 netlog.AddEvent(NetLogEventType::SDCH_DECODING_ERROR, |
| 450 base::Bind(&NetLogSdchResourceProblemCallback, problem)); |
| 451 } |
| 452 |
| 453 // static |
| 445 std::unique_ptr<SdchManager::DictionarySet> | 454 std::unique_ptr<SdchManager::DictionarySet> |
| 446 SdchManager::CreateEmptyDictionarySetForTesting() { | 455 SdchManager::CreateEmptyDictionarySetForTesting() { |
| 447 return std::unique_ptr<DictionarySet>(new DictionarySet); | 456 return std::unique_ptr<DictionarySet>(new DictionarySet); |
| 448 } | 457 } |
| 449 | 458 |
| 450 std::unique_ptr<base::Value> SdchManager::SdchInfoToValue() const { | 459 std::unique_ptr<base::Value> SdchManager::SdchInfoToValue() const { |
| 451 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 460 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 452 | 461 |
| 453 value->SetBoolean("sdch_enabled", true); | 462 value->SetBoolean("sdch_enabled", true); |
| 454 | 463 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 484 entry_dict->SetInteger("tries", it->second.count); | 493 entry_dict->SetInteger("tries", it->second.count); |
| 485 entry_dict->SetInteger("reason", it->second.reason); | 494 entry_dict->SetInteger("reason", it->second.reason); |
| 486 entry_list->Append(std::move(entry_dict)); | 495 entry_list->Append(std::move(entry_dict)); |
| 487 } | 496 } |
| 488 value->Set("blacklisted", std::move(entry_list)); | 497 value->Set("blacklisted", std::move(entry_list)); |
| 489 | 498 |
| 490 return std::move(value); | 499 return std::move(value); |
| 491 } | 500 } |
| 492 | 501 |
| 493 } // namespace net | 502 } // namespace net |
| OLD | NEW |