| OLD | NEW |
| 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 Loading... |
| 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( |
| 237 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| 237 if (store_.get()) { | 238 if (store_.get()) { |
| 238 // If the store is non-null, it means Load was already invoked. Load should | 239 // If the store is non-null, it means Load was already invoked. Load should |
| 239 // only be invoked once. | 240 // only be invoked once. |
| 240 NOTREACHED(); | 241 NOTREACHED(); |
| 241 return; | 242 return; |
| 242 } | 243 } |
| 243 | 244 |
| 244 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( | 245 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( |
| 245 profile_, this)); | 246 profile_, this)); |
| 246 | 247 |
| 247 // Listen for changes to favicons so that we can update the favicon of the | 248 // Listen for changes to favicons so that we can update the favicon of the |
| 248 // node appropriately. | 249 // node appropriately. |
| 249 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, | 250 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, |
| 250 content::Source<Profile>(profile_)); | 251 content::Source<Profile>(profile_)); |
| 251 | 252 |
| 252 // Load the bookmarks. BookmarkStorage notifies us when done. | 253 // Load the bookmarks. BookmarkStorage notifies us when done. |
| 253 store_ = new BookmarkStorage(profile_, this, profile_->GetIOTaskRunner()); | 254 store_ = new BookmarkStorage(profile_, this, task_runner); |
| 254 store_->LoadBookmarks(CreateLoadDetails()); | 255 store_->LoadBookmarks(CreateLoadDetails()); |
| 255 } | 256 } |
| 256 | 257 |
| 257 bool BookmarkModel::IsLoaded() const { | 258 bool BookmarkModel::IsLoaded() const { |
| 258 return loaded_; | 259 return loaded_; |
| 259 } | 260 } |
| 260 | 261 |
| 261 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { | 262 const BookmarkNode* BookmarkModel::GetParentForNewNodes() { |
| 262 std::vector<const BookmarkNode*> nodes = | 263 std::vector<const BookmarkNode*> nodes = |
| 263 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); | 264 bookmark_utils::GetMostRecentlyModifiedFolders(this, 1); |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 BookmarkPermanentNode* bb_node = | 955 BookmarkPermanentNode* bb_node = |
| 955 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 956 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
| 956 BookmarkPermanentNode* other_node = | 957 BookmarkPermanentNode* other_node = |
| 957 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 958 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
| 958 BookmarkPermanentNode* mobile_node = | 959 BookmarkPermanentNode* mobile_node = |
| 959 CreatePermanentNode(BookmarkNode::MOBILE); | 960 CreatePermanentNode(BookmarkNode::MOBILE); |
| 960 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 961 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
| 961 new BookmarkIndex(profile_), | 962 new BookmarkIndex(profile_), |
| 962 next_node_id_); | 963 next_node_id_); |
| 963 } | 964 } |
| OLD | NEW |