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

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

Issue 1355893004: Complete the layered architecture of data_use_measurement component. Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Created 5 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 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_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_MEASUREMENT_H_
6 #define COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_MEASUREMENT_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/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "components/data_use_measurement/core/data_use_measurement_delegate.h"
15 #include "components/data_use_measurement/core/data_use_user_data.h" 16 #include "components/data_use_measurement/core/data_use_user_data.h"
16 17
17 #if defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
18 #include "base/android/application_status_listener.h" 19 #include "base/android/application_status_listener.h"
19 #endif 20 #endif
20 21
21 namespace net { 22 namespace net {
22 class URLRequest; 23 class URLRequest;
23 } 24 }
24 25
25 namespace data_use_measurement { 26 namespace data_use_measurement {
26 27
27 // Records the data use of user traffic and various services in UMA histograms. 28 // Records the data use of user traffic and various services in UMA histograms.
28 // The UMA is broken down by network technology used (Wi-Fi vs cellular). On 29 // The UMA is broken down by network technology used (Wi-Fi vs cellular). On
29 // Android, the UMA is further broken down by whether the application was in the 30 // Android, the UMA is further broken down by whether the application was in the
30 // background or foreground during the request. 31 // background or foreground during the request.
31 // TODO(amohammadkhan): Complete the layered architecture. 32 // TODO(amohammadkhan): Complete the layered architecture.
32 // http://crbug.com/527460 33 // http://crbug.com/527460
33 class DataUseMeasurement { 34 class DataUseMeasurement {
34 public: 35 public:
35 DataUseMeasurement(); 36 // This class gets the ownership of data_use_measurement_delegate object.
37 DataUseMeasurement(DataUseMeasurementDelegate* data_use_measurement_delegate);
36 ~DataUseMeasurement(); 38 ~DataUseMeasurement();
37 39
38 // Records the data use of the |request|, thus |request| must be non-null. 40 // Records the data use of the |request|, thus |request| must be non-null.
39 void ReportDataUseUMA(const net::URLRequest* request) const; 41 void ReportDataUseUMA(const net::URLRequest* request) const;
40 42
41 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
42 // This function should just be used for testing purposes. A change in 44 // This function should just be used for testing purposes. A change in
43 // application state can be simulated by calling this function. 45 // application state can be simulated by calling this function.
44 void OnApplicationStateChangeForTesting( 46 void OnApplicationStateChangeForTesting(
45 base::android::ApplicationState application_state); 47 base::android::ApplicationState application_state);
(...skipping 28 matching lines...) Expand all
74 76
75 // A helper function used to record data use of services. It gets the size of 77 // A helper function used to record data use of services. It gets the size of
76 // exchanged message, its direction (which is upstream or downstream) and 78 // exchanged message, its direction (which is upstream or downstream) and
77 // reports to two histogram groups. DataUse.MessageSize.ServiceName and 79 // reports to two histogram groups. DataUse.MessageSize.ServiceName and
78 // DataUse.Services.{Dimensions}. In the second one, services are buckets. 80 // DataUse.Services.{Dimensions}. In the second one, services are buckets.
79 void ReportDataUsageServices( 81 void ReportDataUsageServices(
80 data_use_measurement::DataUseUserData::ServiceName service, 82 data_use_measurement::DataUseUserData::ServiceName service,
81 TrafficDirection dir, 83 TrafficDirection dir,
82 int64_t message_size) const; 84 int64_t message_size) const;
83 85
86 scoped_ptr<DataUseMeasurementDelegate> data_use_measurement_delegate_;
87
84 #if defined(OS_ANDROID) 88 #if defined(OS_ANDROID)
85 // Application listener store the last known state of the application in this 89 // Application listener store the last known state of the application in this
86 // field. 90 // field.
87 base::android::ApplicationState app_state_; 91 base::android::ApplicationState app_state_;
88 92
89 // ApplicationStatusListener used to monitor whether the application is in the 93 // ApplicationStatusListener used to monitor whether the application is in the
90 // foreground or in the background. It is owned by DataUseMeasurement. 94 // foreground or in the background. It is owned by DataUseMeasurement.
91 scoped_ptr<base::android::ApplicationStatusListener> app_listener_; 95 scoped_ptr<base::android::ApplicationStatusListener> app_listener_;
92 #endif 96 #endif
93 97
94 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurement); 98 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurement);
95 }; 99 };
96 100
97 } // namespace data_use_measurement 101 } // namespace data_use_measurement
98 102
99 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ 103 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_MEASUREMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698