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

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

Issue 10626007: Move ExtensionSystem into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Master merge; moved class declaration Created 8 years, 5 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
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/extension_event_router.h" 5 #include "chrome/browser/extensions/extension_event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 UserGestureState user_gesture, 96 UserGestureState user_gesture,
97 const extensions::EventFilteringInfo& info) { 97 const extensions::EventFilteringInfo& info) {
98 scoped_ptr<Value> event_args_value(Value::CreateStringValue(event_args)); 98 scoped_ptr<Value> event_args_value(Value::CreateStringValue(event_args));
99 DispatchEvent(ipc_sender, extension_id, event_name, *event_args_value.get(), 99 DispatchEvent(ipc_sender, extension_id, event_name, *event_args_value.get(),
100 event_url, user_gesture, info); 100 event_url, user_gesture, info);
101 } 101 }
102 102
103 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 103 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
104 : profile_(profile), 104 : profile_(profile),
105 extension_devtools_manager_( 105 extension_devtools_manager_(
106 ExtensionSystem::Get(profile)->devtools_manager()), 106 extensions::ExtensionSystem::Get(profile)->devtools_manager()),
107 listeners_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 107 listeners_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
108 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 108 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
109 content::NotificationService::AllSources()); 109 content::NotificationService::AllSources());
110 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 110 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
111 content::NotificationService::AllSources()); 111 content::NotificationService::AllSources());
112 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 112 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
113 content::Source<Profile>(profile_)); 113 content::Source<Profile>(profile_));
114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 114 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
115 content::Source<Profile>(profile_)); 115 content::Source<Profile>(profile_));
116 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 116 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 467
468 void ExtensionEventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( 468 void ExtensionEventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent(
469 Profile* profile, 469 Profile* profile,
470 const Extension* extension, 470 const Extension* extension,
471 const linked_ptr<ExtensionEvent>& event) { 471 const linked_ptr<ExtensionEvent>& event) {
472 const Value* event_args = NULL; 472 const Value* event_args = NULL;
473 if (!CanDispatchEventToProfile(profile, extension, event, &event_args)) 473 if (!CanDispatchEventToProfile(profile, extension, event, &event_args))
474 return; 474 return;
475 475
476 extensions::LazyBackgroundTaskQueue* queue = 476 extensions::LazyBackgroundTaskQueue* queue =
477 ExtensionSystem::Get(profile)->lazy_background_task_queue(); 477 extensions::ExtensionSystem::Get(profile)->lazy_background_task_queue();
478 if (queue->ShouldEnqueueTask(profile, extension)) { 478 if (queue->ShouldEnqueueTask(profile, extension)) {
479 queue->AddPendingTask( 479 queue->AddPendingTask(
480 profile, extension->id(), 480 profile, extension->id(),
481 base::Bind(&ExtensionEventRouter::DispatchPendingEvent, 481 base::Bind(&ExtensionEventRouter::DispatchPendingEvent,
482 base::Unretained(this), event)); 482 base::Unretained(this), event));
483 } 483 }
484 } 484 }
485 485
486 void ExtensionEventRouter::IncrementInFlightEvents( 486 void ExtensionEventRouter::IncrementInFlightEvents(
487 Profile* profile, const Extension* extension) { 487 Profile* profile, const Extension* extension) {
488 // Only increment in-flight events if the lazy background page is active, 488 // Only increment in-flight events if the lazy background page is active,
489 // because that's the only time we'll get an ACK. 489 // because that's the only time we'll get an ACK.
490 if (extension->has_lazy_background_page()) { 490 if (extension->has_lazy_background_page()) {
491 ExtensionProcessManager* pm = 491 ExtensionProcessManager* pm =
492 ExtensionSystem::Get(profile)->process_manager(); 492 extensions::ExtensionSystem::Get(profile)->process_manager();
493 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); 493 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id());
494 if (host) 494 if (host)
495 pm->IncrementLazyKeepaliveCount(extension); 495 pm->IncrementLazyKeepaliveCount(extension);
496 } 496 }
497 } 497 }
498 498
499 void ExtensionEventRouter::OnEventAck( 499 void ExtensionEventRouter::OnEventAck(
500 Profile* profile, const std::string& extension_id) { 500 Profile* profile, const std::string& extension_id) {
501 ExtensionProcessManager* pm = 501 ExtensionProcessManager* pm =
502 ExtensionSystem::Get(profile)->process_manager(); 502 extensions::ExtensionSystem::Get(profile)->process_manager();
503 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id); 503 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id);
504 // The event ACK is routed to the background host, so this should never be 504 // The event ACK is routed to the background host, so this should never be
505 // NULL. 505 // NULL.
506 CHECK(host); 506 CHECK(host);
507 // TODO(mpcomplete): We should never get this message unless 507 // TODO(mpcomplete): We should never get this message unless
508 // has_lazy_background_page is true. Find out why we're getting it anyway. 508 // has_lazy_background_page is true. Find out why we're getting it anyway.
509 if (host->extension() && host->extension()->has_lazy_background_page()) 509 if (host->extension() && host->extension()->has_lazy_background_page())
510 pm->DecrementLazyKeepaliveCount(host->extension()); 510 pm->DecrementLazyKeepaliveCount(host->extension());
511 } 511 }
512 512
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 event_args(event_args.DeepCopy()), 618 event_args(event_args.DeepCopy()),
619 event_url(event_url), 619 event_url(event_url),
620 restrict_to_profile(restrict_to_profile), 620 restrict_to_profile(restrict_to_profile),
621 cross_incognito_args(NULL), 621 cross_incognito_args(NULL),
622 user_gesture(user_gesture), 622 user_gesture(user_gesture),
623 info(info) { 623 info(info) {
624 } 624 }
625 625
626 ExtensionEvent::~ExtensionEvent() { 626 ExtensionEvent::~ExtensionEvent() {
627 } 627 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_devtools_bridge.cc ('k') | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698