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/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 : manager_(sdch_manager), | 80 : manager_(sdch_manager), |
81 fetcher_(context, | 81 fetcher_(context, |
82 base::Bind(&SdchOwner::OnDictionaryFetched, | 82 base::Bind(&SdchOwner::OnDictionaryFetched, |
83 // Because |fetcher_| is owned by SdchOwner, the | 83 // Because |fetcher_| is owned by SdchOwner, the |
84 // SdchOwner object will be available for the lifetime | 84 // SdchOwner object will be available for the lifetime |
85 // of |fetcher_|. | 85 // of |fetcher_|. |
86 base::Unretained(this))), | 86 base::Unretained(this))), |
87 total_dictionary_bytes_(0), | 87 total_dictionary_bytes_(0), |
88 clock_(new base::DefaultClock), | 88 clock_(new base::DefaultClock), |
89 max_total_dictionary_size_(kMaxTotalDictionarySize), | 89 max_total_dictionary_size_(kMaxTotalDictionarySize), |
90 min_space_for_dictionary_fetch_(kMinSpaceForDictionaryFetch), | 90 min_space_for_dictionary_fetch_(kMinSpaceForDictionaryFetch) |
| 91 // TODO(rmcilroy) Add back memory_pressure_listener_ when |
| 92 // http://crbug.com/447208 is fixed |
91 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
92 // For debugging http://crbug.com/454198; remove when resolved. | 94 // For debugging http://crbug.com/454198; remove when resolved. |
93 destroyed_(0), | 95 , destroyed_(0) |
94 #endif | 96 #endif |
95 memory_pressure_listener_( | 97 { |
96 base::Bind(&SdchOwner::OnMemoryPressure, | |
97 // Because |memory_pressure_listener_| is owned by | |
98 // SdchOwner, the SdchOwner object will be available | |
99 // for the lifetime of |memory_pressure_listener_|. | |
100 base::Unretained(this))) { | |
101 #if defined(OS_CHROMEOS) | 98 #if defined(OS_CHROMEOS) |
102 // For debugging http://crbug.com/454198; remove when resolved. | 99 // For debugging http://crbug.com/454198; remove when resolved. |
103 CHECK(clock_.get()); | 100 CHECK(clock_.get()); |
104 #endif | 101 #endif |
105 manager_->AddObserver(this); | 102 manager_->AddObserver(this); |
106 } | 103 } |
107 | 104 |
108 SdchOwner::~SdchOwner() { | 105 SdchOwner::~SdchOwner() { |
109 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
110 // For debugging http://crbug.com/454198; remove when resolved. | 107 // For debugging http://crbug.com/454198; remove when resolved. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 RecordDictionaryEviction(it->second.use_count, | 309 RecordDictionaryEviction(it->second.use_count, |
313 DICTIONARY_FATE_EVICT_FOR_MEMORY); | 310 DICTIONARY_FATE_EVICT_FOR_MEMORY); |
314 } | 311 } |
315 | 312 |
316 // TODO(rdsmith): Make a distinction between moderate and critical | 313 // TODO(rdsmith): Make a distinction between moderate and critical |
317 // memory pressure. | 314 // memory pressure. |
318 manager_->ClearData(); | 315 manager_->ClearData(); |
319 } | 316 } |
320 | 317 |
321 } // namespace net | 318 } // namespace net |
OLD | NEW |