| 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 437 |
| 437 dictionaries_.erase(server_hash); | 438 dictionaries_.erase(server_hash); |
| 438 | 439 |
| 439 for (auto& observer : observers_) | 440 for (auto& observer : observers_) |
| 440 observer.OnDictionaryRemoved(server_hash); | 441 observer.OnDictionaryRemoved(server_hash); |
| 441 | 442 |
| 442 return SDCH_OK; | 443 return SDCH_OK; |
| 443 } | 444 } |
| 444 | 445 |
| 445 // static | 446 // static |
| 447 void SdchManager::LogSdchProblem(NetLogWithSource netlog, |
| 448 SdchProblemCode problem) { |
| 449 SdchManager::SdchErrorRecovery(problem); |
| 450 netlog.AddEvent(NetLogEventType::SDCH_DECODING_ERROR, |
| 451 base::Bind(&NetLogSdchResourceProblemCallback, problem)); |
| 452 } |
| 453 |
| 454 // static |
| 446 std::unique_ptr<SdchManager::DictionarySet> | 455 std::unique_ptr<SdchManager::DictionarySet> |
| 447 SdchManager::CreateEmptyDictionarySetForTesting() { | 456 SdchManager::CreateEmptyDictionarySetForTesting() { |
| 448 return std::unique_ptr<DictionarySet>(new DictionarySet); | 457 return std::unique_ptr<DictionarySet>(new DictionarySet); |
| 449 } | 458 } |
| 450 | 459 |
| 451 std::unique_ptr<base::Value> SdchManager::SdchInfoToValue() const { | 460 std::unique_ptr<base::Value> SdchManager::SdchInfoToValue() const { |
| 452 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 461 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 453 | 462 |
| 454 value->SetBoolean("sdch_enabled", true); | 463 value->SetBoolean("sdch_enabled", true); |
| 455 | 464 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 485 entry_dict->SetInteger("tries", it->second.count); | 494 entry_dict->SetInteger("tries", it->second.count); |
| 486 entry_dict->SetInteger("reason", it->second.reason); | 495 entry_dict->SetInteger("reason", it->second.reason); |
| 487 entry_list->Append(std::move(entry_dict)); | 496 entry_list->Append(std::move(entry_dict)); |
| 488 } | 497 } |
| 489 value->Set("blacklisted", std::move(entry_list)); | 498 value->Set("blacklisted", std::move(entry_list)); |
| 490 | 499 |
| 491 return std::move(value); | 500 return std::move(value); |
| 492 } | 501 } |
| 493 | 502 |
| 494 } // namespace net | 503 } // namespace net |
| OLD | NEW |