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

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: Add startup_task_runner_service. 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 void BookmarkModel::Shutdown() { 227 void BookmarkModel::Shutdown() {
228 if (loaded_) 228 if (loaded_)
229 return; 229 return;
230 230
231 // See comment in HistoryService::ShutdownOnUIThread where this is invoked for 231 // See comment in HistoryService::ShutdownOnUIThread where this is invoked for
232 // details. It is also called when the BookmarkModel is deleted. 232 // details. It is also called when the BookmarkModel is deleted.
233 loaded_signal_.Signal(); 233 loaded_signal_.Signal();
234 } 234 }
235 235
236 void BookmarkModel::Load() { 236 void BookmarkModel::Load(scoped_refptr<base::SequencedTaskRunner> task_runner) {
Miranda Callahan 2013/03/29 14:40:13 Do we really need to pass the task_runner here? No
msarda 2013/03/29 14:46:24 I did that in a local change. However, I understoo
237 if (store_.get()) { 237 if (store_.get()) {
238 // 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
239 // only be invoked once. 239 // only be invoked once.
240 NOTREACHED(); 240 NOTREACHED();
241 return; 241 return;
242 } 242 }
243 243
244 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( 244 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker(
245 profile_, this)); 245 profile_, this));
246 246
247 // 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
248 // node appropriately. 248 // node appropriately.
249 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, 249 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED,
250 content::Source<Profile>(profile_)); 250 content::Source<Profile>(profile_));
251 251
252 // Load the bookmarks. BookmarkStorage notifies us when done. 252 // Load the bookmarks. BookmarkStorage notifies us when done.
253 store_ = new BookmarkStorage(profile_, this, profile_->GetIOTaskRunner()); 253 store_ = new BookmarkStorage(profile_, this, task_runner);
Miranda Callahan 2013/03/29 14:40:13 see comment on "Load" above.
254 store_->LoadBookmarks(CreateLoadDetails()); 254 store_->LoadBookmarks(CreateLoadDetails());
255 } 255 }
256 256
257 bool BookmarkModel::IsLoaded() const { 257 bool BookmarkModel::IsLoaded() const {
258 return loaded_; 258 return loaded_;
259 } 259 }
260 260
261 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { 261 const BookmarkNode* BookmarkModel::GetParentForNewNodes() {
262 std::vector<const BookmarkNode*> nodes = 262 std::vector<const BookmarkNode*> nodes =
263 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); 263 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1);
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 BookmarkPermanentNode* bb_node = 954 BookmarkPermanentNode* bb_node =
955 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 955 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
956 BookmarkPermanentNode* other_node = 956 BookmarkPermanentNode* other_node =
957 CreatePermanentNode(BookmarkNode::OTHER_NODE); 957 CreatePermanentNode(BookmarkNode::OTHER_NODE);
958 BookmarkPermanentNode* mobile_node = 958 BookmarkPermanentNode* mobile_node =
959 CreatePermanentNode(BookmarkNode::MOBILE); 959 CreatePermanentNode(BookmarkNode::MOBILE);
960 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, 960 return new BookmarkLoadDetails(bb_node, other_node, mobile_node,
961 new BookmarkIndex(profile_), 961 new BookmarkIndex(profile_),
962 next_node_id_); 962 next_node_id_);
963 } 963 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698