OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | |
6 #define COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | |
7 | |
8 #include <stdint.h> | |
9 #include <string> | |
mmenke
2015/08/31 17:41:29
Blank line needed between C++ and C headers.
amohammadkhan
2015/09/01 04:52:48
Done.
| |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "build/build_config.h" | |
13 #include "components/data_use_measurement/core/data_use_user_data.h" | |
14 | |
15 #if defined(OS_ANDROID) | |
16 #include "base/android/application_status_listener.h" | |
17 #endif | |
18 | |
19 namespace net { | |
20 class URLRequest; | |
21 } | |
22 | |
23 namespace data_use_measurement { | |
24 | |
25 class DataUseMeasurement { | |
Alexei Svitkine (slow)
2015/08/31 17:26:31
Class should have a comment.
mmenke
2015/08/31 17:41:29
Need class level docs.
amohammadkhan
2015/09/01 04:52:48
Done.
amohammadkhan
2015/09/01 04:52:49
Done.
| |
26 public: | |
27 // If the OS is Android, this constructor instantiate a listener object and | |
28 // bind its callback. | |
Alexei Svitkine (slow)
2015/08/31 17:26:31
This comment is not useful.
First, it seems it's
amohammadkhan
2015/09/01 04:52:48
Done.
| |
29 DataUseMeasurement(); | |
30 | |
31 ~DataUseMeasurement(); | |
32 | |
33 // Records the data use of the |request|. | |
34 void ReportDataUseUMA(const net::URLRequest* request); | |
35 | |
36 #if defined(OS_ANDROID) | |
37 // If a change in application status happens, this function is called and this | |
38 // function sets app_state_ appropriately. | |
39 void OnApplicationStateChange( | |
40 base::android::ApplicationState application_state); | |
mmenke
2015/08/31 17:41:29
If this is only public for tests, I suggest making
amohammadkhan
2015/09/01 04:52:48
Done.
| |
41 #endif | |
Alexei Svitkine (slow)
2015/08/31 17:26:31
Add an empty line after this.
amohammadkhan
2015/09/01 04:52:48
Done.
| |
42 private: | |
43 // Specifies that data is received or sent, respectively. | |
44 enum TrafficDirection { DOWNLOAD, UPLOAD }; | |
45 | |
46 // The state of the application. Only available on Android and on other | |
47 // platforms it is always FOREGROUND. | |
48 enum AppState { BACKGROUND, FOREGROUND }; | |
49 | |
50 // The type of network connection that was used. | |
51 enum ConnectionType { CELLULAR, NOT_CELLULAR }; | |
52 | |
53 // The reason a request was sent. Whether the traffic originates from | |
54 // user's request for a web site or a service is the source of the traffic. | |
55 enum ChromeTrafficType { USER_TRAFFIC, SERVICE_TRAFFIC }; | |
56 | |
57 // Returns the current application state (Foreground or Background). It always | |
58 // returns Foreground if Chrome is not running on Android. | |
59 AppState CurrentAppState(); | |
60 | |
61 // Returns the current connection type (Cellular or Not cellular). | |
62 ConnectionType CurrentConnectionType(); | |
63 | |
64 // The function produces a string representing the status of the Chrome when | |
65 // recording is done. Its output is in following form: dir.appState.ConnState | |
66 // for example: Upload.Foreground.Cellular is one of its possible outputs. | |
67 std::string GetDimensionForHistogramName(TrafficDirection dir); | |
68 | |
69 // Helper function used to record data use of services. | |
70 void ReportDataUsage( | |
71 data_use_measurement::DataUseUserData::ServiceType service, | |
72 TrafficDirection dir, | |
73 int64_t message_size); | |
74 | |
75 // Helper function used for reporting data use of URLRequests. | |
76 void ReportDataUsageURLRequest(ChromeTrafficType service_type, | |
77 TrafficDirection dir, | |
78 int64_t message_size); | |
79 | |
80 #if defined(OS_ANDROID) | |
81 // Application listener store the last known state of the application in this | |
82 // field. | |
83 base::android::ApplicationState app_state_; | |
84 | |
85 // ApplicationStatusListener used to monitor that application is in foreground | |
86 // or in background. It is owned by DataUseMeasurement | |
87 scoped_ptr<base::android::ApplicationStatusListener> app_listener_; | |
88 #endif | |
89 }; | |
Alexei Svitkine (slow)
2015/08/31 17:26:31
DISALLOW_COPY_AND_ASSIGN
amohammadkhan
2015/09/01 04:52:49
Done.
| |
90 | |
91 } // namespace data_use_measurement | |
92 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | |
OLD | NEW |