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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void ProfileStatisticsAggregator::WaitOrCountBookmarks() { | 184 void ProfileStatisticsAggregator::WaitOrCountBookmarks() { |
185 // The following checks should only fail in unit tests unrelated to gathering | 185 // The following checks should only fail in unit tests unrelated to gathering |
186 // statistics. Do not bother to return failure in any of these cases. | 186 // statistics. Do not bother to return failure in any of these cases. |
187 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 187 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
188 if (!profile_manager) | 188 if (!profile_manager) |
189 return; | 189 return; |
190 if (!g_browser_process->profile_manager()->IsValidProfile(profile_)) | 190 if (!g_browser_process->profile_manager()->IsValidProfile(profile_)) |
191 return; | 191 return; |
192 | 192 |
193 bookmarks::BookmarkModel* bookmark_model = | 193 bookmarks::BookmarkModel* bookmark_model = |
194 BookmarkModelFactory::GetForProfileIfExists(profile_); | 194 BookmarkModelFactory::GetForBrowserContextIfExists(profile_); |
195 | 195 |
196 if (bookmark_model) { | 196 if (bookmark_model) { |
197 if (bookmark_model->loaded()) { | 197 if (bookmark_model->loaded()) { |
198 CountBookmarks(bookmark_model); | 198 CountBookmarks(bookmark_model); |
199 } else if (!bookmark_model_helper_) { | 199 } else if (!bookmark_model_helper_) { |
200 // If |bookmark_model_helper_| is not null, it means a previous bookmark | 200 // If |bookmark_model_helper_| is not null, it means a previous bookmark |
201 // counting task still waiting for the bookmark model to load. Do nothing | 201 // counting task still waiting for the bookmark model to load. Do nothing |
202 // and continue to use the old |bookmark_model_helper_| in this case. | 202 // and continue to use the old |bookmark_model_helper_| in this case. |
203 AddRef(); | 203 AddRef(); |
204 bookmark_model_helper_.reset(new BookmarkModelHelper(this)); | 204 bookmark_model_helper_.reset(new BookmarkModelHelper(this)); |
(...skipping 26 matching lines...) Expand all Loading... |
231 } | 231 } |
232 | 232 |
233 result.count = count; | 233 result.count = count; |
234 result.success = true; | 234 result.success = true; |
235 } else { | 235 } else { |
236 result.count = 0; | 236 result.count = 0; |
237 result.success = false; | 237 result.success = false; |
238 } | 238 } |
239 return result; | 239 return result; |
240 } | 240 } |
OLD | NEW |