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

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

Issue 2595503002: Record the data use by content type (Closed)
Patch Set: Addressed nits Created 4 years 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_CORE_DATA_USE_USER_DATA_H_ 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 PRECACHE, 45 PRECACHE,
46 NTP_TILES, 46 NTP_TILES,
47 FEEDBACK_UPLOADER, 47 FEEDBACK_UPLOADER,
48 TRACING_UPLOADER, 48 TRACING_UPLOADER,
49 DOM_DISTILLER, 49 DOM_DISTILLER,
50 CLOUD_PRINT, 50 CLOUD_PRINT,
51 SEARCH_PROVIDER_LOGOS, 51 SEARCH_PROVIDER_LOGOS,
52 UPDATE_CLIENT, 52 UPDATE_CLIENT,
53 }; 53 };
54 54
55 // Data use broken by content type. This enum must remain synchronized
56 // with the enum of the same name in metrics/histograms/histograms.xml.
Mark P 2016/12/22 21:40:29 Please follow the guidelines here: https://chromiu
Raj 2016/12/22 23:14:37 Done.
57 enum DataUseContentType {
58 MAIN_FRAME_HTML,
59 NON_MAIN_FRAME_HTML,
60 CSS,
61 IMAGE,
62 JAVASCRIPT,
63 FONT,
64 AUDIO_APPBACKGROUND,
65 AUDIO_TABBACKGROUND,
66 AUDIO,
67 VIDEO_APPBACKGROUND,
68 VIDEO_TABBACKGROUND,
69 VIDEO,
70 OTHER,
Mark P 2016/12/22 21:40:29 Also, it's typical for people to put the unknown/o
Raj 2016/12/22 23:14:37 Done.
71 TYPE_MAX,
72 };
73
55 // The state of the application. Only available on Android and on other 74 // The state of the application. Only available on Android and on other
56 // platforms it is always FOREGROUND. 75 // platforms it is always FOREGROUND.
57 enum AppState { UNKNOWN, BACKGROUND, FOREGROUND }; 76 enum AppState { UNKNOWN, BACKGROUND, FOREGROUND };
58 77
59 DataUseUserData(ServiceName service_name, AppState app_state); 78 DataUseUserData(ServiceName service_name, AppState app_state);
60 ~DataUseUserData() override; 79 ~DataUseUserData() override;
61 80
62 // Helper function to create DataUseUserData. The caller takes the ownership 81 // Helper function to create DataUseUserData. The caller takes the ownership
63 // of the returned object. 82 // of the returned object.
64 static base::SupportsUserData::Data* Create( 83 static base::SupportsUserData::Data* Create(
65 DataUseUserData::ServiceName service); 84 DataUseUserData::ServiceName service);
66 85
67 // Return the service name of the ServiceName enum. 86 // Return the service name of the ServiceName enum.
68 static std::string GetServiceNameAsString(ServiceName service); 87 static std::string GetServiceNameAsString(ServiceName service);
69 88
70 // Services should use this function to attach their |service_name| to the 89 // Services should use this function to attach their |service_name| to the
71 // URLFetcher serving them. 90 // URLFetcher serving them.
72 static void AttachToFetcher(net::URLFetcher* fetcher, 91 static void AttachToFetcher(net::URLFetcher* fetcher,
73 ServiceName service_name); 92 ServiceName service_name);
74 93
75 ServiceName service_name() const { return service_name_; } 94 ServiceName service_name() const { return service_name_; }
76 95
77 AppState app_state() const { return app_state_; } 96 AppState app_state() const { return app_state_; }
78 97
79 void set_app_state(AppState app_state) { app_state_ = app_state; } 98 void set_app_state(AppState app_state) { app_state_ = app_state; }
80 99
100 DataUseContentType content_type() { return content_type_; }
101
102 void set_content_type(DataUseContentType content_type) {
103 content_type_ = content_type;
104 }
105
81 // The key for retrieving back this type of user data. 106 // The key for retrieving back this type of user data.
82 static const void* const kUserDataKey; 107 static const void* const kUserDataKey;
83 108
84 private: 109 private:
85 const ServiceName service_name_; 110 const ServiceName service_name_;
86 111
87 // App state when network access was performed for the request previously. 112 // App state when network access was performed for the request previously.
88 AppState app_state_; 113 AppState app_state_;
89 114
115 DataUseContentType content_type_;
116
90 DISALLOW_COPY_AND_ASSIGN(DataUseUserData); 117 DISALLOW_COPY_AND_ASSIGN(DataUseUserData);
91 }; 118 };
92 119
93 } // namespace data_use_measurement 120 } // namespace data_use_measurement
94 121
95 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ 122 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698