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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h

Issue 949533004: Rename DataReductionProxyStatisticsPrefs to DataReductionProxyCompressionStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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
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 COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STATIS TICS_PREFS_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRE SSION_STATS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STATIS TICS_PREFS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COMPRE SSION_STATS_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
17 17
18 class PrefChangeRegistrar; 18 class PrefChangeRegistrar;
19 class PrefService; 19 class PrefService;
20 20
21 namespace base { 21 namespace base {
22 class ListValue; 22 class ListValue;
23 class SequencedTaskRunner; 23 class SequencedTaskRunner;
24 class Value; 24 class Value;
25 } 25 }
26 26
27 namespace data_reduction_proxy { 27 namespace data_reduction_proxy {
28 28
29 // Data reduction proxy delayed pref service reduces the number calls to pref 29 // Data reduction proxy delayed pref service reduces the number calls to pref
30 // service by storing prefs in memory and writing to the given PrefService after 30 // service by storing prefs in memory and writing to the given PrefService after
31 // |delay| amount of time. If |delay| is zero, the delayed pref service writes 31 // |delay| amount of time. If |delay| is zero, the delayed pref service writes
32 // directly to the PrefService and does not store the prefs in memory. All 32 // directly to the PrefService and does not store the prefs in memory. All
33 // prefs must be stored and read on the UI thread. 33 // prefs must be stored and read on the UI thread.
34 // TODO(bengr): Rename as DataReductionProxyCompressionStats. 34 class DataReductionProxyCompressionStats {
35 class DataReductionProxyStatisticsPrefs { 35 public:
36 public:
37 // Constructs a data reduction proxy delayed pref service object using 36 // Constructs a data reduction proxy delayed pref service object using
38 // |pref_service|. Writes prefs to |pref_service| after |delay| 37 // |pref_service|. Writes prefs to |pref_service| after |delay|
39 // and stores them in |pref_map_| and |list_pref_map| between writes. 38 // and stores them in |pref_map_| and |list_pref_map| between writes.
40 // If |delay| is zero, writes directly to the PrefService and does not store 39 // If |delay| is zero, writes directly to the PrefService and does not store
41 // in the maps. 40 // in the maps.
42 DataReductionProxyStatisticsPrefs( 41 DataReductionProxyCompressionStats(
43 PrefService* pref_service, 42 PrefService* pref_service,
44 scoped_refptr<base::SequencedTaskRunner> task_runner, 43 scoped_refptr<base::SequencedTaskRunner> task_runner,
45 const base::TimeDelta& delay); 44 const base::TimeDelta& delay);
46 ~DataReductionProxyStatisticsPrefs(); 45 ~DataReductionProxyCompressionStats();
47 46
48 // Loads all data_reduction_proxy::prefs into the |pref_map_| and 47 // Loads all data_reduction_proxy::prefs into the |pref_map_| and
49 // |list_pref_map_|. 48 // |list_pref_map_|.
50 void Init(); 49 void Init();
51 50
52 void OnUpdateContentLengths(); 51 void OnUpdateContentLengths();
53 52
54 // Gets the int64 pref at |pref_path| from the |DataReductionProxyPrefMap|. 53 // Gets the int64 pref at |pref_path| from the |DataReductionProxyPrefMap|.
55 int64 GetInt64(const char* pref_path); 54 int64 GetInt64(const char* pref_path);
56 55
57 // Updates the pref value in the |DataReductionProxyPrefMap| map. 56 // Updates the pref value in the |DataReductionProxyPrefMap| map.
58 // The pref is later written to |pref service_|. 57 // The pref is later written to |pref service_|.
59 void SetInt64(const char* pref_path, int64 pref_value); 58 void SetInt64(const char* pref_path, int64 pref_value);
60 59
61 // Gets the pref list at |pref_path| from the |DataReductionProxyPrefMap|. 60 // Gets the pref list at |pref_path| from the |DataReductionProxyPrefMap|.
62 base::ListValue* GetList(const char* pref_path); 61 base::ListValue* GetList(const char* pref_path);
63 62
64 // Writes the prefs stored in |DataReductionProxyPrefMap| and 63 // Writes the prefs stored in |DataReductionProxyPrefMap| and
65 // |DataReductionProxyListPrefMap| to |pref_service|. 64 // |DataReductionProxyListPrefMap| to |pref_service|.
66 void WritePrefs(); 65 void WritePrefs();
67 66
68 // Creates a |Value| summary of the persistent state of the network session. 67 // Creates a |Value| summary of the persistent state of the network session.
69 // The caller is responsible for deleting the returned value. 68 // The caller is responsible for deleting the returned value.
70 // Must be called on the UI thread. 69 // Must be called on the UI thread.
71 base::Value* HistoricNetworkStatsInfoToValue(); 70 base::Value* HistoricNetworkStatsInfoToValue();
72 71
73 base::WeakPtr<DataReductionProxyStatisticsPrefs> GetWeakPtr(); 72 base::WeakPtr<DataReductionProxyCompressionStats> GetWeakPtr();
74 73
75 private: 74 private:
76 typedef std::map<const char*, int64> DataReductionProxyPrefMap; 75 typedef std::map<const char*, int64> DataReductionProxyPrefMap;
77 typedef base::ScopedPtrHashMap<const char*, base::ListValue> 76 typedef base::ScopedPtrHashMap<const char*, base::ListValue>
78 DataReductionProxyListPrefMap; 77 DataReductionProxyListPrefMap;
79 78
80 // Gets the value of |pref| from the pref service and adds it to the 79 // Gets the value of |pref| from the pref service and adds it to the
81 // |pref_map|. 80 // |pref_map|.
82 void InitInt64Pref(const char* pref); 81 void InitInt64Pref(const char* pref);
83 82
84 // Gets the value of |pref| from the pref service and adds it to the 83 // Gets the value of |pref| from the pref service and adds it to the
85 // |list_pref_map|. 84 // |list_pref_map|.
(...skipping 17 matching lines...) Expand all
103 102
104 PrefService* pref_service_; 103 PrefService* pref_service_;
105 scoped_refptr<base::SequencedTaskRunner> task_runner_; 104 scoped_refptr<base::SequencedTaskRunner> task_runner_;
106 const base::TimeDelta delay_; 105 const base::TimeDelta delay_;
107 bool delayed_task_posted_; 106 bool delayed_task_posted_;
108 DataReductionProxyPrefMap pref_map_; 107 DataReductionProxyPrefMap pref_map_;
109 DataReductionProxyListPrefMap list_pref_map_; 108 DataReductionProxyListPrefMap list_pref_map_;
110 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; 109 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
111 base::ThreadChecker thread_checker_; 110 base::ThreadChecker thread_checker_;
112 111
113 base::WeakPtrFactory<DataReductionProxyStatisticsPrefs> weak_factory_; 112 base::WeakPtrFactory<DataReductionProxyCompressionStats> weak_factory_;
114 113
115 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyStatisticsPrefs); 114 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyCompressionStats);
116 }; 115 };
117 116
118 } // namespace data_reduction_proxy 117 } // namespace data_reduction_proxy
119 118
120 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_STA TISTICS_PREFS_H_ 119 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_COM PRESSION_STATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698