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 <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" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 load_times_.erase(server_hash); | 289 load_times_.erase(server_hash); |
290 } | 290 } |
291 | 291 |
292 SdchOwner::SdchOwner(SdchManager* sdch_manager, URLRequestContext* context) | 292 SdchOwner::SdchOwner(SdchManager* sdch_manager, URLRequestContext* context) |
293 : manager_(sdch_manager), | 293 : manager_(sdch_manager), |
294 fetcher_(new SdchDictionaryFetcher(context)), | 294 fetcher_(new SdchDictionaryFetcher(context)), |
295 total_dictionary_bytes_(0), | 295 total_dictionary_bytes_(0), |
296 clock_(new base::DefaultClock), | 296 clock_(new base::DefaultClock), |
297 max_total_dictionary_size_(kMaxTotalDictionarySize), | 297 max_total_dictionary_size_(kMaxTotalDictionarySize), |
298 min_space_for_dictionary_fetch_(kMinSpaceForDictionaryFetch), | 298 min_space_for_dictionary_fetch_(kMinSpaceForDictionaryFetch), |
299 memory_pressure_listener_( | 299 memory_pressure_listener_(base::MemoryPressureListener::Create( |
300 base::Bind(&SdchOwner::OnMemoryPressure, | 300 base::Bind(&SdchOwner::OnMemoryPressure, |
301 // Because |memory_pressure_listener_| is owned by | 301 // Because |memory_pressure_listener_| is owned by |
302 // SdchOwner, the SdchOwner object will be available | 302 // SdchOwner, the SdchOwner object will be available |
303 // for the lifetime of |memory_pressure_listener_|. | 303 // for the lifetime of |memory_pressure_listener_|. |
304 base::Unretained(this))), | 304 base::Unretained(this)))), |
305 in_memory_pref_store_(new ValueMapPrefStorage()), | 305 in_memory_pref_store_(new ValueMapPrefStorage()), |
306 external_pref_store_(nullptr), | 306 external_pref_store_(nullptr), |
307 pref_store_(in_memory_pref_store_.get()), | 307 pref_store_(in_memory_pref_store_.get()), |
308 creation_time_(clock_->Now()) { | 308 creation_time_(clock_->Now()) { |
309 manager_->AddObserver(this); | 309 manager_->AddObserver(this); |
310 InitializePrefStore(pref_store_); | 310 InitializePrefStore(pref_store_); |
311 } | 311 } |
312 | 312 |
313 SdchOwner::~SdchOwner() { | 313 SdchOwner::~SdchOwner() { |
314 for (DictionaryPreferenceIterator it(pref_store_); !it.IsAtEnd(); | 314 for (DictionaryPreferenceIterator it(pref_store_); !it.IsAtEnd(); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } | 736 } |
737 | 737 |
738 return true; | 738 return true; |
739 } | 739 } |
740 | 740 |
741 bool SdchOwner::IsPersistingDictionaries() const { | 741 bool SdchOwner::IsPersistingDictionaries() const { |
742 return in_memory_pref_store_.get() != nullptr; | 742 return in_memory_pref_store_.get() != nullptr; |
743 } | 743 } |
744 | 744 |
745 } // namespace net | 745 } // namespace net |
OLD | NEW |