| OLD | NEW |
| 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 Loading... |
| 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. |
| 57 // These values are written to logs. New enum values can be added, but |
| 58 // existing enums must never be renumbered or deleted and reused. |
| 59 enum DataUseContentType { |
| 60 OTHER = 0, |
| 61 MAIN_FRAME_HTML = 1, |
| 62 NON_MAIN_FRAME_HTML = 2, |
| 63 CSS = 3, |
| 64 IMAGE = 4, |
| 65 JAVASCRIPT = 5, |
| 66 FONT = 6, |
| 67 AUDIO_APPBACKGROUND = 7, |
| 68 AUDIO_TABBACKGROUND = 8, |
| 69 AUDIO = 9, |
| 70 VIDEO_APPBACKGROUND = 10, |
| 71 VIDEO_TABBACKGROUND = 11, |
| 72 VIDEO = 12, |
| 73 TYPE_MAX = 13, |
| 74 }; |
| 75 |
| 55 // The state of the application. Only available on Android and on other | 76 // The state of the application. Only available on Android and on other |
| 56 // platforms it is always FOREGROUND. | 77 // platforms it is always FOREGROUND. |
| 57 enum AppState { UNKNOWN, BACKGROUND, FOREGROUND }; | 78 enum AppState { UNKNOWN, BACKGROUND, FOREGROUND }; |
| 58 | 79 |
| 59 DataUseUserData(ServiceName service_name, AppState app_state); | 80 DataUseUserData(ServiceName service_name, AppState app_state); |
| 60 ~DataUseUserData() override; | 81 ~DataUseUserData() override; |
| 61 | 82 |
| 62 // Helper function to create DataUseUserData. The caller takes the ownership | 83 // Helper function to create DataUseUserData. The caller takes the ownership |
| 63 // of the returned object. | 84 // of the returned object. |
| 64 static base::SupportsUserData::Data* Create( | 85 static base::SupportsUserData::Data* Create( |
| 65 DataUseUserData::ServiceName service); | 86 DataUseUserData::ServiceName service); |
| 66 | 87 |
| 67 // Return the service name of the ServiceName enum. | 88 // Return the service name of the ServiceName enum. |
| 68 static std::string GetServiceNameAsString(ServiceName service); | 89 static std::string GetServiceNameAsString(ServiceName service); |
| 69 | 90 |
| 70 // Services should use this function to attach their |service_name| to the | 91 // Services should use this function to attach their |service_name| to the |
| 71 // URLFetcher serving them. | 92 // URLFetcher serving them. |
| 72 static void AttachToFetcher(net::URLFetcher* fetcher, | 93 static void AttachToFetcher(net::URLFetcher* fetcher, |
| 73 ServiceName service_name); | 94 ServiceName service_name); |
| 74 | 95 |
| 75 ServiceName service_name() const { return service_name_; } | 96 ServiceName service_name() const { return service_name_; } |
| 76 | 97 |
| 77 AppState app_state() const { return app_state_; } | 98 AppState app_state() const { return app_state_; } |
| 78 | 99 |
| 79 void set_app_state(AppState app_state) { app_state_ = app_state; } | 100 void set_app_state(AppState app_state) { app_state_ = app_state; } |
| 80 | 101 |
| 102 DataUseContentType content_type() { return content_type_; } |
| 103 |
| 104 void set_content_type(DataUseContentType content_type) { |
| 105 content_type_ = content_type; |
| 106 } |
| 107 |
| 81 // The key for retrieving back this type of user data. | 108 // The key for retrieving back this type of user data. |
| 82 static const void* const kUserDataKey; | 109 static const void* const kUserDataKey; |
| 83 | 110 |
| 84 private: | 111 private: |
| 85 const ServiceName service_name_; | 112 const ServiceName service_name_; |
| 86 | 113 |
| 87 // App state when network access was performed for the request previously. | 114 // App state when network access was performed for the request previously. |
| 88 AppState app_state_; | 115 AppState app_state_; |
| 89 | 116 |
| 117 DataUseContentType content_type_; |
| 118 |
| 90 DISALLOW_COPY_AND_ASSIGN(DataUseUserData); | 119 DISALLOW_COPY_AND_ASSIGN(DataUseUserData); |
| 91 }; | 120 }; |
| 92 | 121 |
| 93 } // namespace data_use_measurement | 122 } // namespace data_use_measurement |
| 94 | 123 |
| 95 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ | 124 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CORE_DATA_USE_USER_DATA_H_ |
| OLD | NEW |