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

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

Issue 11366074: Coalesce event router Init calls into their constructors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa Created 8 years, 1 month 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_extension_api.h" 5 #include "chrome/browser/bookmarks/bookmark_extension_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/i18n/file_util_icu.h" 9 #include "base/i18n/file_util_icu.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (!source_profile || !source_profile->IsSameProfile(profile())) 130 if (!source_profile || !source_profile->IsSameProfile(profile()))
131 return; 131 return;
132 132
133 DCHECK(BookmarkModelFactory::GetForProfile(profile())->IsLoaded()); 133 DCHECK(BookmarkModelFactory::GetForProfile(profile())->IsLoaded());
134 Run(); 134 Run();
135 Release(); // Balanced in Run(). 135 Release(); // Balanced in Run().
136 } 136 }
137 137
138 BookmarkExtensionEventRouter::BookmarkExtensionEventRouter( 138 BookmarkExtensionEventRouter::BookmarkExtensionEventRouter(
139 BookmarkModel* model) : model_(model) { 139 BookmarkModel* model) : model_(model) {
140 model_->AddObserver(this);
140 } 141 }
141 142
142 BookmarkExtensionEventRouter::~BookmarkExtensionEventRouter() { 143 BookmarkExtensionEventRouter::~BookmarkExtensionEventRouter() {
143 if (model_) { 144 if (model_) {
144 model_->RemoveObserver(this); 145 model_->RemoveObserver(this);
145 } 146 }
146 } 147 }
147 148
148 void BookmarkExtensionEventRouter::Init() {
149 model_->AddObserver(this);
150 }
151
152 void BookmarkExtensionEventRouter::DispatchEvent( 149 void BookmarkExtensionEventRouter::DispatchEvent(
153 Profile* profile, 150 Profile* profile,
154 const char* event_name, 151 const char* event_name,
155 scoped_ptr<ListValue> event_args) { 152 scoped_ptr<ListValue> event_args) {
156 if (extensions::ExtensionSystem::Get(profile)->event_router()) { 153 if (extensions::ExtensionSystem::Get(profile)->event_router()) {
157 extensions::ExtensionSystem::Get(profile)->event_router()-> 154 extensions::ExtensionSystem::Get(profile)->event_router()->
158 DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(), 155 DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(),
159 extensions::EventFilteringInfo()); 156 extensions::EventFilteringInfo());
160 } 157 }
161 } 158 }
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 int index, 956 int index,
960 void* params) { 957 void* params) {
961 #if !defined(OS_ANDROID) 958 #if !defined(OS_ANDROID)
962 // Android does not have support for the standard exporter. 959 // Android does not have support for the standard exporter.
963 // TODO(jgreenwald): remove ifdef once extensions are no longer built on 960 // TODO(jgreenwald): remove ifdef once extensions are no longer built on
964 // Android. 961 // Android.
965 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 962 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
966 #endif 963 #endif
967 Release(); // Balanced in BookmarksIOFunction::SelectFile() 964 Release(); // Balanced in BookmarksIOFunction::SelectFile()
968 } 965 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_extension_api.h ('k') | chrome/browser/extensions/api/cookies/cookies_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698