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

Unified Diff: chrome/browser/extensions/api/bookmarks/bookmarks_api.cc

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 11 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/api/bookmarks/bookmarks_api.cc
diff --git a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc b/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
index 77792946309ef28bfc0c6170fcd03e6f27035624..7329ab4fcb7a0cdb15c6238b76e28e8e895e6bec 100644
--- a/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
+++ b/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
@@ -9,6 +9,7 @@
#include "base/i18n/file_util_icu.h"
#include "base/i18n/time_formatting.h"
#include "base/json/json_writer.h"
+#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/prefs/public/pref_service_base.h"
@@ -273,7 +274,7 @@ void BookmarkEventRouter::ExtensiveBookmarkChangesEnded(BookmarkModel* model) {
args.Pass());
}
-BookmarkAPI::BookmarkAPI(Profile* profile) : profile_(profile) {
+BookmarksAPI::BookmarksAPI(Profile* profile) : profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
this, keys::kOnBookmarkCreated);
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
@@ -290,14 +291,22 @@ BookmarkAPI::BookmarkAPI(Profile* profile) : profile_(profile) {
this, keys::kOnBookmarkImportEnded);
}
-BookmarkAPI::~BookmarkAPI() {
+BookmarksAPI::~BookmarksAPI() {
}
-void BookmarkAPI::Shutdown() {
+void BookmarksAPI::Shutdown() {
ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
}
-void BookmarkAPI::OnListenerAdded(const EventListenerInfo& details) {
+static base::LazyInstance<ProfileKeyedAPIFactory<BookmarksAPI> >
+g_factory = LAZY_INSTANCE_INITIALIZER;
+
+// static
+ProfileKeyedAPIFactory<BookmarksAPI>* BookmarksAPI::GetFactoryInstance() {
+ return &g_factory.Get();
+}
+
+void BookmarksAPI::OnListenerAdded(const EventListenerInfo& details) {
bookmark_event_router_.reset(new BookmarkEventRouter(
BookmarkModelFactory::GetForProfile(profile_)));
ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
« no previous file with comments | « chrome/browser/extensions/api/bookmarks/bookmarks_api.h ('k') | chrome/browser/extensions/api/commands/command_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698