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

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

Issue 2462983003: Move data use measurement to DataUseNetworkDelegate (Closed)
Patch Set: Rebased and fixed nits Created 4 years, 1 month 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_ASCRIBER_H_ 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_
6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_ 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "components/data_use_measurement/core/data_use_measurement.h"
13 #include "components/metrics/data_use_tracker.h"
12 #include "url/gurl.h" 14 #include "url/gurl.h"
13 15
14 namespace net { 16 namespace net {
15 class NetworkDelegate; 17 class NetworkDelegate;
16 class URLRequest; 18 class URLRequest;
17 } 19 }
18 20
19 namespace data_use_measurement { 21 namespace data_use_measurement {
20 22
21 class DataUseRecorder; 23 class DataUseRecorder;
24 class URLRequestClassifier;
22 25
23 // Abstract class that manages instances of DataUseRecorder and maps 26 // Abstract class that manages instances of DataUseRecorder and maps
24 // a URLRequest instance to its appropriate DataUseRecorder. An embedder 27 // a URLRequest instance to its appropriate DataUseRecorder. An embedder
25 // should provide an override if it is interested in tracking data usage. Data 28 // should provide an override if it is interested in tracking data usage. Data
26 // use from all URLRequests mapped to the same DataUseRecorder will be grouped 29 // use from all URLRequests mapped to the same DataUseRecorder will be grouped
27 // together and reported as a single use. 30 // together and reported as a single use.
28 class DataUseAscriber { 31 class DataUseAscriber {
29 public: 32 public:
30 virtual ~DataUseAscriber() {} 33 virtual ~DataUseAscriber() {}
31 34
32 // Creates a network delegate that will be used to track data use. 35 // Creates a network delegate that will be used to track data use.
33 std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate( 36 std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate(
34 std::unique_ptr<net::NetworkDelegate> wrapped_network_delegate); 37 std::unique_ptr<net::NetworkDelegate> wrapped_network_delegate,
38 const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder);
35 39
36 // Returns the DataUseRecorder to which data usage for the given URL should 40 // Returns the DataUseRecorder to which data usage for the given URL should
37 // be ascribed. If no existing DataUseRecorder exists, a new one will be 41 // be ascribed. If no existing DataUseRecorder exists, a new one will be
38 // created. 42 // created.
39 virtual DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) = 0; 43 virtual DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) = 0;
40 44
41 // Methods called by DataUseNetworkDelegate to propagate data use information: 45 // Methods called by DataUseNetworkDelegate to propagate data use information:
42 virtual void OnBeforeUrlRequest(net::URLRequest* request); 46 virtual void OnBeforeUrlRequest(net::URLRequest* request);
43 47
44 virtual void OnBeforeRedirect(net::URLRequest* request, 48 virtual void OnBeforeRedirect(net::URLRequest* request,
45 const GURL& new_location); 49 const GURL& new_location);
46 50
47 virtual void OnNetworkBytesSent(net::URLRequest* request, int64_t bytes_sent); 51 virtual void OnNetworkBytesSent(net::URLRequest* request, int64_t bytes_sent);
48 52
49 virtual void OnNetworkBytesReceived(net::URLRequest* request, 53 virtual void OnNetworkBytesReceived(net::URLRequest* request,
50 int64_t bytes_received); 54 int64_t bytes_received);
51 55
52 virtual void OnUrlRequestDestroyed(net::URLRequest* request); 56 virtual void OnUrlRequestDestroyed(net::URLRequest* request);
57
58 virtual std::unique_ptr<URLRequestClassifier> CreateURLRequestClassifier()
59 const = 0;
53 }; 60 };
54 61
55 } // namespace data_use_measurement 62 } // namespace data_use_measurement
56 63
57 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_ 64 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_
OLDNEW
« no previous file with comments | « components/data_use_measurement/core/DEPS ('k') | components/data_use_measurement/core/data_use_ascriber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698