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 #include "components/data_use_measurement/core/data_use_user_data.h" | 5 #include "components/data_use_measurement/core/data_use_user_data.h" |
6 | 6 |
7 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
8 #include "base/android/application_status_listener.h" | 8 #include "base/android/application_status_listener.h" |
9 #endif | 9 #endif |
10 | 10 |
| 11 #include "base/memory/ptr_util.h" |
11 #include "net/url_request/url_fetcher.h" | 12 #include "net/url_request/url_fetcher.h" |
12 | 13 |
13 namespace data_use_measurement { | 14 namespace data_use_measurement { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 DataUseUserData::AppState GetCurrentAppState() { | 18 DataUseUserData::AppState GetCurrentAppState() { |
18 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
19 return base::android::ApplicationStatusListener::GetState() == | 20 return base::android::ApplicationStatusListener::GetState() == |
20 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES | 21 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES |
(...skipping 12 matching lines...) Expand all Loading... |
33 app_state_(app_state), | 34 app_state_(app_state), |
34 content_type_(DataUseContentType::OTHER) {} | 35 content_type_(DataUseContentType::OTHER) {} |
35 | 36 |
36 DataUseUserData::~DataUseUserData() {} | 37 DataUseUserData::~DataUseUserData() {} |
37 | 38 |
38 // static | 39 // static |
39 const void* const DataUseUserData::kUserDataKey = | 40 const void* const DataUseUserData::kUserDataKey = |
40 &DataUseUserData::kUserDataKey; | 41 &DataUseUserData::kUserDataKey; |
41 | 42 |
42 // static | 43 // static |
43 base::SupportsUserData::Data* DataUseUserData::Create( | 44 std::unique_ptr<base::SupportsUserData::Data> DataUseUserData::Create( |
44 ServiceName service_name) { | 45 ServiceName service_name) { |
45 return new DataUseUserData(service_name, GetCurrentAppState()); | 46 return base::MakeUnique<DataUseUserData>(service_name, GetCurrentAppState()); |
46 } | 47 } |
47 | 48 |
48 // static | 49 // static |
49 std::string DataUseUserData::GetServiceNameAsString(ServiceName service_name) { | 50 std::string DataUseUserData::GetServiceNameAsString(ServiceName service_name) { |
50 switch (service_name) { | 51 switch (service_name) { |
51 case SUGGESTIONS: | 52 case SUGGESTIONS: |
52 return "Suggestions"; | 53 return "Suggestions"; |
53 case NOT_TAGGED: | 54 case NOT_TAGGED: |
54 return "NotTagged"; | 55 return "NotTagged"; |
55 case TRANSLATE: | 56 case TRANSLATE: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 136 } |
136 | 137 |
137 // static | 138 // static |
138 void DataUseUserData::AttachToFetcher(net::URLFetcher* fetcher, | 139 void DataUseUserData::AttachToFetcher(net::URLFetcher* fetcher, |
139 ServiceName service_name) { | 140 ServiceName service_name) { |
140 fetcher->SetURLRequestUserData(kUserDataKey, | 141 fetcher->SetURLRequestUserData(kUserDataKey, |
141 base::Bind(&Create, service_name)); | 142 base::Bind(&Create, service_name)); |
142 } | 143 } |
143 | 144 |
144 } // namespace data_use_measurement | 145 } // namespace data_use_measurement |
OLD | NEW |