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

Side by Side Diff: components/data_use_measurement/core/data_use.h

Issue 2865913002: Support for identifying traffic type in data use ascriber (Closed)
Patch Set: compile fix Created 3 years, 7 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 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 class TrafficType {
22 DataUse(const DataUse& other); 22 // Unknown type. URLRequests for arbitrary scheme such as blob, file,
23 // extensions, chrome URLs fall under this bucket - url/url_constants.cc
24 // TODO(rajendrant): Record metrics on the distribution of these type. It is
25 // also possible to remove this UNKNOWN type altogether by skipping the URL
26 // schemes that do not make use of network.
27 UNKNOWN,
28
29 // User initiated traffic.
30 USER_TRAFFIC,
31
32 // Chrome services.
33 SERVICES,
34
35 // Fetch from ServiceWorker.
36 SERVICE_WORKER,
37 };
38
39 explicit DataUse(TrafficType traffic_type);
23 ~DataUse(); 40 ~DataUse();
24 41
25 // Merge data use from another instance. 42 // Merge data use from another instance.
26 void MergeFrom(const DataUse& other); 43 void MergeFrom(const DataUse& other);
27 44
28 const GURL& url() const { return url_; } 45 const GURL& url() const { return url_; }
29 46
30 void set_url(const GURL& url) { url_ = url; } 47 void set_url(const GURL& url) { url_ = url; }
31 48
32 const std::string& description() const { return description_; } 49 const std::string& description() const { return description_; }
33 50
34 void set_description(const std::string& description) { 51 void set_description(const std::string& description) {
35 description_ = description; 52 description_ = description;
36 } 53 }
37 54
38 int64_t total_bytes_received() const { return total_bytes_received_; } 55 int64_t total_bytes_received() const { return total_bytes_received_; }
39 56
40 int64_t total_bytes_sent() const { return total_bytes_sent_; } 57 int64_t total_bytes_sent() const { return total_bytes_sent_; }
41 58
59 TrafficType traffic_type() const { return traffic_type_; }
60
42 private: 61 private:
62 // TODO(rajendrant): Remove this friend after adding member function to
63 // increment total sent/received bytes.
43 friend class DataUseRecorder; 64 friend class DataUseRecorder;
44 65
45 GURL url_; 66 GURL url_;
46 std::string description_; 67 std::string description_;
68 const TrafficType traffic_type_;
47 69
48 int64_t total_bytes_sent_; 70 int64_t total_bytes_sent_;
49 int64_t total_bytes_received_; 71 int64_t total_bytes_received_;
72
73 DISALLOW_COPY_AND_ASSIGN(DataUse);
50 }; 74 };
51 75
52 } // namespace data_use_measurement 76 } // namespace data_use_measurement
53 77
54 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_ 78 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_H_
OLDNEW
« no previous file with comments | « chrome/browser/data_use_measurement/chrome_data_use_recorder.cc ('k') | components/data_use_measurement/core/data_use.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698