Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/profiles/profile_statistics_aggregator.cc

Issue 2216713002: Use BookmarkModelFactory::GetForBrowserContext everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks
Patch Set: Replace in .mm files Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698