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 #if defined(OS_CHROMEOS) | 91 // TODO(rmcilroy) Add back memory_pressure_listener_ when |
92 // http://crbug.com/447208 is fixed | |
93 #if !defined(OS_CHROMEOS) | |
94 { | |
95 #else | |
92 // For debugging http://crbug.com/454198; remove when resolved. | 96 // For debugging http://crbug.com/454198; remove when resolved. |
93 destroyed_(0), | 97 , destroyed_(0) { |
94 #endif | |
95 memory_pressure_listener_( | |
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) | |
102 // For debugging http://crbug.com/454198; remove when resolved. | 98 // For debugging http://crbug.com/454198; remove when resolved. |
103 CHECK(clock_.get()); | 99 CHECK(clock_.get()); |
104 #endif | 100 #endif |
davidben
2015/02/28 00:18:18
Nit: the ifdef'ing might be less scary if you do..
rmcilroy
2015/02/28 00:33:09
Done.
| |
105 manager_->AddObserver(this); | 101 manager_->AddObserver(this); |
106 } | 102 } |
107 | 103 |
108 SdchOwner::~SdchOwner() { | 104 SdchOwner::~SdchOwner() { |
109 #if defined(OS_CHROMEOS) | 105 #if defined(OS_CHROMEOS) |
110 // For debugging http://crbug.com/454198; remove when resolved. | 106 // For debugging http://crbug.com/454198; remove when resolved. |
111 CHECK_EQ(0u, destroyed_); | 107 CHECK_EQ(0u, destroyed_); |
112 CHECK(clock_.get()); | 108 CHECK(clock_.get()); |
113 clock_.reset(); | 109 clock_.reset(); |
114 #endif | 110 #endif |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 RecordDictionaryEviction(it->second.use_count, | 308 RecordDictionaryEviction(it->second.use_count, |
313 DICTIONARY_FATE_EVICT_FOR_MEMORY); | 309 DICTIONARY_FATE_EVICT_FOR_MEMORY); |
314 } | 310 } |
315 | 311 |
316 // TODO(rdsmith): Make a distinction between moderate and critical | 312 // TODO(rdsmith): Make a distinction between moderate and critical |
317 // memory pressure. | 313 // memory pressure. |
318 manager_->ClearData(); | 314 manager_->ClearData(); |
319 } | 315 } |
320 | 316 |
321 } // namespace net | 317 } // namespace net |
OLD | NEW |