| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return; | 190 return; |
| 191 if (!g_browser_process->profile_manager()->IsValidProfile(profile_)) | 191 if (!g_browser_process->profile_manager()->IsValidProfile(profile_)) |
| 192 return; | 192 return; |
| 193 | 193 |
| 194 bookmarks::BookmarkModel* bookmark_model = | 194 bookmarks::BookmarkModel* bookmark_model = |
| 195 BookmarkModelFactory::GetForProfileIfExists(profile_); | 195 BookmarkModelFactory::GetForProfileIfExists(profile_); |
| 196 | 196 |
| 197 if (bookmark_model) { | 197 if (bookmark_model) { |
| 198 if (bookmark_model->loaded()) { | 198 if (bookmark_model->loaded()) { |
| 199 CountBookmarks(bookmark_model); | 199 CountBookmarks(bookmark_model); |
| 200 } else { | 200 } else if (!bookmark_model_helper_) { |
| 201 // If |bookmark_model_helper_| is not null, it means a previous bookmark |
| 202 // counting task still waiting for the bookmark model to load. Do nothing |
| 203 // and continue to use the old |bookmark_model_helper_| in this case. |
| 201 AddRef(); | 204 AddRef(); |
| 202 bookmark_model_helper_.reset(new BookmarkModelHelper(this)); | 205 bookmark_model_helper_.reset(new BookmarkModelHelper(this)); |
| 203 bookmark_model->AddObserver(bookmark_model_helper_.get()); | 206 bookmark_model->AddObserver(bookmark_model_helper_.get()); |
| 204 } | 207 } |
| 205 } else { | 208 } else { |
| 206 StatisticsCallbackFailure(profiles::kProfileStatisticsBookmarks); | 209 StatisticsCallbackFailure(profiles::kProfileStatisticsBookmarks); |
| 207 } | 210 } |
| 208 } | 211 } |
| 209 | 212 |
| 210 ProfileStatisticsAggregator::ProfileStatValue | 213 ProfileStatisticsAggregator::ProfileStatValue |
| (...skipping 18 matching lines...) Expand all Loading... |
| 229 } | 232 } |
| 230 | 233 |
| 231 result.count = count; | 234 result.count = count; |
| 232 result.success = true; | 235 result.success = true; |
| 233 } else { | 236 } else { |
| 234 result.count = 0; | 237 result.count = 0; |
| 235 result.success = false; | 238 result.success = false; |
| 236 } | 239 } |
| 237 return result; | 240 return result; |
| 238 } | 241 } |
| OLD | NEW |