| 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 "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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "base/version.h" | 14 #include "base/version.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/activity_log/activity_log.h" | 17 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 19 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 19 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 20 #include "chrome/browser/extensions/event_names.h" | 20 #include "chrome/browser/extensions/event_names.h" |
| 21 #include "chrome/browser/extensions/extension_host.h" | 21 #include "chrome/browser/extensions/extension_host.h" |
| 22 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 23 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_system.h" | 23 #include "chrome/browser/extensions/extension_system.h" |
| 25 #include "chrome/browser/extensions/extension_util.h" | 24 #include "chrome/browser/extensions/extension_util.h" |
| 26 #include "chrome/browser/extensions/process_map.h" | 25 #include "chrome/browser/extensions/process_map.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/chrome_version_info.h" | 29 #include "chrome/common/chrome_version_info.h" |
| 31 #include "chrome/common/extensions/extension.h" | 30 #include "chrome/common/extensions/extension.h" |
| 32 #include "chrome/common/extensions/extension_messages.h" | 31 #include "chrome/common/extensions/extension_messages.h" |
| 33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 34 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 35 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 36 #include "extensions/browser/lazy_background_task_queue.h" | 35 #include "extensions/browser/lazy_background_task_queue.h" |
| 36 #include "extensions/browser/process_manager.h" |
| 37 #include "extensions/common/extension_api.h" | 37 #include "extensions/common/extension_api.h" |
| 38 #include "extensions/common/extension_urls.h" | 38 #include "extensions/common/extension_urls.h" |
| 39 #include "extensions/common/manifest_handlers/background_info.h" | 39 #include "extensions/common/manifest_handlers/background_info.h" |
| 40 #include "extensions/common/manifest_handlers/incognito_info.h" | 40 #include "extensions/common/manifest_handlers/incognito_info.h" |
| 41 | 41 |
| 42 using base::DictionaryValue; | 42 using base::DictionaryValue; |
| 43 using base::ListValue; | 43 using base::ListValue; |
| 44 using content::BrowserThread; | 44 using content::BrowserThread; |
| 45 | 45 |
| 46 namespace extensions { | 46 namespace extensions { |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 if (!extension) | 692 if (!extension) |
| 693 return; | 693 return; |
| 694 event_router->IncrementInFlightEvents(profile, extension); | 694 event_router->IncrementInFlightEvents(profile, extension); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void EventRouter::IncrementInFlightEvents(Profile* profile, | 697 void EventRouter::IncrementInFlightEvents(Profile* profile, |
| 698 const Extension* extension) { | 698 const Extension* extension) { |
| 699 // Only increment in-flight events if the lazy background page is active, | 699 // Only increment in-flight events if the lazy background page is active, |
| 700 // because that's the only time we'll get an ACK. | 700 // because that's the only time we'll get an ACK. |
| 701 if (BackgroundInfo::HasLazyBackgroundPage(extension)) { | 701 if (BackgroundInfo::HasLazyBackgroundPage(extension)) { |
| 702 ExtensionProcessManager* pm = | 702 extensions::ProcessManager* pm = |
| 703 ExtensionSystem::Get(profile)->process_manager(); | 703 ExtensionSystem::Get(profile)->process_manager(); |
| 704 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); | 704 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id()); |
| 705 if (host) | 705 if (host) |
| 706 pm->IncrementLazyKeepaliveCount(extension); | 706 pm->IncrementLazyKeepaliveCount(extension); |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 | 709 |
| 710 void EventRouter::OnEventAck(Profile* profile, | 710 void EventRouter::OnEventAck(Profile* profile, |
| 711 const std::string& extension_id) { | 711 const std::string& extension_id) { |
| 712 ExtensionProcessManager* pm = | 712 extensions::ProcessManager* pm = |
| 713 ExtensionSystem::Get(profile)->process_manager(); | 713 ExtensionSystem::Get(profile)->process_manager(); |
| 714 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id); | 714 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id); |
| 715 // The event ACK is routed to the background host, so this should never be | 715 // The event ACK is routed to the background host, so this should never be |
| 716 // NULL. | 716 // NULL. |
| 717 CHECK(host); | 717 CHECK(host); |
| 718 // TODO(mpcomplete): We should never get this message unless | 718 // TODO(mpcomplete): We should never get this message unless |
| 719 // HasLazyBackgroundPage is true. Find out why we're getting it anyway. | 719 // HasLazyBackgroundPage is true. Find out why we're getting it anyway. |
| 720 if (host->extension() && | 720 if (host->extension() && |
| 721 BackgroundInfo::HasLazyBackgroundPage(host->extension())) | 721 BackgroundInfo::HasLazyBackgroundPage(host->extension())) |
| 722 pm->DecrementLazyKeepaliveCount(host->extension()); | 722 pm->DecrementLazyKeepaliveCount(host->extension()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 copy->will_dispatch_callback = will_dispatch_callback; | 861 copy->will_dispatch_callback = will_dispatch_callback; |
| 862 return copy; | 862 return copy; |
| 863 } | 863 } |
| 864 | 864 |
| 865 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 865 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
| 866 const std::string& extension_id) | 866 const std::string& extension_id) |
| 867 : event_name(event_name), | 867 : event_name(event_name), |
| 868 extension_id(extension_id) {} | 868 extension_id(extension_id) {} |
| 869 | 869 |
| 870 } // namespace extensions | 870 } // namespace extensions |
| OLD | NEW |