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

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

Issue 10399087: Converting BookmarkModel and HistoryService to ProfileKeyedServices. This just performs the initial… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 145 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
146 BookmarkModelBeingDeleted(this)); 146 BookmarkModelBeingDeleted(this));
147 147
148 if (store_) { 148 if (store_) {
149 // The store maintains a reference back to us. We need to tell it we're gone 149 // The store maintains a reference back to us. We need to tell it we're gone
150 // so that it doesn't try and invoke a method back on us again. 150 // so that it doesn't try and invoke a method back on us again.
151 store_->BookmarkModelDeleted(); 151 store_->BookmarkModelDeleted();
152 } 152 }
153 } 153 }
154 154
155 // static 155 void BookmarkModel::Shutdown() {
156 void BookmarkModel::RegisterUserPrefs(PrefService* prefs) {
157 // Don't sync this, as otherwise, due to a limitation in sync, it
158 // will cause a deadlock (see http://crbug.com/97955). If we truly
159 // want to sync the expanded state of folders, it should be part of
160 // bookmark sync itself (i.e., a property of the sync folder nodes).
161 prefs->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, new ListValue,
162 PrefService::UNSYNCABLE_PREF);
163 }
164
165 void BookmarkModel::Cleanup() {
166 if (loaded_) 156 if (loaded_)
167 return; 157 return;
168 158
169 // See comment in Profile shutdown code where this is invoked for details. 159 // See comment in HistoryService::ShutdownOnUIThread where this is invoked for
160 // details. It is also called when the BookmarkModel is deleted.
170 loaded_signal_.Signal(); 161 loaded_signal_.Signal();
171 } 162 }
172 163
173 void BookmarkModel::Load() { 164 void BookmarkModel::Load() {
174 if (store_.get()) { 165 if (store_.get()) {
175 // If the store is non-null, it means Load was already invoked. Load should 166 // If the store is non-null, it means Load was already invoked. Load should
176 // only be invoked once. 167 // only be invoked once.
177 NOTREACHED(); 168 NOTREACHED();
178 return; 169 return;
179 } 170 }
180 171
181 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker( 172 expanded_state_tracker_.reset(new BookmarkExpandedStateTracker(
182 profile_, prefs::kBookmarkEditorExpandedNodes)); 173 profile_, prefs::kBookmarkEditorExpandedNodes, this));
183 174
184 // Listen for changes to favicons so that we can update the favicon of the 175 // Listen for changes to favicons so that we can update the favicon of the
185 // node appropriately. 176 // node appropriately.
186 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, 177 registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED,
187 content::Source<Profile>(profile_)); 178 content::Source<Profile>(profile_));
188 179
189 // Load the bookmarks. BookmarkStorage notifies us when done. 180 // Load the bookmarks. BookmarkStorage notifies us when done.
190 store_ = new BookmarkStorage(profile_, this); 181 store_ = new BookmarkStorage(profile_, this);
191 store_->LoadBookmarks(CreateLoadDetails()); 182 store_->LoadBookmarks(CreateLoadDetails());
192 } 183 }
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 861 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
871 BookmarkPermanentNode* bb_node = 862 BookmarkPermanentNode* bb_node =
872 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 863 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
873 BookmarkPermanentNode* other_node = 864 BookmarkPermanentNode* other_node =
874 CreatePermanentNode(BookmarkNode::OTHER_NODE); 865 CreatePermanentNode(BookmarkNode::OTHER_NODE);
875 BookmarkPermanentNode* mobile_node = 866 BookmarkPermanentNode* mobile_node =
876 CreatePermanentNode(BookmarkNode::MOBILE); 867 CreatePermanentNode(BookmarkNode::MOBILE);
877 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, 868 return new BookmarkLoadDetails(bb_node, other_node, mobile_node,
878 new BookmarkIndex(profile_), next_node_id_); 869 new BookmarkIndex(profile_), next_node_id_);
879 } 870 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_model_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698