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

Side by Side Diff: chrome/browser/bookmarks/bookmark_model.cc

Issue 12952005: Delay bookmarks load while the profile is loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 7 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bookmarks/bookmark_model.h" 5 #include "chrome/browser/bookmarks/bookmark_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 void BookmarkModel::Shutdown() { 226 void BookmarkModel::Shutdown() {
227 if (loaded_) 227 if (loaded_)
228 return; 228 return;
229 229
230 // See comment in HistoryService::ShutdownOnUIThread where this is invoked for 230 // See comment in HistoryService::ShutdownOnUIThread where this is invoked for
231 // details. It is also called when the BookmarkModel is deleted. 231 // details. It is also called when the BookmarkModel is deleted.
232 loaded_signal_.Signal(); 232 loaded_signal_.Signal();
233 } 233 }
234 234
235 void BookmarkModel::Load() { 235 void BookmarkModel::Load(
236 const scoped_refptr<base::SequencedTaskRunner>& task_runner) {
236 if (store_.get()) { 237 if (store_.get()) {
237 // If the store is non-null, it means Load was already invoked. Load should 238 // If the store is non-null, it means Load was already invoked. Load should
238 // only be invoked once. 239 // only be invoked once.
239 NOTREACHED(); 240 NOTREACHED();
240 return; 241 return;
241 } 242 }
242 243
243 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( 244 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker(
244 profile_, this)); 245 profile_, this));
245 246
246 // Listen for changes to favicons so that we can update the favicon of the 247 // Listen for changes to favicons so that we can update the favicon of the
247 // node appropriately. 248 // node appropriately.
248 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, 249 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED,
249 content::Source<Profile>(profile_)); 250 content::Source<Profile>(profile_));
250 251
251 // Load the bookmarks. BookmarkStorage notifies us when done. 252 // Load the bookmarks. BookmarkStorage notifies us when done.
252 store_ = new BookmarkStorage(profile_, this, profile_->GetIOTaskRunner()); 253 store_ = new BookmarkStorage(profile_, this, task_runner);
253 store_->LoadBookmarks(CreateLoadDetails()); 254 store_->LoadBookmarks(CreateLoadDetails());
254 } 255 }
255 256
256 bool BookmarkModel::IsLoaded() const { 257 bool BookmarkModel::IsLoaded() const {
257 return loaded_; 258 return loaded_;
258 } 259 }
259 260
260 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { 261 const BookmarkNode* BookmarkModel::GetParentForNewNodes() {
261 std::vector<const BookmarkNode*> nodes = 262 std::vector<const BookmarkNode*> nodes =
262 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); 263 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 BookmarkPermanentNode* bb_node = 996 BookmarkPermanentNode* bb_node =
996 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 997 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
997 BookmarkPermanentNode* other_node = 998 BookmarkPermanentNode* other_node =
998 CreatePermanentNode(BookmarkNode::OTHER_NODE); 999 CreatePermanentNode(BookmarkNode::OTHER_NODE);
999 BookmarkPermanentNode* mobile_node = 1000 BookmarkPermanentNode* mobile_node =
1000 CreatePermanentNode(BookmarkNode::MOBILE); 1001 CreatePermanentNode(BookmarkNode::MOBILE);
1001 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, 1002 return new BookmarkLoadDetails(bb_node, other_node, mobile_node,
1002 new BookmarkIndex(profile_), 1003 new BookmarkIndex(profile_),
1003 next_node_id_); 1004 next_node_id_);
1004 } 1005 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_model_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698