| 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 "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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 DVLOG(1) << "Loaded dictionary with client hash " << client_hash | 441 DVLOG(1) << "Loaded dictionary with client hash " << client_hash |
| 442 << " and server hash " << server_hash; | 442 << " and server hash " << server_hash; |
| 443 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash, | 443 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash, |
| 444 server_hash, dictionary_url_normalized, domain, | 444 server_hash, dictionary_url_normalized, domain, |
| 445 path, expiration, ports); | 445 path, expiration, ports); |
| 446 dictionaries_[server_hash] = | 446 dictionaries_[server_hash] = |
| 447 new base::RefCountedData<SdchDictionary>(dictionary); | 447 new base::RefCountedData<SdchDictionary>(dictionary); |
| 448 if (server_hash_p) | 448 if (server_hash_p) |
| 449 *server_hash_p = server_hash; | 449 *server_hash_p = server_hash; |
| 450 | 450 |
| 451 FOR_EACH_OBSERVER(SdchObserver, observers_, |
| 452 OnDictionaryAdded(this, dictionary_url, server_hash)); |
| 453 |
| 451 return SDCH_OK; | 454 return SDCH_OK; |
| 452 } | 455 } |
| 453 | 456 |
| 454 SdchProblemCode SdchManager::RemoveSdchDictionary( | 457 SdchProblemCode SdchManager::RemoveSdchDictionary( |
| 455 const std::string& server_hash) { | 458 const std::string& server_hash) { |
| 456 if (dictionaries_.find(server_hash) == dictionaries_.end()) | 459 if (dictionaries_.find(server_hash) == dictionaries_.end()) |
| 457 return SDCH_DICTIONARY_HASH_NOT_FOUND; | 460 return SDCH_DICTIONARY_HASH_NOT_FOUND; |
| 458 | 461 |
| 459 dictionaries_.erase(server_hash); | 462 dictionaries_.erase(server_hash); |
| 463 |
| 464 FOR_EACH_OBSERVER(SdchObserver, observers_, |
| 465 OnDictionaryRemoved(this, server_hash)); |
| 466 |
| 460 return SDCH_OK; | 467 return SDCH_OK; |
| 461 } | 468 } |
| 462 | 469 |
| 463 // static | 470 // static |
| 464 scoped_ptr<SdchManager::DictionarySet> | 471 scoped_ptr<SdchManager::DictionarySet> |
| 465 SdchManager::CreateEmptyDictionarySetForTesting() { | 472 SdchManager::CreateEmptyDictionarySetForTesting() { |
| 466 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); | 473 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); |
| 467 } | 474 } |
| 468 | 475 |
| 469 // For investigation of http://crbug.com/454198; remove when resolved. | 476 // For investigation of http://crbug.com/454198; remove when resolved. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 entry_dict->SetInteger("tries", it->second.count); | 524 entry_dict->SetInteger("tries", it->second.count); |
| 518 entry_dict->SetInteger("reason", it->second.reason); | 525 entry_dict->SetInteger("reason", it->second.reason); |
| 519 entry_list->Append(entry_dict); | 526 entry_list->Append(entry_dict); |
| 520 } | 527 } |
| 521 value->Set("blacklisted", entry_list); | 528 value->Set("blacklisted", entry_list); |
| 522 | 529 |
| 523 return value; | 530 return value; |
| 524 } | 531 } |
| 525 | 532 |
| 526 } // namespace net | 533 } // namespace net |
| OLD | NEW |