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

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

Issue 2390603002: Make SdchOwner a client of memory coordinator (Closed)
Patch Set: Fix comments Created 4 years, 2 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 | « no previous file | net/sdch/sdch_owner.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 #ifndef NET_SDCH_SDCH_OWNER_H_ 5 #ifndef NET_SDCH_SDCH_OWNER_H_
6 #define NET_SDCH_SDCH_OWNER_H_ 6 #define NET_SDCH_SDCH_OWNER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/memory_coordinator_client.h"
15 #include "base/memory/memory_pressure_listener.h" 16 #include "base/memory/memory_pressure_listener.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "net/base/sdch_observer.h" 18 #include "net/base/sdch_observer.h"
18 #include "net/url_request/sdch_dictionary_fetcher.h" 19 #include "net/url_request/sdch_dictionary_fetcher.h"
19 20
20 class GURL; 21 class GURL;
21 22
22 namespace base { 23 namespace base {
23 class Clock; 24 class Clock;
24 } 25 }
25 26
26 namespace net { 27 namespace net {
27 class SdchManager; 28 class SdchManager;
28 class URLRequestContext; 29 class URLRequestContext;
29 30
30 // This class owns the SDCH objects not owned as part of URLRequestContext, and 31 // This class owns the SDCH objects not owned as part of URLRequestContext, and
31 // exposes interface for setting SDCH policy. It should be instantiated by 32 // exposes interface for setting SDCH policy. It should be instantiated by
32 // the net/ embedder. 33 // the net/ embedder.
33 // TODO(rdsmith): Implement dictionary prioritization. 34 // TODO(rdsmith): Implement dictionary prioritization.
34 class NET_EXPORT SdchOwner : public SdchObserver { 35 class NET_EXPORT SdchOwner : public SdchObserver,
36 public base::MemoryCoordinatorClient {
35 public: 37 public:
36 // Abstact storage interface for storing settings that allows the embedder 38 // Abstact storage interface for storing settings that allows the embedder
37 // to provide the appropriate storage backend. 39 // to provide the appropriate storage backend.
38 class NET_EXPORT PrefStorage { 40 class NET_EXPORT PrefStorage {
39 public: 41 public:
40 // Possible values returned by GetReadError. This is a subset of the error 42 // Possible values returned by GetReadError. This is a subset of the error
41 // values of Chromium's pref storage that we care about. 43 // values of Chromium's pref storage that we care about.
42 // 44 //
43 // DO NOT CHANGE VALUES. This is logged persistently in a histogram. 45 // DO NOT CHANGE VALUES. This is logged persistently in a histogram.
44 enum ReadError { 46 enum ReadError {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 int use_count; 151 int use_count;
150 size_t size; 152 size_t size;
151 153
152 DictionaryInfo() : use_count(0), size(0) {} 154 DictionaryInfo() : use_count(0), size(0) {}
153 DictionaryInfo(const base::Time& last_used, size_t size) 155 DictionaryInfo(const base::Time& last_used, size_t size)
154 : last_used(last_used), use_count(0), size(size) {} 156 : last_used(last_used), use_count(0), size(size) {}
155 DictionaryInfo(const DictionaryInfo& rhs) = default; 157 DictionaryInfo(const DictionaryInfo& rhs) = default;
156 DictionaryInfo& operator=(const DictionaryInfo& rhs) = default; 158 DictionaryInfo& operator=(const DictionaryInfo& rhs) = default;
157 }; 159 };
158 160
161 // base::MemoryCoordinatorClient implementation:
162 void OnMemoryStateChange(base::MemoryState state) override;
163
159 void OnMemoryPressure( 164 void OnMemoryPressure(
160 base::MemoryPressureListener::MemoryPressureLevel level); 165 base::MemoryPressureListener::MemoryPressureLevel level);
161 166
167 // Clears data to save memory usage.
168 void ClearData();
169
162 // Schedule loading of all dictionaries described in |persisted_info|. 170 // Schedule loading of all dictionaries described in |persisted_info|.
163 // Returns false and does not schedule a load if |persisted_info| has an 171 // Returns false and does not schedule a load if |persisted_info| has an
164 // unsupported version or no dictionaries key. Skips any dictionaries that are 172 // unsupported version or no dictionaries key. Skips any dictionaries that are
165 // malformed in |persisted_info|. 173 // malformed in |persisted_info|.
166 bool SchedulePersistedDictionaryLoads( 174 bool SchedulePersistedDictionaryLoads(
167 const base::DictionaryValue& persisted_info); 175 const base::DictionaryValue& persisted_info);
168 176
169 bool IsPersistingDictionaries() const; 177 bool IsPersistingDictionaries() const;
170 178
171 enum DictionaryFate { 179 enum DictionaryFate {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Creation time for this SdchOwner object, used for reporting temporal memory 269 // Creation time for this SdchOwner object, used for reporting temporal memory
262 // pressure. 270 // pressure.
263 base::Time creation_time_; 271 base::Time creation_time_;
264 272
265 DISALLOW_COPY_AND_ASSIGN(SdchOwner); 273 DISALLOW_COPY_AND_ASSIGN(SdchOwner);
266 }; 274 };
267 275
268 } // namespace net 276 } // namespace net
269 277
270 #endif // NET_SDCH_SDCH_OWNER_H_ 278 #endif // NET_SDCH_SDCH_OWNER_H_
OLDNEW
« no previous file with comments | « no previous file | net/sdch/sdch_owner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698