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

Side by Side Diff: chrome/browser/extensions/event_router.cc

Issue 13726026: Added ActivityLog tests and associated bugfixes/extra logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored to remove strings from IPC Created 7 years, 8 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/extensions/event_router.h" 5 #include "chrome/browser/extensions/event_router.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 observers_.erase(iters_to_remove[i]); 229 observers_.erase(iters_to_remove[i]);
230 } 230 }
231 231
232 void EventRouter::OnListenerAdded(const EventListener* listener) { 232 void EventRouter::OnListenerAdded(const EventListener* listener) {
233 const std::string& event_name = listener->event_name; 233 const std::string& event_name = listener->event_name;
234 const EventListenerInfo details(event_name, listener->extension_id); 234 const EventListenerInfo details(event_name, listener->extension_id);
235 ObserverMap::iterator observer = observers_.find(event_name); 235 ObserverMap::iterator observer = observers_.find(event_name);
236 if (observer != observers_.end()) 236 if (observer != observers_.end())
237 observer->second->OnListenerAdded(details); 237 observer->second->OnListenerAdded(details);
238 238
239 #if 0
240 // TODO(felt): Experimentally determine if these are needed, or if they
241 // can be permanently removed. Temporarily removing for now to reduce log
242 // size while under investigation.
239 const Extension* extension = extensions::ExtensionSystem::Get(profile_)-> 243 const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
240 extension_service()->GetExtensionById(listener->extension_id, 244 extension_service()->GetExtensionById(listener->extension_id,
241 ExtensionService::INCLUDE_ENABLED); 245 ExtensionService::INCLUDE_ENABLED);
242 if (extension) { 246 if (extension) {
243 scoped_ptr<ListValue> args(new ListValue()); 247 scoped_ptr<ListValue> args(new ListValue());
244 if (listener->filter) 248 if (listener->filter)
245 args->Append(listener->filter->DeepCopy()); 249 args->Append(listener->filter->DeepCopy());
246 activity_log_->LogAPIAction( 250 activity_log_->LogAPIAction(
247 extension, event_name + ".addListener", args.get(), std::string()); 251 extension, event_name + ".addListener", args.get(), std::string());
248 } 252 }
253 #endif
249 } 254 }
250 255
251 void EventRouter::OnListenerRemoved(const EventListener* listener) { 256 void EventRouter::OnListenerRemoved(const EventListener* listener) {
252 const std::string& event_name = listener->event_name; 257 const std::string& event_name = listener->event_name;
253 const EventListenerInfo details(event_name, listener->extension_id); 258 const EventListenerInfo details(event_name, listener->extension_id);
254 ObserverMap::iterator observer = observers_.find(event_name); 259 ObserverMap::iterator observer = observers_.find(event_name);
255 if (observer != observers_.end()) 260 if (observer != observers_.end())
256 observer->second->OnListenerRemoved(details); 261 observer->second->OnListenerRemoved(details);
257 262
258 void* profile = 263 void* profile =
259 listener->process 264 listener->process
260 ? Profile::FromBrowserContext(listener->process->GetBrowserContext()) 265 ? Profile::FromBrowserContext(listener->process->GetBrowserContext())
261 : NULL; 266 : NULL;
262 BrowserThread::PostTask( 267 BrowserThread::PostTask(
263 BrowserThread::IO, FROM_HERE, 268 BrowserThread::IO, FROM_HERE,
264 base::Bind(&NotifyEventListenerRemovedOnIOThread, 269 base::Bind(&NotifyEventListenerRemovedOnIOThread,
265 profile, listener->extension_id, event_name)); 270 profile, listener->extension_id, event_name));
266 271 #if 0
272 // TODO(felt): Experimentally determine if these are needed, or if they
273 // can be permanently removed. Temporarily removing for now to reduce log
274 // size while under investigation.
267 const Extension* extension = extensions::ExtensionSystem::Get(profile_)-> 275 const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
268 extension_service()->GetExtensionById(listener->extension_id, 276 extension_service()->GetExtensionById(listener->extension_id,
269 ExtensionService::INCLUDE_ENABLED); 277 ExtensionService::INCLUDE_ENABLED);
270 if (extension) { 278 if (extension) {
271 scoped_ptr<ListValue> args(new ListValue()); 279 scoped_ptr<ListValue> args(new ListValue());
272 activity_log_->LogAPIAction( 280 activity_log_->LogAPIAction(
273 extension, event_name + ".removeListener", args.get(), std::string()); 281 extension, event_name + ".removeListener", args.get(), std::string());
274 } 282 }
283 #endif
275 } 284 }
276 285
277 void EventRouter::AddLazyEventListener(const std::string& event_name, 286 void EventRouter::AddLazyEventListener(const std::string& event_name,
278 const std::string& extension_id) { 287 const std::string& extension_id) {
279 scoped_ptr<EventListener> listener(new EventListener( 288 scoped_ptr<EventListener> listener(new EventListener(
280 event_name, extension_id, NULL, scoped_ptr<DictionaryValue>())); 289 event_name, extension_id, NULL, scoped_ptr<DictionaryValue>()));
281 bool is_new = listeners_.AddListener(listener.Pass()); 290 bool is_new = listeners_.AddListener(listener.Pass());
282 291
283 if (is_new) { 292 if (is_new) {
284 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)-> 293 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile_)->
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 copy->will_dispatch_callback = will_dispatch_callback; 725 copy->will_dispatch_callback = will_dispatch_callback;
717 return copy; 726 return copy;
718 } 727 }
719 728
720 EventListenerInfo::EventListenerInfo(const std::string& event_name, 729 EventListenerInfo::EventListenerInfo(const std::string& event_name,
721 const std::string& extension_id) 730 const std::string& extension_id)
722 : event_name(event_name), 731 : event_name(event_name),
723 extension_id(extension_id) {} 732 extension_id(extension_id) {}
724 733
725 } // namespace extensions 734 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698