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

Unified Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 7243012: Change many extension event routers to not be singletons and to be more profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bookmark remove observer Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_bookmarks_module.cc
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index e325aa01dbc879290259e28750aa531675578b17..c61c8ddc56d8a3af89fa9ec29e6895fb7effe418 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -118,22 +118,18 @@ void BookmarksFunction::Observe(NotificationType type,
Release(); // Balanced in Run().
}
-// static
-ExtensionBookmarkEventRouter* ExtensionBookmarkEventRouter::GetInstance() {
- return Singleton<ExtensionBookmarkEventRouter>::get();
-}
-
-ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter() {
+ExtensionBookmarkEventRouter::ExtensionBookmarkEventRouter(
+ BookmarkModel* model) : model_(model) {
}
ExtensionBookmarkEventRouter::~ExtensionBookmarkEventRouter() {
+ if (model_) {
+ model_->RemoveObserver(this);
+ }
}
-void ExtensionBookmarkEventRouter::Observe(BookmarkModel* model) {
- if (models_.find(model) == models_.end()) {
- model->AddObserver(this);
- models_.insert(model);
- }
+void ExtensionBookmarkEventRouter::Init() {
+ model_->AddObserver(this);
}
void ExtensionBookmarkEventRouter::DispatchEvent(Profile *profile,
@@ -150,6 +146,11 @@ void ExtensionBookmarkEventRouter::Loaded(BookmarkModel* model) {
// so they know when it's safe to use the API?
}
+void ExtensionBookmarkEventRouter::BookmarkModelBeingDeleted(
+ BookmarkModel* model) {
+ model_ = NULL;
+}
+
void ExtensionBookmarkEventRouter::BookmarkNodeMoved(
BookmarkModel* model,
const BookmarkNode* old_parent,
« no previous file with comments | « chrome/browser/extensions/extension_bookmarks_module.h ('k') | chrome/browser/extensions/extension_cookies_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698