Chromium Code Reviews| 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 COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ | 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ |
| 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ | 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace data_use_measurement { | 16 namespace data_use_measurement { |
| 17 | 17 |
| 18 // Class to store total network data used by some entity. | 18 // Class to store total network data used by some entity. |
| 19 class DataUse { | 19 class DataUse { |
| 20 public: | 20 public: |
| 21 DataUse(); | 21 enum TrafficType { |
|
tbansal1
2017/05/12 15:59:58
can this be enum class?
https://groups.google.com/
rajendrant
2017/05/16 00:50:08
Done.
| |
| 22 // Unknown. | |
| 23 UNKNOWN, | |
|
tbansal1
2017/05/12 15:59:58
May be add a TODO to record metrics on the distrib
rajendrant
2017/05/16 00:50:08
Done.
| |
| 24 | |
| 25 // User initiated traffic. | |
| 26 USER_TRAFFIC, | |
| 27 | |
| 28 // Chrome services. | |
| 29 SERVICES, | |
| 30 | |
| 31 // Fetch from ServiceWorker. | |
| 32 SERVICE_WORKER, | |
| 33 }; | |
| 34 | |
| 35 DataUse(TrafficType traffic_type); | |
|
tbansal1
2017/05/12 15:59:58
explicit
rajendrant
2017/05/16 00:50:08
Done.
| |
| 22 DataUse(const DataUse& other); | 36 DataUse(const DataUse& other); |
| 23 ~DataUse(); | 37 ~DataUse(); |
| 24 | 38 |
| 25 // Merge data use from another instance. | 39 // Merge data use from another instance. |
| 26 void MergeFrom(const DataUse& other); | 40 void MergeFrom(const DataUse& other); |
| 27 | 41 |
| 28 const GURL& url() const { return url_; } | 42 const GURL& url() const { return url_; } |
| 29 | 43 |
| 30 void set_url(const GURL& url) { url_ = url; } | 44 void set_url(const GURL& url) { url_ = url; } |
| 31 | 45 |
| 32 const std::string& description() const { return description_; } | 46 const std::string& description() const { return description_; } |
| 33 | 47 |
| 34 void set_description(const std::string& description) { | 48 void set_description(const std::string& description) { |
| 35 description_ = description; | 49 description_ = description; |
| 36 } | 50 } |
| 37 | 51 |
| 38 int64_t total_bytes_received() const { return total_bytes_received_; } | 52 int64_t total_bytes_received() const { return total_bytes_received_; } |
| 39 | 53 |
| 40 int64_t total_bytes_sent() const { return total_bytes_sent_; } | 54 int64_t total_bytes_sent() const { return total_bytes_sent_; } |
| 41 | 55 |
| 56 TrafficType traffic_type() { return traffic_type_; } | |
|
tbansal1
2017/05/12 15:59:58
const function
rajendrant
2017/05/16 00:50:08
Done.
| |
| 57 | |
| 42 private: | 58 private: |
| 43 friend class DataUseRecorder; | 59 friend class DataUseRecorder; |
|
tbansal1
2017/05/12 15:59:58
TODO to remove this friend.
This probably means th
rajendrant
2017/05/16 00:50:08
Done.
| |
| 44 | 60 |
| 45 GURL url_; | 61 GURL url_; |
| 46 std::string description_; | 62 std::string description_; |
| 63 const TrafficType traffic_type_; | |
| 47 | 64 |
| 48 int64_t total_bytes_sent_; | 65 int64_t total_bytes_sent_; |
| 49 int64_t total_bytes_received_; | 66 int64_t total_bytes_received_; |
|
tbansal1
2017/05/12 15:59:58
May be add a TODO to add thread checker.
tbansal1
2017/05/12 15:59:58
DISALLOW_COPY_AND_ASSIGN
or override the assignmen
rajendrant
2017/05/16 00:50:08
Done.
rajendrant
2017/05/16 00:50:08
Thread checker could be too much for this class. T
| |
| 50 }; | 67 }; |
| 51 | 68 |
| 52 } // namespace data_use_measurement | 69 } // namespace data_use_measurement |
| 53 | 70 |
| 54 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ | 71 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ |
| OLD | NEW |