| OLD | NEW |
| 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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 extension, context); | 624 extension, context); |
| 625 } | 625 } |
| 626 | 626 |
| 627 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( | 627 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( |
| 628 BrowserContext* context, | 628 BrowserContext* context, |
| 629 const Extension* extension, | 629 const Extension* extension, |
| 630 const linked_ptr<Event>& event) { | 630 const linked_ptr<Event>& event) { |
| 631 if (!CanDispatchEventToBrowserContext(context, extension, event)) | 631 if (!CanDispatchEventToBrowserContext(context, extension, event)) |
| 632 return false; | 632 return false; |
| 633 | 633 |
| 634 LazyBackgroundTaskQueue* queue = ExtensionSystem::Get( | 634 LazyBackgroundTaskQueue* queue = LazyBackgroundTaskQueue::Get( |
| 635 context)->lazy_background_task_queue(); | 635 context); |
| 636 if (queue->ShouldEnqueueTask(context, extension)) { | 636 if (queue->ShouldEnqueueTask(context, extension)) { |
| 637 linked_ptr<Event> dispatched_event(event); | 637 linked_ptr<Event> dispatched_event(event); |
| 638 | 638 |
| 639 // If there's a dispatch callback, call it now (rather than dispatch time) | 639 // If there's a dispatch callback, call it now (rather than dispatch time) |
| 640 // to avoid lifetime issues. Use a separate copy of the event args, so they | 640 // to avoid lifetime issues. Use a separate copy of the event args, so they |
| 641 // last until the event is dispatched. | 641 // last until the event is dispatched. |
| 642 if (!event->will_dispatch_callback.is_null()) { | 642 if (!event->will_dispatch_callback.is_null()) { |
| 643 dispatched_event.reset(event->DeepCopy()); | 643 dispatched_event.reset(event->DeepCopy()); |
| 644 if (!dispatched_event->will_dispatch_callback.Run( | 644 if (!dispatched_event->will_dispatch_callback.Run( |
| 645 context, extension, dispatched_event->event_args.get())) { | 645 context, extension, dispatched_event->event_args.get())) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 // Remove all event listeners associated with this renderer. | 738 // Remove all event listeners associated with this renderer. |
| 739 listeners_.RemoveListenersForProcess(renderer); | 739 listeners_.RemoveListenersForProcess(renderer); |
| 740 break; | 740 break; |
| 741 } | 741 } |
| 742 case extensions::NOTIFICATION_EXTENSION_ENABLED: { | 742 case extensions::NOTIFICATION_EXTENSION_ENABLED: { |
| 743 // If the extension has a lazy background page, make sure it gets loaded | 743 // If the extension has a lazy background page, make sure it gets loaded |
| 744 // to register the events the extension is interested in. | 744 // to register the events the extension is interested in. |
| 745 const Extension* extension = | 745 const Extension* extension = |
| 746 content::Details<const Extension>(details).ptr(); | 746 content::Details<const Extension>(details).ptr(); |
| 747 if (BackgroundInfo::HasLazyBackgroundPage(extension)) { | 747 if (BackgroundInfo::HasLazyBackgroundPage(extension)) { |
| 748 LazyBackgroundTaskQueue* queue = ExtensionSystem::Get( | 748 LazyBackgroundTaskQueue* queue = LazyBackgroundTaskQueue::Get( |
| 749 browser_context_)->lazy_background_task_queue(); | 749 browser_context_); |
| 750 queue->AddPendingTask(browser_context_, extension->id(), | 750 queue->AddPendingTask(browser_context_, extension->id(), |
| 751 base::Bind(&DoNothing)); | 751 base::Bind(&DoNothing)); |
| 752 } | 752 } |
| 753 break; | 753 break; |
| 754 } | 754 } |
| 755 default: | 755 default: |
| 756 NOTREACHED(); | 756 NOTREACHED(); |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 | 759 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 const std::string& extension_id, | 826 const std::string& extension_id, |
| 827 const GURL& listener_url, | 827 const GURL& listener_url, |
| 828 content::BrowserContext* browser_context) | 828 content::BrowserContext* browser_context) |
| 829 : event_name(event_name), | 829 : event_name(event_name), |
| 830 extension_id(extension_id), | 830 extension_id(extension_id), |
| 831 listener_url(listener_url), | 831 listener_url(listener_url), |
| 832 browser_context(browser_context) { | 832 browser_context(browser_context) { |
| 833 } | 833 } |
| 834 | 834 |
| 835 } // namespace extensions | 835 } // namespace extensions |
| OLD | NEW |