OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/field_trial.h" | 8 #include "base/field_trial.h" |
9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 const std::set<int> ports) | 324 const std::set<int> ports) |
325 : text_(dictionary_text, offset), | 325 : text_(dictionary_text, offset), |
326 client_hash_(client_hash), | 326 client_hash_(client_hash), |
327 url_(gurl), | 327 url_(gurl), |
328 domain_(domain), | 328 domain_(domain), |
329 path_(path), | 329 path_(path), |
330 expiration_(expiration), | 330 expiration_(expiration), |
331 ports_(ports) { | 331 ports_(ports) { |
332 } | 332 } |
333 | 333 |
| 334 SdchManager::Dictionary::~Dictionary() { |
| 335 } |
| 336 |
334 // static | 337 // static |
335 void SdchManager::GenerateHash(const std::string& dictionary_text, | 338 void SdchManager::GenerateHash(const std::string& dictionary_text, |
336 std::string* client_hash, std::string* server_hash) { | 339 std::string* client_hash, std::string* server_hash) { |
337 char binary_hash[32]; | 340 char binary_hash[32]; |
338 base::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); | 341 base::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); |
339 | 342 |
340 std::string first_48_bits(&binary_hash[0], 6); | 343 std::string first_48_bits(&binary_hash[0], 6); |
341 std::string second_48_bits(&binary_hash[6], 6); | 344 std::string second_48_bits(&binary_hash[6], 6); |
342 UrlSafeBase64Encode(first_48_bits, client_hash); | 345 UrlSafeBase64Encode(first_48_bits, client_hash); |
343 UrlSafeBase64Encode(second_48_bits, server_hash); | 346 UrlSafeBase64Encode(second_48_bits, server_hash); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (enable) { | 536 if (enable) { |
534 allow_latency_experiment_.insert(url.host()); | 537 allow_latency_experiment_.insert(url.host()); |
535 return; | 538 return; |
536 } | 539 } |
537 ExperimentSet::iterator it = allow_latency_experiment_.find(url.host()); | 540 ExperimentSet::iterator it = allow_latency_experiment_.find(url.host()); |
538 if (allow_latency_experiment_.end() == it) | 541 if (allow_latency_experiment_.end() == it) |
539 return; // It was already erased, or never allowed. | 542 return; // It was already erased, or never allowed. |
540 SdchErrorRecovery(LATENCY_TEST_DISALLOWED); | 543 SdchErrorRecovery(LATENCY_TEST_DISALLOWED); |
541 allow_latency_experiment_.erase(it); | 544 allow_latency_experiment_.erase(it); |
542 } | 545 } |
OLD | NEW |