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, |
| 452 observers_, |
| 453 OnDictionaryAdded(this, dictionary_url, server_hash)); |
| 454 |
451 return SDCH_OK; | 455 return SDCH_OK; |
452 } | 456 } |
453 | 457 |
454 SdchProblemCode SdchManager::RemoveSdchDictionary( | 458 SdchProblemCode SdchManager::RemoveSdchDictionary( |
455 const std::string& server_hash) { | 459 const std::string& server_hash) { |
456 if (dictionaries_.find(server_hash) == dictionaries_.end()) | 460 if (dictionaries_.find(server_hash) == dictionaries_.end()) |
457 return SDCH_DICTIONARY_HASH_NOT_FOUND; | 461 return SDCH_DICTIONARY_HASH_NOT_FOUND; |
458 | 462 |
459 dictionaries_.erase(server_hash); | 463 dictionaries_.erase(server_hash); |
| 464 |
| 465 FOR_EACH_OBSERVER(SdchObserver, |
| 466 observers_, |
| 467 OnDictionaryRemoved(this, server_hash)); |
| 468 |
460 return SDCH_OK; | 469 return SDCH_OK; |
461 } | 470 } |
462 | 471 |
463 // static | 472 // static |
464 scoped_ptr<SdchManager::DictionarySet> | 473 scoped_ptr<SdchManager::DictionarySet> |
465 SdchManager::CreateEmptyDictionarySetForTesting() { | 474 SdchManager::CreateEmptyDictionarySetForTesting() { |
466 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); | 475 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); |
467 } | 476 } |
468 | 477 |
469 // For investigation of http://crbug.com/454198; remove when resolved. | 478 // 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); | 526 entry_dict->SetInteger("tries", it->second.count); |
518 entry_dict->SetInteger("reason", it->second.reason); | 527 entry_dict->SetInteger("reason", it->second.reason); |
519 entry_list->Append(entry_dict); | 528 entry_list->Append(entry_dict); |
520 } | 529 } |
521 value->Set("blacklisted", entry_list); | 530 value->Set("blacklisted", entry_list); |
522 | 531 |
523 return value; | 532 return value; |
524 } | 533 } |
525 | 534 |
526 } // namespace net | 535 } // namespace net |
OLD | NEW |