OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/sha2.h" | |
11 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "crypto/sha2.h" |
13 #include "net/base/registry_controlled_domain.h" | 13 #include "net/base/registry_controlled_domain.h" |
14 #include "net/url_request/url_request_http_job.h" | 14 #include "net/url_request/url_request_http_job.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 //------------------------------------------------------------------------------ | 18 //------------------------------------------------------------------------------ |
19 // static | 19 // static |
20 const size_t SdchManager::kMaxDictionarySize = 1000000; | 20 const size_t SdchManager::kMaxDictionarySize = 1000000; |
21 | 21 |
22 // static | 22 // static |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 489 } |
490 // Watch to see if we have corrupt or numerous dictionaries. | 490 // Watch to see if we have corrupt or numerous dictionaries. |
491 if (count > 0) | 491 if (count > 0) |
492 UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count); | 492 UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count); |
493 } | 493 } |
494 | 494 |
495 // static | 495 // static |
496 void SdchManager::GenerateHash(const std::string& dictionary_text, | 496 void SdchManager::GenerateHash(const std::string& dictionary_text, |
497 std::string* client_hash, std::string* server_hash) { | 497 std::string* client_hash, std::string* server_hash) { |
498 char binary_hash[32]; | 498 char binary_hash[32]; |
499 base::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); | 499 crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); |
500 | 500 |
501 std::string first_48_bits(&binary_hash[0], 6); | 501 std::string first_48_bits(&binary_hash[0], 6); |
502 std::string second_48_bits(&binary_hash[6], 6); | 502 std::string second_48_bits(&binary_hash[6], 6); |
503 UrlSafeBase64Encode(first_48_bits, client_hash); | 503 UrlSafeBase64Encode(first_48_bits, client_hash); |
504 UrlSafeBase64Encode(second_48_bits, server_hash); | 504 UrlSafeBase64Encode(second_48_bits, server_hash); |
505 | 505 |
506 DCHECK_EQ(server_hash->length(), 8u); | 506 DCHECK_EQ(server_hash->length(), 8u); |
507 DCHECK_EQ(client_hash->length(), 8u); | 507 DCHECK_EQ(client_hash->length(), 8u); |
508 } | 508 } |
509 | 509 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 case '/': | 541 case '/': |
542 (*output)[i] = '_'; | 542 (*output)[i] = '_'; |
543 continue; | 543 continue; |
544 default: | 544 default: |
545 continue; | 545 continue; |
546 } | 546 } |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 } // namespace net | 550 } // namespace net |
OLD | NEW |