Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: net/sdch/sdch_owner.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_stream_factory.cc ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/time/default_clock.h" 16 #include "base/time/default_clock.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "net/base/sdch_manager.h" 18 #include "net/base/sdch_manager.h"
19 #include "net/base/sdch_net_log_params.h" 19 #include "net/base/sdch_net_log_params.h"
20 #include "net/log/net_log_event_type.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 namespace { 24 namespace {
24 25
25 // Dictionaries that haven't been touched in 24 hours may be evicted 26 // Dictionaries that haven't been touched in 24 hours may be evicted
26 // to make room for new dictionaries. 27 // to make room for new dictionaries.
27 const int kFreshnessLifetimeHours = 24; 28 const int kFreshnessLifetimeHours = 24;
28 29
29 // Dictionaries that have never been used only stay fresh for one hour. 30 // Dictionaries that have never been used only stay fresh for one hour.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 stale_dictionary_list.push_back(DictionaryItem( 413 stale_dictionary_list.push_back(DictionaryItem(
413 it.last_used(), it.server_hash(), it.use_count(), it.size())); 414 it.last_used(), it.server_hash(), it.use_count(), it.size()));
414 recoverable_bytes += it.size(); 415 recoverable_bytes += it.size();
415 } 416 }
416 } 417 }
417 418
418 if (total_dictionary_bytes_ + dictionary_text.size() - recoverable_bytes > 419 if (total_dictionary_bytes_ + dictionary_text.size() - recoverable_bytes >
419 max_total_dictionary_size_) { 420 max_total_dictionary_size_) {
420 RecordDictionaryFate(DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE); 421 RecordDictionaryFate(DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE);
421 SdchManager::SdchErrorRecovery(SDCH_DICTIONARY_NO_ROOM); 422 SdchManager::SdchErrorRecovery(SDCH_DICTIONARY_NO_ROOM);
422 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, 423 net_log.AddEvent(NetLogEventType::SDCH_DICTIONARY_ERROR,
423 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, 424 base::Bind(&NetLogSdchDictionaryFetchProblemCallback,
424 SDCH_DICTIONARY_NO_ROOM, dictionary_url, true)); 425 SDCH_DICTIONARY_NO_ROOM, dictionary_url, true));
425 return; 426 return;
426 } 427 }
427 428
428 // Add the new dictionary. This is done before removing the stale 429 // Add the new dictionary. This is done before removing the stale
429 // dictionaries so that no state change will occur if dictionary addition 430 // dictionaries so that no state change will occur if dictionary addition
430 // fails. 431 // fails.
431 std::string server_hash; 432 std::string server_hash;
432 SdchProblemCode rv = manager_->AddSdchDictionary( 433 SdchProblemCode rv = manager_->AddSdchDictionary(
433 dictionary_text, dictionary_url, &server_hash); 434 dictionary_text, dictionary_url, &server_hash);
434 if (rv != SDCH_OK) { 435 if (rv != SDCH_OK) {
435 RecordDictionaryFate(DICTIONARY_FATE_FETCH_MANAGER_REFUSED); 436 RecordDictionaryFate(DICTIONARY_FATE_FETCH_MANAGER_REFUSED);
436 SdchManager::SdchErrorRecovery(rv); 437 SdchManager::SdchErrorRecovery(rv);
437 net_log.AddEvent(NetLog::TYPE_SDCH_DICTIONARY_ERROR, 438 net_log.AddEvent(NetLogEventType::SDCH_DICTIONARY_ERROR,
438 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv, 439 base::Bind(&NetLogSdchDictionaryFetchProblemCallback, rv,
439 dictionary_url, true)); 440 dictionary_url, true));
440 return; 441 return;
441 } 442 }
442 443
443 base::DictionaryValue* pref_dictionary_map = 444 base::DictionaryValue* pref_dictionary_map =
444 GetPersistentStoreDictionaryMap(pref_store_); 445 GetPersistentStoreDictionaryMap(pref_store_);
445 ScopedPrefNotifier scoped_pref_notifier(pref_store_); 446 ScopedPrefNotifier scoped_pref_notifier(pref_store_);
446 447
447 // Remove the old dictionaries. 448 // Remove the old dictionaries.
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 739 }
739 740
740 return true; 741 return true;
741 } 742 }
742 743
743 bool SdchOwner::IsPersistingDictionaries() const { 744 bool SdchOwner::IsPersistingDictionaries() const {
744 return in_memory_pref_store_.get() != nullptr; 745 return in_memory_pref_store_.get() != nullptr;
745 } 746 }
746 747
747 } // namespace net 748 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory.cc ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698