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

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

Issue 2354323002: Propagate network delegate events to ChromeDataUseAscriber. (Closed)
Patch Set: Move delegate creation to ascriber. Created 4 years, 3 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_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>
9 #include <memory>
bengr 2016/09/23 21:21:13 Add a blank line above.
Not at Google. Contact bengr 2016/09/26 16:29:00 Done.
10
11 #include "url/gurl.h"
12
8 namespace net { 13 namespace net {
14 class NetworkDelegate;
9 class URLRequest; 15 class URLRequest;
10 } 16 }
11 17
12 namespace data_use_measurement { 18 namespace data_use_measurement {
13 19
14 class DataUseRecorder; 20 class DataUseRecorder;
15 21
16 // Abstract class that manages instances of DataUseRecorder and maps 22 // Abstract class that manages instances of DataUseRecorder and maps
17 // a URLRequest instance to its appropriate DataUseRecorder. An embedder 23 // a URLRequest instance to its appropriate DataUseRecorder. An embedder
18 // should provide an override if it is interested in tracking data usage. Data 24 // should provide an override if it is interested in tracking data usage. Data
19 // use from all URLRequests mapped to the same DataUseRecorder will be grouped 25 // use from all URLRequests mapped to the same DataUseRecorder will be grouped
20 // together and reported as a single use. 26 // together and reported as a single use.
21 class DataUseAscriber { 27 class DataUseAscriber {
22 public: 28 public:
23 virtual ~DataUseAscriber() {} 29 virtual ~DataUseAscriber() {}
24 30
31 // Creates a network delegate that will be used to track data use.
32 std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate(
33 std::unique_ptr<net::NetworkDelegate> wrapped_network_delegate);
34
25 // Returns the DataUseRecorder to which data usage for the given URL should 35 // Returns the DataUseRecorder to which data usage for the given URL should
26 // be ascribed. If no existing DataUseRecorder exists, a new one will be 36 // be ascribed. If no existing DataUseRecorder exists, a new one will be
27 // created. 37 // created.
28 virtual DataUseRecorder* GetDataUseRecorder( 38 virtual DataUseRecorder* GetDataUseRecorder(
29 const net::URLRequest* request) = 0; 39 const net::URLRequest* request) = 0;
40
41 // Methods called by DataUseNetworkDelegate to propagate data use information:
42 virtual void OnBeforeUrlRequest(net::URLRequest* request);
43
44 virtual void OnBeforeRedirect(net::URLRequest* request,
45 const GURL& new_location);
46
47 virtual void OnNetworkBytesSent(net::URLRequest* request, int64_t bytes_sent);
48
49 virtual void OnNetworkBytesReceived(net::URLRequest* request,
50 int64_t bytes_received);
51
52 virtual void OnUrlRequestCompleted(net::URLRequest* request, bool started);
30 }; 53 };
31 54
32 } // namespace data_use_measurement 55 } // namespace data_use_measurement
33 56
34 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_ 57 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_ASCRIBER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698