OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/app_list/app_list_service_impl.h" | 5 #include "chrome/browser/ui/app_list/app_list_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 profile_name != base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe(); | 227 profile_name != base::FilePath(chrome::kSystemProfileDir).AsUTF8Unsafe(); |
228 } | 228 } |
229 | 229 |
230 } // namespace | 230 } // namespace |
231 | 231 |
232 void AppListServiceImpl::RecordAppListLaunch() { | 232 void AppListServiceImpl::RecordAppListLaunch() { |
233 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, | 233 RecordDailyEventFrequency(prefs::kLastAppListLaunchPing, |
234 prefs::kAppListLaunchCount, | 234 prefs::kAppListLaunchCount, |
235 &SendAppListLaunch); | 235 &SendAppListLaunch); |
236 RecordAppListDiscoverability(local_state_, false); | 236 RecordAppListDiscoverability(local_state_, false); |
237 RecordAppListLastLaunch(); | |
238 } | 237 } |
239 | 238 |
240 // static | 239 // static |
241 void AppListServiceImpl::RecordAppListAppLaunch() { | 240 void AppListServiceImpl::RecordAppListAppLaunch() { |
242 RecordDailyEventFrequency(prefs::kLastAppListAppLaunchPing, | 241 RecordDailyEventFrequency(prefs::kLastAppListAppLaunchPing, |
243 prefs::kAppListAppLaunchCount, | 242 prefs::kAppListAppLaunchCount, |
244 &SendAppListAppLaunch); | 243 &SendAppListAppLaunch); |
245 } | 244 } |
246 | 245 |
247 // static | 246 // static |
248 void AppListServiceImpl::RecordAppListLastLaunch() { | |
249 if (!g_browser_process) | |
250 return; // In a unit test. | |
251 | |
252 PrefService* local_state = g_browser_process->local_state(); | |
253 if (!local_state) | |
254 return; // In a unit test. | |
255 | |
256 local_state->SetInt64(prefs::kAppListLastLaunchTime, | |
257 base::Time::Now().ToInternalValue()); | |
258 } | |
259 | |
260 // static | |
261 void AppListServiceImpl::SendAppListStats() { | 247 void AppListServiceImpl::SendAppListStats() { |
262 if (!g_browser_process || g_browser_process->IsShuttingDown()) | 248 if (!g_browser_process || g_browser_process->IsShuttingDown()) |
263 return; | 249 return; |
264 | 250 |
265 SendDailyEventFrequency(prefs::kLastAppListLaunchPing, | 251 SendDailyEventFrequency(prefs::kLastAppListLaunchPing, |
266 prefs::kAppListLaunchCount, | 252 prefs::kAppListLaunchCount, |
267 &SendAppListLaunch); | 253 &SendAppListLaunch); |
268 SendDailyEventFrequency(prefs::kLastAppListAppLaunchPing, | 254 SendDailyEventFrequency(prefs::kLastAppListAppLaunchPing, |
269 prefs::kAppListAppLaunchCount, | 255 prefs::kAppListAppLaunchCount, |
270 &SendAppListAppLaunch); | 256 &SendAppListAppLaunch); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 437 |
452 if (!base::ThreadTaskRunnerHandle::IsSet()) | 438 if (!base::ThreadTaskRunnerHandle::IsSet()) |
453 return; // In a unit test. | 439 return; // In a unit test. |
454 | 440 |
455 // Send app list usage stats after a delay. | 441 // Send app list usage stats after a delay. |
456 const int kSendUsageStatsDelay = 5; | 442 const int kSendUsageStatsDelay = 5; |
457 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 443 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
458 FROM_HERE, base::Bind(&AppListServiceImpl::SendAppListStats), | 444 FROM_HERE, base::Bind(&AppListServiceImpl::SendAppListStats), |
459 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); | 445 base::TimeDelta::FromSeconds(kSendUsageStatsDelay)); |
460 } | 446 } |
OLD | NEW |