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

Side by Side Diff: components/data_usage/core/data_use_aggregator.h

Issue 1421983002: Include tab IDs when reporting data use accounting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_scoped_vector
Patch Set: Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_USAGE_CORE_DATA_USE_AGGREGATOR_H_ 5 #ifndef COMPONENTS_DATA_USAGE_CORE_DATA_USE_AGGREGATOR_H_
6 #define COMPONENTS_DATA_USAGE_CORE_DATA_USE_AGGREGATOR_H_ 6 #define COMPONENTS_DATA_USAGE_CORE_DATA_USE_AGGREGATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 17 #include "base/observer_list.h"
16 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
17 19
20 class GURL;
21
18 namespace net { 22 namespace net {
19 class URLRequest; 23 class URLRequest;
20 } 24 }
21 25
22 namespace data_usage { 26 namespace data_usage {
23 struct DataUse; 27 struct DataUse;
24 28
25 // Class that collects and aggregates network usage, reporting the usage to 29 // Class that collects and aggregates network usage, reporting the usage to
26 // observers. Should only be used on the IO thread. 30 // observers. Should only be used on the IO thread.
27 class DataUseAggregator { 31 class DataUseAggregator {
28 public: 32 public:
29 class Observer { 33 class Observer {
30 public: 34 public:
31 virtual ~Observer() {} 35 virtual ~Observer() {}
32 // Each of the elements of |data_use_sequence| are guaranteed to be 36 // Each of the elements of |data_use_sequence| are guaranteed to be
33 // non-NULL. 37 // non-NULL.
34 virtual void OnDataUse( 38 virtual void OnDataUse(
35 const std::vector<const DataUse*>& data_use_sequence) = 0; 39 const std::vector<const DataUse*>& data_use_sequence) = 0;
36 }; 40 };
37 41
38 DataUseAggregator(); 42 DataUseAggregator();
39 virtual ~DataUseAggregator(); 43 virtual ~DataUseAggregator();
40 44
41 void AddObserver(Observer* observer); 45 void AddObserver(Observer* observer);
42 void RemoveObserver(Observer* observer); 46 void RemoveObserver(Observer* observer);
43 47
44 // Virtual for testing. 48 // Virtual for testing.
45 virtual void ReportDataUse(const net::URLRequest& request, 49 virtual void ReportDataUse(int64_t tx_bytes,
46 int32_t tab_id, 50 int64_t rx_bytes,
47 int64_t tx_bytes, 51 const GURL& url,
48 int64_t rx_bytes); 52 const base::Time& request_time,
53 const GURL& first_party_for_cookies,
54 int32_t tab_id);
49 55
50 // Account for off-the-record data use. This usage is only kept track of here 56 // Account for off-the-record data use. This usage is only kept track of here
51 // so that it can be taken out of any amortized data usage calculations, and a 57 // so that it can be taken out of any amortized data usage calculations, and a
52 // per-request breakdown of off-the-record data usage will never leave the 58 // per-request breakdown of off-the-record data usage will never leave the
53 // DataUseAggregator. 59 // DataUseAggregator.
54 // Virtual for testing. 60 // Virtual for testing.
55 virtual void ReportOffTheRecordDataUse(int64_t tx_bytes, int64_t rx_bytes); 61 virtual void ReportOffTheRecordDataUse(int64_t tx_bytes, int64_t rx_bytes);
56 62
57 base::WeakPtr<DataUseAggregator> GetWeakPtr(); 63 base::WeakPtr<DataUseAggregator> GetWeakPtr();
58 64
(...skipping 17 matching lines...) Expand all
76 bool is_flush_pending_; 82 bool is_flush_pending_;
77 83
78 base::WeakPtrFactory<DataUseAggregator> weak_ptr_factory_; 84 base::WeakPtrFactory<DataUseAggregator> weak_ptr_factory_;
79 85
80 DISALLOW_COPY_AND_ASSIGN(DataUseAggregator); 86 DISALLOW_COPY_AND_ASSIGN(DataUseAggregator);
81 }; 87 };
82 88
83 } // namespace data_usage 89 } // namespace data_usage
84 90
85 #endif // COMPONENTS_DATA_USAGE_CORE_DATA_USE_AGGREGATOR_H_ 91 #endif // COMPONENTS_DATA_USAGE_CORE_DATA_USE_AGGREGATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698