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 "chrome/browser/profiles/profile_statistics.h" | 5 #include "chrome/browser/profiles/profile_statistics.h" |
6 | 6 |
| 7 #include <set> |
7 #include "base/bind.h" | 8 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
10 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
15 #include "chrome/browser/password_manager/password_store_factory.h" | 16 #include "chrome/browser/password_manager/password_store_factory.h" |
16 #include "chrome/browser/profiles/profile_attributes_entry.h" | 17 #include "chrome/browser/profiles/profile_attributes_entry.h" |
17 #include "chrome/browser/profiles/profile_attributes_storage.h" | 18 #include "chrome/browser/profiles/profile_attributes_storage.h" |
18 #include "chrome/browser/profiles/profile_info_cache.h" | 19 #include "chrome/browser/profiles/profile_info_cache.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "components/bookmarks/browser/bookmark_model.h" | 21 #include "components/bookmarks/browser/bookmark_model.h" |
| 22 #include "components/bookmarks/browser/bookmark_model_observer.h" |
21 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
22 #include "components/password_manager/core/browser/password_store.h" | 24 #include "components/password_manager/core/browser/password_store.h" |
23 #include "components/password_manager/core/browser/password_store_consumer.h" | 25 #include "components/password_manager/core/browser/password_store_consumer.h" |
24 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
25 | 27 |
26 using content::BrowserThread; | |
27 | |
28 namespace { | 28 namespace { |
29 | 29 |
30 struct ProfileStatValue { | 30 struct ProfileStatValue { |
31 int count; | 31 int count; |
32 bool success; // false means the statistics failed to load | 32 bool success; // false means the statistics failed to load |
33 }; | 33 }; |
34 | 34 |
35 int CountBookmarksFromNode(const bookmarks::BookmarkNode* node) { | 35 int CountBookmarksFromNode(const bookmarks::BookmarkNode* node) { |
36 int count = 0; | 36 int count = 0; |
37 if (node->is_url()) { | 37 if (node->is_url()) { |
38 ++count; | 38 ++count; |
39 } else { | 39 } else { |
40 for (int i = 0; i < node->child_count(); ++i) | 40 for (int i = 0; i < node->child_count(); ++i) |
41 count += CountBookmarksFromNode(node->GetChild(i)); | 41 count += CountBookmarksFromNode(node->GetChild(i)); |
42 } | 42 } |
43 return count; | 43 return count; |
44 } | 44 } |
45 | 45 |
46 class ProfileStatisticsAggregator | 46 class ProfileStatisticsAggregator |
47 : public base::RefCountedThreadSafe<ProfileStatisticsAggregator> { | 47 : public base::RefCountedThreadSafe<ProfileStatisticsAggregator> { |
48 // This class collects statistical information about the profile and returns | 48 // This class is used internally by GetProfileStatistics and |
| 49 // StoreProfileStatisticsToCache. |
| 50 // |
| 51 // The class collects statistical information about the profile and returns |
49 // the information via a callback function. Currently bookmarks, history, | 52 // the information via a callback function. Currently bookmarks, history, |
50 // logins and preferences are counted. | 53 // logins and preferences are counted. |
51 // | 54 // |
52 // The class is RefCounted because this is needed for CancelableTaskTracker | 55 // The class is RefCounted because this is needed for CancelableTaskTracker |
53 // to function properly. Once all tasks are run (or cancelled) the instance is | 56 // to function properly. Once all tasks are run (or cancelled) the instance is |
54 // automatically destructed. | 57 // automatically destructed. |
55 // | |
56 // The class is used internally by GetProfileStatistics function. | |
57 | 58 |
58 public: | 59 public: |
59 explicit ProfileStatisticsAggregator(Profile* profile, | 60 ProfileStatisticsAggregator(Profile* profile, |
60 const profiles::ProfileStatisticsCallback& callback, | 61 const profiles::ProfileStatisticsCallback& callback, |
61 base::CancelableTaskTracker* tracker); | 62 base::CancelableTaskTracker* tracker); |
62 | 63 |
63 private: | 64 private: |
64 friend class base::RefCountedThreadSafe<ProfileStatisticsAggregator>; | 65 friend class base::RefCountedThreadSafe<ProfileStatisticsAggregator>; |
65 ~ProfileStatisticsAggregator() {} | 66 ~ProfileStatisticsAggregator() {} |
66 | 67 |
67 void Init(); | 68 void Init(); |
68 | 69 |
69 // Callback functions | 70 // Callback functions |
70 // Normal callback. Appends result to |profile_category_stats_|, and then call | 71 // Normal callback. Appends result to |profile_category_stats_|, and then call |
71 // the external callback. All other callbacks call this function. | 72 // the external callback. All other callbacks call this function. |
72 void StatisticsCallback(const char* category, ProfileStatValue result); | 73 void StatisticsCallback(const char* category, ProfileStatValue result); |
73 // Callback for reporting success. | 74 // Callback for reporting success. |
74 void StatisticsCallbackSuccess(const char* category, int count); | 75 void StatisticsCallbackSuccess(const char* category, int count); |
75 // Callback for reporting failure. | 76 // Callback for reporting failure. |
76 void StatisticsCallbackFailure(const char* category); | 77 void StatisticsCallbackFailure(const char* category); |
77 // Callback for history. | 78 // Callback for history. |
78 void StatisticsCallbackHistory(history::HistoryCountResult result); | 79 void StatisticsCallbackHistory(history::HistoryCountResult result); |
79 | 80 |
80 // Bookmark counting. | 81 // Bookmark counting. |
81 ProfileStatValue CountBookmarks() const; | 82 void WaitOrCountBookmarks(); |
| 83 void CountBookmarks(bookmarks::BookmarkModel* bookmark_model); |
82 | 84 |
83 // Preference counting. | 85 // Preference counting. |
84 ProfileStatValue CountPrefs() const; | 86 ProfileStatValue CountPrefs() const; |
85 | 87 |
86 Profile* profile_; | 88 Profile* profile_; |
87 profiles::ProfileCategoryStats profile_category_stats_; | 89 profiles::ProfileCategoryStats profile_category_stats_; |
88 | 90 |
89 // Callback function to be called when results arrive. Will be called | 91 // Callback function to be called when results arrive. Will be called |
90 // multiple times (once for each statistics). | 92 // multiple times (once for each statistics). |
91 const profiles::ProfileStatisticsCallback callback_; | 93 const profiles::ProfileStatisticsCallback callback_; |
92 | 94 |
93 base::CancelableTaskTracker* tracker_; | 95 base::CancelableTaskTracker* tracker_; |
| 96 scoped_ptr<base::CancelableTaskTracker> default_tracker_; |
| 97 |
| 98 // Bookmark counting |
| 99 class BookmarkModelHelper |
| 100 : public bookmarks::BookmarkModelObserver { |
| 101 public: |
| 102 explicit BookmarkModelHelper(ProfileStatisticsAggregator* parent) |
| 103 : parent_(parent) {} |
| 104 |
| 105 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
| 106 bool ids_reassigned) |
| 107 override { |
| 108 // Remove observer before release, otherwise it may become a dangling |
| 109 // reference. |
| 110 model->RemoveObserver(this); |
| 111 parent_->CountBookmarks(model); |
| 112 parent_->Release(); |
| 113 } |
| 114 |
| 115 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, |
| 116 const bookmarks::BookmarkNode* old_parent, |
| 117 int old_index, |
| 118 const bookmarks::BookmarkNode* new_parent, |
| 119 int new_index) override {} |
| 120 |
| 121 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
| 122 const bookmarks::BookmarkNode* parent, |
| 123 int index) override {} |
| 124 |
| 125 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
| 126 const bookmarks::BookmarkNode* parent, |
| 127 int old_index, const bookmarks::BookmarkNode* node, |
| 128 const std::set<GURL>& no_longer_bookmarked) override {} |
| 129 |
| 130 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, |
| 131 const bookmarks::BookmarkNode* node) override {} |
| 132 |
| 133 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, |
| 134 const bookmarks::BookmarkNode* node) override {} |
| 135 |
| 136 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, |
| 137 const bookmarks::BookmarkNode* node) override {} |
| 138 |
| 139 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, |
| 140 const std::set<GURL>& removed_urls) override {} |
| 141 |
| 142 |
| 143 private: |
| 144 ProfileStatisticsAggregator* parent_ = nullptr; |
| 145 }; |
| 146 scoped_ptr<BookmarkModelHelper> bookmark_model_helper_; |
94 | 147 |
95 // Password counting. | 148 // Password counting. |
96 class PasswordStoreConsumerHelper | 149 class PasswordStoreConsumerHelper |
97 : public password_manager::PasswordStoreConsumer { | 150 : public password_manager::PasswordStoreConsumer { |
98 public: | 151 public: |
99 explicit PasswordStoreConsumerHelper(ProfileStatisticsAggregator* parent) | 152 explicit PasswordStoreConsumerHelper(ProfileStatisticsAggregator* parent) |
100 : parent_(parent) {} | 153 : parent_(parent) {} |
101 | 154 |
102 void OnGetPasswordStoreResults( | 155 void OnGetPasswordStoreResults( |
103 ScopedVector<autofill::PasswordForm> results) override { | 156 ScopedVector<autofill::PasswordForm> results) override { |
(...skipping 12 matching lines...) Expand all Loading... |
116 }; | 169 }; |
117 | 170 |
118 ProfileStatisticsAggregator::ProfileStatisticsAggregator( | 171 ProfileStatisticsAggregator::ProfileStatisticsAggregator( |
119 Profile* profile, | 172 Profile* profile, |
120 const profiles::ProfileStatisticsCallback& callback, | 173 const profiles::ProfileStatisticsCallback& callback, |
121 base::CancelableTaskTracker* tracker) | 174 base::CancelableTaskTracker* tracker) |
122 : profile_(profile), | 175 : profile_(profile), |
123 callback_(callback), | 176 callback_(callback), |
124 tracker_(tracker), | 177 tracker_(tracker), |
125 password_store_consumer_helper_(this) { | 178 password_store_consumer_helper_(this) { |
| 179 if (!tracker_) { |
| 180 default_tracker_.reset(new base::CancelableTaskTracker); |
| 181 tracker_ = default_tracker_.get(); |
| 182 } |
126 Init(); | 183 Init(); |
127 } | 184 } |
128 | 185 |
129 void ProfileStatisticsAggregator::Init() { | 186 void ProfileStatisticsAggregator::Init() { |
| 187 DCHECK(profile_); |
| 188 |
130 // Initiate bookmark counting (async). Post to UI thread. | 189 // Initiate bookmark counting (async). Post to UI thread. |
131 tracker_->PostTaskAndReplyWithResult( | 190 tracker_->PostTask( |
132 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get(), | 191 content::BrowserThread::GetMessageLoopProxyForThread( |
133 FROM_HERE, | 192 content::BrowserThread::UI).get(), |
134 base::Bind(&ProfileStatisticsAggregator::CountBookmarks, this), | 193 FROM_HERE, |
135 base::Bind(&ProfileStatisticsAggregator::StatisticsCallback, | 194 base::Bind(&ProfileStatisticsAggregator::WaitOrCountBookmarks, this)); |
136 this, profiles::kProfileStatisticsBookmarks)); | |
137 | 195 |
138 // Initiate history counting (async). | 196 // Initiate history counting (async). |
139 history::HistoryService* history_service = | 197 history::HistoryService* history_service = |
140 HistoryServiceFactory::GetForProfileWithoutCreating(profile_); | 198 HistoryServiceFactory::GetForProfileWithoutCreating(profile_); |
141 | 199 |
142 if (history_service) { | 200 if (history_service) { |
143 history_service->GetHistoryCount( | 201 history_service->GetHistoryCount( |
144 base::Time(), | 202 base::Time(), |
145 base::Time::Max(), | 203 base::Time::Max(), |
146 base::Bind(&ProfileStatisticsAggregator::StatisticsCallbackHistory, | 204 base::Bind(&ProfileStatisticsAggregator::StatisticsCallbackHistory, |
147 this), | 205 this), |
148 tracker_); | 206 tracker_); |
149 } else { | 207 } else { |
150 StatisticsCallbackFailure(profiles::kProfileStatisticsBrowsingHistory); | 208 StatisticsCallbackFailure(profiles::kProfileStatisticsBrowsingHistory); |
151 } | 209 } |
152 | 210 |
153 // Initiate stored password counting (async). | 211 // Initiate stored password counting (async). |
154 // TODO(anthonyvd): make password task cancellable. | 212 // TODO(anthonyvd): make password task cancellable. |
155 scoped_refptr<password_manager::PasswordStore> password_store = | 213 scoped_refptr<password_manager::PasswordStore> password_store = |
156 PasswordStoreFactory::GetForProfile( | 214 PasswordStoreFactory::GetForProfile( |
157 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 215 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
158 if (password_store) { | 216 if (password_store) { |
159 password_store->GetAutofillableLogins(&password_store_consumer_helper_); | 217 password_store->GetAutofillableLogins(&password_store_consumer_helper_); |
160 } else { | 218 } else { |
161 StatisticsCallbackFailure(profiles::kProfileStatisticsPasswords); | 219 StatisticsCallbackFailure(profiles::kProfileStatisticsPasswords); |
162 } | 220 } |
163 | 221 |
164 // Initiate preference counting (async). Post to UI thread. | 222 // Initiate preference counting (async). Post to UI thread. |
165 tracker_->PostTaskAndReplyWithResult( | 223 tracker_->PostTaskAndReplyWithResult( |
166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get(), | 224 content::BrowserThread::GetMessageLoopProxyForThread( |
167 FROM_HERE, | 225 content::BrowserThread::UI).get(), |
168 base::Bind(&ProfileStatisticsAggregator::CountPrefs, this), | 226 FROM_HERE, |
169 base::Bind(&ProfileStatisticsAggregator::StatisticsCallback, | 227 base::Bind(&ProfileStatisticsAggregator::CountPrefs, this), |
170 this, profiles::kProfileStatisticsSettings)); | 228 base::Bind(&ProfileStatisticsAggregator::StatisticsCallback, |
| 229 this, profiles::kProfileStatisticsSettings)); |
171 } | 230 } |
172 | 231 |
173 void ProfileStatisticsAggregator::StatisticsCallback( | 232 void ProfileStatisticsAggregator::StatisticsCallback( |
174 const char* category, ProfileStatValue result) { | 233 const char* category, ProfileStatValue result) { |
175 profiles::ProfileCategoryStat datum; | 234 profiles::ProfileCategoryStat datum; |
176 datum.category = category; | 235 datum.category = category; |
177 datum.count = result.count; | 236 datum.count = result.count; |
178 datum.success = result.success; | 237 datum.success = result.success; |
179 profile_category_stats_.push_back(datum); | 238 profile_category_stats_.push_back(datum); |
180 callback_.Run(profile_category_stats_); | 239 if (!callback_.is_null()) |
| 240 callback_.Run(profile_category_stats_); |
| 241 |
| 242 if (result.success) { |
| 243 profiles::SetProfileStatisticsInCache(profile_->GetPath(), datum.category, |
| 244 result.count); |
| 245 } |
181 } | 246 } |
182 | 247 |
183 void ProfileStatisticsAggregator::StatisticsCallbackSuccess( | 248 void ProfileStatisticsAggregator::StatisticsCallbackSuccess( |
184 const char* category, int count) { | 249 const char* category, int count) { |
185 ProfileStatValue result; | 250 ProfileStatValue result; |
186 result.count = count; | 251 result.count = count; |
187 result.success = true; | 252 result.success = true; |
188 StatisticsCallback(category, result); | 253 StatisticsCallback(category, result); |
189 } | 254 } |
190 | 255 |
191 void ProfileStatisticsAggregator::StatisticsCallbackFailure( | 256 void ProfileStatisticsAggregator::StatisticsCallbackFailure( |
192 const char* category) { | 257 const char* category) { |
193 ProfileStatValue result; | 258 ProfileStatValue result; |
194 result.count = 0; | 259 result.count = 0; |
195 result.success = false; | 260 result.success = false; |
196 StatisticsCallback(category, result); | 261 StatisticsCallback(category, result); |
197 } | 262 } |
198 | 263 |
199 void ProfileStatisticsAggregator::StatisticsCallbackHistory( | 264 void ProfileStatisticsAggregator::StatisticsCallbackHistory( |
200 history::HistoryCountResult result) { | 265 history::HistoryCountResult result) { |
201 ProfileStatValue result_converted; | 266 ProfileStatValue result_converted; |
202 result_converted.count = result.count; | 267 result_converted.count = result.count; |
203 result_converted.success = result.success; | 268 result_converted.success = result.success; |
204 StatisticsCallback(profiles::kProfileStatisticsBrowsingHistory, | 269 StatisticsCallback(profiles::kProfileStatisticsBrowsingHistory, |
205 result_converted); | 270 result_converted); |
206 } | 271 } |
207 | 272 |
208 ProfileStatValue ProfileStatisticsAggregator::CountBookmarks() const { | 273 void ProfileStatisticsAggregator::CountBookmarks( |
| 274 bookmarks::BookmarkModel* bookmark_model) { |
| 275 int count = CountBookmarksFromNode(bookmark_model->bookmark_bar_node()) + |
| 276 CountBookmarksFromNode(bookmark_model->other_node()) + |
| 277 CountBookmarksFromNode(bookmark_model->mobile_node()); |
| 278 |
| 279 StatisticsCallbackSuccess(profiles::kProfileStatisticsBookmarks, count); |
| 280 } |
| 281 |
| 282 void ProfileStatisticsAggregator::WaitOrCountBookmarks() { |
209 bookmarks::BookmarkModel* bookmark_model = | 283 bookmarks::BookmarkModel* bookmark_model = |
210 BookmarkModelFactory::GetForProfileIfExists(profile_); | 284 BookmarkModelFactory::GetForProfileIfExists(profile_); |
211 | 285 |
212 ProfileStatValue result; | |
213 if (bookmark_model) { | 286 if (bookmark_model) { |
214 result.count = CountBookmarksFromNode(bookmark_model->bookmark_bar_node()) + | 287 if (bookmark_model->loaded()) { |
215 CountBookmarksFromNode(bookmark_model->other_node()) + | 288 CountBookmarks(bookmark_model); |
216 CountBookmarksFromNode(bookmark_model->mobile_node()); | 289 } else { |
217 result.success = true; | 290 AddRef(); |
| 291 bookmark_model_helper_.reset(new BookmarkModelHelper(this)); |
| 292 bookmark_model->AddObserver(bookmark_model_helper_.get()); |
| 293 } |
218 } else { | 294 } else { |
219 result.count = 0; | 295 StatisticsCallbackFailure(profiles::kProfileStatisticsBookmarks); |
220 result.success = false; | |
221 } | 296 } |
222 return result; | |
223 } | 297 } |
224 | 298 |
225 ProfileStatValue ProfileStatisticsAggregator::CountPrefs() const { | 299 ProfileStatValue ProfileStatisticsAggregator::CountPrefs() const { |
226 const PrefService* pref_service = profile_->GetPrefs(); | 300 const PrefService* pref_service = profile_->GetPrefs(); |
227 | 301 |
228 ProfileStatValue result; | 302 ProfileStatValue result; |
229 if (pref_service) { | 303 if (pref_service) { |
230 scoped_ptr<base::DictionaryValue> prefs = | 304 scoped_ptr<base::DictionaryValue> prefs = |
231 pref_service->GetPreferenceValuesWithoutPathExpansion(); | 305 pref_service->GetPreferenceValuesWithoutPathExpansion(); |
232 | 306 |
(...skipping 21 matching lines...) Expand all Loading... |
254 } // namespace | 328 } // namespace |
255 | 329 |
256 namespace profiles { | 330 namespace profiles { |
257 | 331 |
258 // Constants for the categories in ProfileCategoryStats | 332 // Constants for the categories in ProfileCategoryStats |
259 const char kProfileStatisticsBrowsingHistory[] = "BrowsingHistory"; | 333 const char kProfileStatisticsBrowsingHistory[] = "BrowsingHistory"; |
260 const char kProfileStatisticsPasswords[] = "Passwords"; | 334 const char kProfileStatisticsPasswords[] = "Passwords"; |
261 const char kProfileStatisticsBookmarks[] = "Bookmarks"; | 335 const char kProfileStatisticsBookmarks[] = "Bookmarks"; |
262 const char kProfileStatisticsSettings[] = "Settings"; | 336 const char kProfileStatisticsSettings[] = "Settings"; |
263 | 337 |
264 void GetProfileStatistics(Profile* profile, | 338 void GatherProfileStatistics(Profile* profile, |
265 const ProfileStatisticsCallback& callback, | 339 const ProfileStatisticsCallback& callback, |
266 base::CancelableTaskTracker* tracker) { | 340 base::CancelableTaskTracker* tracker) { |
267 scoped_refptr<ProfileStatisticsAggregator> aggregator = | 341 scoped_refptr<ProfileStatisticsAggregator> aggregator = |
268 new ProfileStatisticsAggregator(profile, callback, tracker); | 342 new ProfileStatisticsAggregator(profile, callback, tracker); |
269 } | 343 } |
270 | 344 |
271 ProfileCategoryStats GetProfileStatisticsFromCache( | 345 ProfileCategoryStats GetProfileStatisticsFromCache( |
272 const base::FilePath& profile_path) { | 346 const base::FilePath& profile_path) { |
273 ProfileInfoCache& profile_info_cache = | 347 ProfileInfoCache& profile_info_cache = |
274 g_browser_process->profile_manager()->GetProfileInfoCache(); | 348 g_browser_process->profile_manager()->GetProfileInfoCache(); |
275 ProfileAttributesEntry* entry = nullptr; | 349 ProfileAttributesEntry* entry = nullptr; |
276 bool has_entry = profile_info_cache. | 350 bool has_entry = profile_info_cache. |
(...skipping 24 matching lines...) Expand all Loading... |
301 | 375 |
302 return stats; | 376 return stats; |
303 } | 377 } |
304 | 378 |
305 void SetProfileStatisticsInCache(const base::FilePath& profile_path, | 379 void SetProfileStatisticsInCache(const base::FilePath& profile_path, |
306 const std::string& category, int count) { | 380 const std::string& category, int count) { |
307 // If local_state() is null, profile_manager() will seg-fault. | 381 // If local_state() is null, profile_manager() will seg-fault. |
308 if (!g_browser_process || !g_browser_process->local_state()) | 382 if (!g_browser_process || !g_browser_process->local_state()) |
309 return; | 383 return; |
310 | 384 |
311 ProfileInfoCache& profile_info_cache = | 385 // profile_manager() may return a null pointer. |
312 g_browser_process->profile_manager()->GetProfileInfoCache(); | 386 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 387 if (!profile_manager) |
| 388 return; |
| 389 |
| 390 ProfileInfoCache& profile_info_cache = profile_manager->GetProfileInfoCache(); |
313 ProfileAttributesEntry* entry = nullptr; | 391 ProfileAttributesEntry* entry = nullptr; |
314 if (!profile_info_cache.GetProfileAttributesWithPath(profile_path, &entry)) | 392 if (!profile_info_cache.GetProfileAttributesWithPath(profile_path, &entry)) |
315 return; | 393 return; |
316 | 394 |
317 if (category == kProfileStatisticsBrowsingHistory) { | 395 if (category == kProfileStatisticsBrowsingHistory) { |
318 entry->SetStatsBrowsingHistory(count); | 396 entry->SetStatsBrowsingHistory(count); |
319 } else if (category == kProfileStatisticsPasswords) { | 397 } else if (category == kProfileStatisticsPasswords) { |
320 entry->SetStatsPasswords(count); | 398 entry->SetStatsPasswords(count); |
321 } else if (category == kProfileStatisticsBookmarks) { | 399 } else if (category == kProfileStatisticsBookmarks) { |
322 entry->SetStatsBookmarks(count); | 400 entry->SetStatsBookmarks(count); |
323 } else if (category == kProfileStatisticsSettings) { | 401 } else if (category == kProfileStatisticsSettings) { |
324 entry->SetStatsSettings(count); | 402 entry->SetStatsSettings(count); |
325 } else { | 403 } else { |
326 NOTREACHED(); | 404 NOTREACHED(); |
327 } | 405 } |
328 } | 406 } |
329 | 407 |
330 } // namespace profiles | 408 } // namespace profiles |
OLD | NEW |