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

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

Issue 1129063011: Extract LazyBackgroundTaskQueue from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased from master Created 5 years, 7 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
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.cc ('k') | extensions/browser/extension_system.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 extension, context); 631 extension, context);
632 } 632 }
633 633
634 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( 634 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent(
635 BrowserContext* context, 635 BrowserContext* context,
636 const Extension* extension, 636 const Extension* extension,
637 const linked_ptr<Event>& event) { 637 const linked_ptr<Event>& event) {
638 if (!CanDispatchEventToBrowserContext(context, extension, event)) 638 if (!CanDispatchEventToBrowserContext(context, extension, event))
639 return false; 639 return false;
640 640
641 LazyBackgroundTaskQueue* queue = ExtensionSystem::Get( 641 LazyBackgroundTaskQueue* queue = LazyBackgroundTaskQueue::Get(context);
642 context)->lazy_background_task_queue();
643 if (queue->ShouldEnqueueTask(context, extension)) { 642 if (queue->ShouldEnqueueTask(context, extension)) {
644 linked_ptr<Event> dispatched_event(event); 643 linked_ptr<Event> dispatched_event(event);
645 644
646 // If there's a dispatch callback, call it now (rather than dispatch time) 645 // If there's a dispatch callback, call it now (rather than dispatch time)
647 // to avoid lifetime issues. Use a separate copy of the event args, so they 646 // to avoid lifetime issues. Use a separate copy of the event args, so they
648 // last until the event is dispatched. 647 // last until the event is dispatched.
649 if (!event->will_dispatch_callback.is_null()) { 648 if (!event->will_dispatch_callback.is_null()) {
650 dispatched_event.reset(event->DeepCopy()); 649 dispatched_event.reset(event->DeepCopy());
651 if (!dispatched_event->will_dispatch_callback.Run( 650 if (!dispatched_event->will_dispatch_callback.Run(
652 context, extension, dispatched_event->event_args.get())) { 651 context, extension, dispatched_event->event_args.get())) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 // Remove all event listeners associated with this renderer. 744 // Remove all event listeners associated with this renderer.
746 listeners_.RemoveListenersForProcess(renderer); 745 listeners_.RemoveListenersForProcess(renderer);
747 break; 746 break;
748 } 747 }
749 case extensions::NOTIFICATION_EXTENSION_ENABLED: { 748 case extensions::NOTIFICATION_EXTENSION_ENABLED: {
750 // If the extension has a lazy background page, make sure it gets loaded 749 // If the extension has a lazy background page, make sure it gets loaded
751 // to register the events the extension is interested in. 750 // to register the events the extension is interested in.
752 const Extension* extension = 751 const Extension* extension =
753 content::Details<const Extension>(details).ptr(); 752 content::Details<const Extension>(details).ptr();
754 if (BackgroundInfo::HasLazyBackgroundPage(extension)) { 753 if (BackgroundInfo::HasLazyBackgroundPage(extension)) {
755 LazyBackgroundTaskQueue* queue = ExtensionSystem::Get( 754 LazyBackgroundTaskQueue* queue =
756 browser_context_)->lazy_background_task_queue(); 755 LazyBackgroundTaskQueue::Get(browser_context_);
757 queue->AddPendingTask(browser_context_, extension->id(), 756 queue->AddPendingTask(browser_context_, extension->id(),
758 base::Bind(&DoNothing)); 757 base::Bind(&DoNothing));
759 } 758 }
760 break; 759 break;
761 } 760 }
762 default: 761 default:
763 NOTREACHED(); 762 NOTREACHED();
764 } 763 }
765 } 764 }
766 765
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 const std::string& extension_id, 832 const std::string& extension_id,
834 const GURL& listener_url, 833 const GURL& listener_url,
835 content::BrowserContext* browser_context) 834 content::BrowserContext* browser_context)
836 : event_name(event_name), 835 : event_name(event_name),
837 extension_id(extension_id), 836 extension_id(extension_id),
838 listener_url(listener_url), 837 listener_url(listener_url),
839 browser_context(browser_context) { 838 browser_context(browser_context) {
840 } 839 }
841 840
842 } // namespace extensions 841 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.cc ('k') | extensions/browser/extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698