| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sdch/sdch_owner.h" | 5 #include "net/sdch/sdch_owner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // For debugging http://crbug.com/454198; remove when resolved. | 394 // For debugging http://crbug.com/454198; remove when resolved. |
| 395 CHECK_EQ(0u, destroyed_); | 395 CHECK_EQ(0u, destroyed_); |
| 396 CHECK(clock_.get()); | 396 CHECK(clock_.get()); |
| 397 #endif | 397 #endif |
| 398 | 398 |
| 399 if (total_dictionary_bytes_ + dictionary_text.size() - recoverable_bytes > | 399 if (total_dictionary_bytes_ + dictionary_text.size() - recoverable_bytes > |
| 400 max_total_dictionary_size_) { | 400 max_total_dictionary_size_) { |
| 401 RecordDictionaryFate(DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE); | 401 RecordDictionaryFate(DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE); |
| 402 SdchManager::SdchErrorRecovery(SDCH_DICTIONARY_NO_ROOM); | 402 SdchManager::SdchErrorRecovery(SDCH_DICTIONARY_NO_ROOM); |
| 403 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, | 403 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, |
| 404 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, | 404 base::Bind(NetLogSdchDictionaryFetchProblemCallback, |
| 405 SDCH_DICTIONARY_NO_ROOM, dictionary_url, true)); | 405 SDCH_DICTIONARY_NO_ROOM, dictionary_url, true)); |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 | 408 |
| 409 // Add the new dictionary. This is done before removing the stale | 409 // Add the new dictionary. This is done before removing the stale |
| 410 // dictionaries so that no state change will occur if dictionary addition | 410 // dictionaries so that no state change will occur if dictionary addition |
| 411 // fails. | 411 // fails. |
| 412 std::string server_hash; | 412 std::string server_hash; |
| 413 SdchProblemCode rv = manager_->AddSdchDictionary( | 413 SdchProblemCode rv = manager_->AddSdchDictionary( |
| 414 dictionary_text, dictionary_url, &server_hash); | 414 dictionary_text, dictionary_url, &server_hash); |
| 415 if (rv != SDCH_OK) { | 415 if (rv != SDCH_OK) { |
| 416 RecordDictionaryFate(DICTIONARY_FATE_FETCH_MANAGER_REFUSED); | 416 RecordDictionaryFate(DICTIONARY_FATE_FETCH_MANAGER_REFUSED); |
| 417 SdchManager::SdchErrorRecovery(rv); | 417 SdchManager::SdchErrorRecovery(rv); |
| 418 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, | 418 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, |
| 419 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv, | 419 base::Bind(NetLogSdchDictionaryFetchProblemCallback, rv, |
| 420 dictionary_url, true)); | 420 dictionary_url, true)); |
| 421 return; | 421 return; |
| 422 } | 422 } |
| 423 | 423 |
| 424 base::DictionaryValue* pref_dictionary_map = | 424 base::DictionaryValue* pref_dictionary_map = |
| 425 GetPersistentStoreDictionaryMap(pref_store_); | 425 GetPersistentStoreDictionaryMap(pref_store_); |
| 426 ScopedPrefNotifier scoped_pref_notifier(pref_store_); | 426 ScopedPrefNotifier scoped_pref_notifier(pref_store_); |
| 427 | 427 |
| 428 // Remove the old dictionaries. | 428 // Remove the old dictionaries. |
| 429 std::sort(stale_dictionary_list.begin(), stale_dictionary_list.end()); | 429 std::sort(stale_dictionary_list.begin(), stale_dictionary_list.end()); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 772 } |
| 773 | 773 |
| 774 return true; | 774 return true; |
| 775 } | 775 } |
| 776 | 776 |
| 777 bool SdchOwner::IsPersistingDictionaries() const { | 777 bool SdchOwner::IsPersistingDictionaries() const { |
| 778 return in_memory_pref_store_.get() != nullptr; | 778 return in_memory_pref_store_.get() != nullptr; |
| 779 } | 779 } |
| 780 | 780 |
| 781 } // namespace net | 781 } // namespace net |
| OLD | NEW |