| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/profiles/profile_statistics_aggregator.h" | 5 #include "chrome/browser/profiles/profile_statistics_aggregator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void ProfileStatisticsAggregator::StartAggregator() { | 83 void ProfileStatisticsAggregator::StartAggregator() { |
| 84 DCHECK(g_browser_process->profile_manager()->IsValidProfile(profile_)); | 84 DCHECK(g_browser_process->profile_manager()->IsValidProfile(profile_)); |
| 85 profile_category_stats_.clear(); | 85 profile_category_stats_.clear(); |
| 86 | 86 |
| 87 // Try to cancel tasks from task trackers. | 87 // Try to cancel tasks from task trackers. |
| 88 tracker_.TryCancelAll(); | 88 tracker_.TryCancelAll(); |
| 89 password_store_consumer_helper_.cancelable_task_tracker()->TryCancelAll(); | 89 password_store_consumer_helper_.cancelable_task_tracker()->TryCancelAll(); |
| 90 | 90 |
| 91 // Initiate bookmark counting (async). | 91 // Initiate bookmark counting (async). |
| 92 tracker_.PostTask( | 92 tracker_.PostTask( |
| 93 content::BrowserThread::GetMessageLoopProxyForThread( | 93 content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI) |
| 94 content::BrowserThread::UI).get(), | 94 .get(), |
| 95 FROM_HERE, | 95 FROM_HERE, |
| 96 base::Bind(&ProfileStatisticsAggregator::WaitOrCountBookmarks, this)); | 96 base::Bind(&ProfileStatisticsAggregator::WaitOrCountBookmarks, this)); |
| 97 | 97 |
| 98 // Initiate history counting (async). | 98 // Initiate history counting (async). |
| 99 history::HistoryService* history_service = | 99 history::HistoryService* history_service = |
| 100 HistoryServiceFactory::GetForProfileWithoutCreating(profile_); | 100 HistoryServiceFactory::GetForProfileWithoutCreating(profile_); |
| 101 | 101 |
| 102 if (history_service) { | 102 if (history_service) { |
| 103 history_service->GetHistoryCount( | 103 history_service->GetHistoryCount( |
| 104 base::Time(), | 104 base::Time(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 PasswordStoreFactory::GetForProfile( | 115 PasswordStoreFactory::GetForProfile( |
| 116 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 116 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 117 if (password_store) { | 117 if (password_store) { |
| 118 password_store->GetAutofillableLogins(&password_store_consumer_helper_); | 118 password_store->GetAutofillableLogins(&password_store_consumer_helper_); |
| 119 } else { | 119 } else { |
| 120 StatisticsCallbackFailure(profiles::kProfileStatisticsPasswords); | 120 StatisticsCallbackFailure(profiles::kProfileStatisticsPasswords); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Initiate preference counting (async). | 123 // Initiate preference counting (async). |
| 124 tracker_.PostTaskAndReplyWithResult( | 124 tracker_.PostTaskAndReplyWithResult( |
| 125 content::BrowserThread::GetMessageLoopProxyForThread( | 125 content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI) |
| 126 content::BrowserThread::UI).get(), | 126 .get(), |
| 127 FROM_HERE, | 127 FROM_HERE, base::Bind(&ProfileStatisticsAggregator::CountPrefs, this), |
| 128 base::Bind(&ProfileStatisticsAggregator::CountPrefs, this), | 128 base::Bind(&ProfileStatisticsAggregator::StatisticsCallback, this, |
| 129 base::Bind(&ProfileStatisticsAggregator::StatisticsCallback, | 129 profiles::kProfileStatisticsSettings)); |
| 130 this, profiles::kProfileStatisticsSettings)); | |
| 131 } | 130 } |
| 132 | 131 |
| 133 void ProfileStatisticsAggregator::StatisticsCallback( | 132 void ProfileStatisticsAggregator::StatisticsCallback( |
| 134 const char* category, ProfileStatValue result) { | 133 const char* category, ProfileStatValue result) { |
| 135 profiles::ProfileCategoryStat datum; | 134 profiles::ProfileCategoryStat datum; |
| 136 datum.category = category; | 135 datum.category = category; |
| 137 datum.count = result.count; | 136 datum.count = result.count; |
| 138 datum.success = result.success; | 137 datum.success = result.success; |
| 139 profile_category_stats_.push_back(datum); | 138 profile_category_stats_.push_back(datum); |
| 140 for (const auto& stats_callback : stats_callbacks_) { | 139 for (const auto& stats_callback : stats_callbacks_) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 231 } |
| 233 | 232 |
| 234 result.count = count; | 233 result.count = count; |
| 235 result.success = true; | 234 result.success = true; |
| 236 } else { | 235 } else { |
| 237 result.count = 0; | 236 result.count = 0; |
| 238 result.success = false; | 237 result.success = false; |
| 239 } | 238 } |
| 240 return result; | 239 return result; |
| 241 } | 240 } |
| OLD | NEW |