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

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

Issue 1279543002: Support needed to measure user and service traffic in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewHistogram
Patch Set: Removing few commented lines. Created 5 years, 4 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
(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_H_
sclittle 2015/08/21 23:55:34 Change this to the full path, e.g. COMPONENTS_DATA
amohammadkhan 2015/08/24 23:18:48 Done.
6 #define COMPONENTS_DATA_USE_MEASUREMENT_H_
sclittle 2015/08/21 23:55:34 Move this file and its .cc to the "data_use_measur
amohammadkhan 2015/08/26 22:28:41 Done.
7
sclittle 2015/08/21 23:55:34 Add "#include <stdint.h>" for int64_t.
amohammadkhan 2015/08/24 23:18:48 Done.
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "build/build_config.h"
12
13 #if defined(OS_ANDROID)
14 #include "base/android/application_status_listener.h"
15 #endif
16
17 namespace net {
18 class URLRequest;
19 }
20
21 namespace data_use_measurement {
22
23 class DataUseMeasurement {
24 public:
25 // This constructor instantiate a listener object and bind its callback.
26 DataUseMeasurement();
27
28 // Records the data use of the |request|.
29 void ReportDataUseUMA(const net::URLRequest* request);
30
31 #if defined(OS_ANDROID)
32 // If a change in application status happens, this function is called and this
33 // function sets app_state_ appropriately.
34 void OnApplicationStateChange(
35 base::android::ApplicationState application_state);
36 #endif
37 private:
38 // Specifies that data is received or sent, respectively.
39 enum TrafficDirection { DOWNLOAD, UPLOAD };
40
41 // The state of the application. Only available on Android and on other
42 // platforms it is always FOREGROUND.
43 enum AppState { BACKGROUND, FOREGROUND };
44
45 // The type of network connection that was used.
46 enum ConnectionType { CELLULAR, NOT_CELLULAR };
47
48 // The reason a request was sent. Whether the traffic originates from
49 // user's request for a web site or a service is the source of the traffic.
50 enum ChromeTrafficType { USER_TRAFFIC, SERVICE_TRAFFIC };
51
52 // Returns the current application state (Foreground or Background). It always
53 // returns Foreground if Chrome is not running on Android.
54 AppState CurrentAppState();
55
56 // Returns the current connection type (Cellular or Not cellular).
57 ConnectionType CurrentConnectionType();
sclittle 2015/08/21 23:55:34 nit: indentation, please run "git cl format" to fo
amohammadkhan 2015/08/24 23:18:48 Done.
58
59 // The function produces a string representing the status of the Chrome when
60 // recording is done. Its output is in following form: dir.appState.ConnState
61 // for example: Upload.Foreground.Cellular is one of its possible outputs.
62 std::string DimensionMaker(TrafficDirection dir);
63
64 // Helper function used to record data use of services.
65 void ReportDataUsage(const std::string& service_name,
66 TrafficDirection dir,
67 int64_t message_size);
68
69 // Helper function used for reporting data use of URLRequests.
70 void ReportDataUsageURLRequest(ChromeTrafficType service_type,
71 TrafficDirection dir,
72 int64_t message_size);
73
74 #if defined(OS_ANDROID)
75 // Application listener store the last known state of the application in this
76 // field.
77 base::android::ApplicationState app_state_;
78
79 // ApplicationStatusListener used to monitor that application is in foreground
80 // or in background. It is owned by DataUseMeasurement
81 base::android::ApplicationStatusListener app_listener_;
sclittle 2015/08/21 23:55:34 Make this a scoped_ptr, and call reset() on it to
amohammadkhan 2015/08/24 23:18:48 Done.
82 #endif
83
84 };
85 }
86 #endif // COMPONENTS_DATA_USE_MEASUREMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698