OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ |
6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ | 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
| 13 #include <unordered_map> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/containers/hash_tables.h" | |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chrome/browser/android/data_usage/data_use_tab_model.h" | 21 #include "chrome/browser/android/data_usage/data_use_tab_model.h" |
22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
23 | 23 |
24 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
25 #include "base/android/application_status_listener.h" | 25 #include "base/android/application_status_listener.h" |
26 #endif | 26 #endif |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 }; | 164 }; |
165 | 165 |
166 // Class that implements hash operator on DataUseReportKey. | 166 // Class that implements hash operator on DataUseReportKey. |
167 class DataUseReportKeyHash { | 167 class DataUseReportKeyHash { |
168 public: | 168 public: |
169 // A simple heuristical hash function that satisifes the property that two | 169 // A simple heuristical hash function that satisifes the property that two |
170 // equal data structures have the same hash value. | 170 // equal data structures have the same hash value. |
171 size_t operator()(const DataUseReportKey& k) const; | 171 size_t operator()(const DataUseReportKey& k) const; |
172 }; | 172 }; |
173 | 173 |
174 typedef base::hash_map<DataUseReportKey, DataUseReport, DataUseReportKeyHash> | 174 typedef std:: |
175 DataUseReports; | 175 unordered_map<DataUseReportKey, DataUseReport, DataUseReportKeyHash> |
| 176 DataUseReports; |
176 | 177 |
177 // Maximum size of the data use report buffer. Once this limit is reached, new | 178 // Maximum size of the data use report buffer. Once this limit is reached, new |
178 // reports will be ignored. | 179 // reports will be ignored. |
179 // TODO(rajendrant): Instead of the ignoring the new data use report, remove | 180 // TODO(rajendrant): Instead of the ignoring the new data use report, remove |
180 // the oldest report entry. | 181 // the oldest report entry. |
181 static const size_t kMaxBufferSize; | 182 static const size_t kMaxBufferSize; |
182 | 183 |
183 // Adds |data_use| to buffered reports. |data_use| is the received data use | 184 // Adds |data_use| to buffered reports. |data_use| is the received data use |
184 // report. |label| is a non-empty label that applies to |data_use|. |tag| is | 185 // report. |label| is a non-empty label that applies to |data_use|. |tag| is |
185 // the tag to be applied for this data use. |start_time| and |end_time| are | 186 // the tag to be applied for this data use. |start_time| and |end_time| are |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 base::ThreadChecker thread_checker_; | 250 base::ThreadChecker thread_checker_; |
250 | 251 |
251 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseReporter); | 252 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseReporter); |
252 }; | 253 }; |
253 | 254 |
254 } // namespace android | 255 } // namespace android |
255 | 256 |
256 } // namespace chrome | 257 } // namespace chrome |
257 | 258 |
258 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ | 259 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_REPORTER_H_ |
OLD | NEW |