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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments 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 | 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/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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 !process_map->Contains(extension->id(), process->GetID())) { 429 !process_map->Contains(extension->id(), process->GetID())) {
430 return; 430 return;
431 } 431 }
432 432
433 const Value* event_args = NULL; 433 const Value* event_args = NULL;
434 if (!CanDispatchEventToProfile(listener_profile, extension, 434 if (!CanDispatchEventToProfile(listener_profile, extension,
435 event, &event_args)) { 435 event, &event_args)) {
436 return; 436 return;
437 } 437 }
438 438
439 // We need to call IncrementInFlightEvents() before DispatchEvent() because
440 // the former may prevent this extension from getting suspended and so send
441 // the onSuspendCanceled() to the extension, which needs to arrive before the
442 // event that DispatchEvent() is dispatching.
443 IncrementInFlightEvents(listener_profile, extension);
444
439 DispatchEvent(process, extension_id, 445 DispatchEvent(process, extension_id,
440 event->event_name, *event_args, 446 event->event_name, *event_args,
441 event->event_url, event->user_gesture, 447 event->event_url, event->user_gesture,
442 event->info); 448 event->info);
443 IncrementInFlightEvents(listener_profile, extension);
444 } 449 }
445 450
446 bool ExtensionEventRouter::CanDispatchEventToProfile( 451 bool ExtensionEventRouter::CanDispatchEventToProfile(
447 Profile* profile, 452 Profile* profile,
448 const Extension* extension, 453 const Extension* extension,
449 const linked_ptr<ExtensionEvent>& event, 454 const linked_ptr<ExtensionEvent>& event,
450 const Value** event_args) { 455 const Value** event_args) {
451 *event_args = event->event_args.get(); 456 *event_args = event->event_args.get();
452 457
453 // Is this event from a different profile than the renderer (ie, an 458 // Is this event from a different profile than the renderer (ie, an
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 491
487 void ExtensionEventRouter::IncrementInFlightEvents( 492 void ExtensionEventRouter::IncrementInFlightEvents(
488 Profile* profile, const Extension* extension) { 493 Profile* profile, const Extension* extension) {
489 // Only increment in-flight events if the lazy background page is active, 494 // Only increment in-flight events if the lazy background page is active,
490 // because that's the only time we'll get an ACK. 495 // because that's the only time we'll get an ACK.
491 if (extension->has_lazy_background_page()) { 496 if (extension->has_lazy_background_page()) {
492 ExtensionProcessManager* pm = 497 ExtensionProcessManager* pm =
493 extensions::ExtensionSystem::Get(profile)->process_manager(); 498 extensions::ExtensionSystem::Get(profile)->process_manager();
494 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); 499 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id());
495 if (host) 500 if (host)
496 pm->IncrementLazyKeepaliveCount(extension); 501 pm->IncrementLazyKeepaliveCount(extension, true);
497 } 502 }
498 } 503 }
499 504
500 void ExtensionEventRouter::OnEventAck( 505 void ExtensionEventRouter::OnEventAck(
501 Profile* profile, const std::string& extension_id) { 506 Profile* profile, const std::string& extension_id) {
502 ExtensionProcessManager* pm = 507 ExtensionProcessManager* pm =
503 extensions::ExtensionSystem::Get(profile)->process_manager(); 508 extensions::ExtensionSystem::Get(profile)->process_manager();
504 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id); 509 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id);
505 // The event ACK is routed to the background host, so this should never be 510 // The event ACK is routed to the background host, so this should never be
506 // NULL. 511 // NULL.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 event_args(event_args.DeepCopy()), 624 event_args(event_args.DeepCopy()),
620 event_url(event_url), 625 event_url(event_url),
621 restrict_to_profile(restrict_to_profile), 626 restrict_to_profile(restrict_to_profile),
622 cross_incognito_args(NULL), 627 cross_incognito_args(NULL),
623 user_gesture(user_gesture), 628 user_gesture(user_gesture),
624 info(info) { 629 info(info) {
625 } 630 }
626 631
627 ExtensionEvent::~ExtensionEvent() { 632 ExtensionEvent::~ExtensionEvent() {
628 } 633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698