| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 156 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 157 content::Source<Profile>(profile)); | 157 content::Source<Profile>(profile)); |
| 158 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 158 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 159 content::NotificationService::AllSources()); | 159 content::NotificationService::AllSources()); |
| 160 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 160 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 161 content::Source<Profile>(profile)); | 161 content::Source<Profile>(profile)); |
| 162 if (profile->IsOffTheRecord()) { | 162 if (profile->IsOffTheRecord()) { |
| 163 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 163 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 164 content::Source<Profile>(original_profile)); | 164 content::Source<Profile>(original_profile)); |
| 165 } | 165 } |
| 166 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING, | 166 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED, |
| 167 content::Source<content::BrowserContext>(profile)); | 167 content::Source<content::BrowserContext>(profile)); |
| 168 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, | 168 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED, |
| 169 content::Source<content::BrowserContext>(profile)); | 169 content::Source<content::BrowserContext>(profile)); |
| 170 | 170 |
| 171 event_page_idle_time_ = base::TimeDelta::FromSeconds(10); | 171 event_page_idle_time_ = base::TimeDelta::FromSeconds(10); |
| 172 unsigned idle_time_sec = 0; | 172 unsigned idle_time_sec = 0; |
| 173 if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 173 if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 174 switches::kEventPageIdleTime), &idle_time_sec)) { | 174 switches::kEventPageIdleTime), &idle_time_sec)) { |
| 175 event_page_idle_time_ = base::TimeDelta::FromSeconds(idle_time_sec); | 175 event_page_idle_time_ = base::TimeDelta::FromSeconds(idle_time_sec); |
| 176 } | 176 } |
| 177 event_page_unloading_time_ = base::TimeDelta::FromSeconds(5); | 177 event_page_unloading_time_ = base::TimeDelta::FromSeconds(5); |
| 178 unsigned unloading_time_sec = 0; | 178 unsigned unloading_time_sec = 0; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 } | 622 } |
| 623 | 623 |
| 624 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 624 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 625 // Close background hosts when the last browser is closed so that they | 625 // Close background hosts when the last browser is closed so that they |
| 626 // have time to shutdown various objects on different threads. Our | 626 // have time to shutdown various objects on different threads. Our |
| 627 // destructor is called too late in the shutdown sequence. | 627 // destructor is called too late in the shutdown sequence. |
| 628 CloseBackgroundHosts(); | 628 CloseBackgroundHosts(); |
| 629 break; | 629 break; |
| 630 } | 630 } |
| 631 | 631 |
| 632 case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING: { | 632 case content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED: { |
| 633 RenderViewHost* render_view_host = | 633 RenderViewHost* render_view_host = |
| 634 content::Details<RenderViewHost>(details).ptr(); | 634 content::Details<RenderViewHost>(details).ptr(); |
| 635 WebContents* web_contents = | 635 WebContents* web_contents = |
| 636 WebContents::FromRenderViewHost(render_view_host); | 636 WebContents::FromRenderViewHost(render_view_host); |
| 637 // Keep the lazy background page alive while it's being inspected. | 637 // Keep the lazy background page alive while it's being inspected. |
| 638 // Balanced in response to the CLOSING notification. | 638 // Balanced in response to the CLOSING notification. |
| 639 if (chrome::GetViewType(web_contents) == | 639 if (chrome::GetViewType(web_contents) == |
| 640 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 640 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 641 const Extension* extension = GetExtensionForRenderViewHost( | 641 const Extension* extension = GetExtensionForRenderViewHost( |
| 642 render_view_host); | 642 render_view_host); |
| 643 if (extension) | 643 if (extension) { |
| 644 CancelSuspend(extension); |
| 644 IncrementLazyKeepaliveCount(extension); | 645 IncrementLazyKeepaliveCount(extension); |
| 646 } |
| 645 } | 647 } |
| 646 break; | 648 break; |
| 647 } | 649 } |
| 648 | 650 |
| 649 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING: { | 651 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: { |
| 650 RenderViewHost* render_view_host = | 652 RenderViewHost* render_view_host = |
| 651 content::Details<RenderViewHost>(details).ptr(); | 653 content::Details<RenderViewHost>(details).ptr(); |
| 652 WebContents* web_contents = | 654 WebContents* web_contents = |
| 653 WebContents::FromRenderViewHost(render_view_host); | 655 WebContents::FromRenderViewHost(render_view_host); |
| 654 // Balanced in response to the OPENING notification. | 656 // Balanced in response to the OPENING notification. |
| 655 if (chrome::GetViewType(web_contents) == | 657 if (chrome::GetViewType(web_contents) == |
| 656 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 658 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
| 657 const Extension* extension = GetExtensionForRenderViewHost( | 659 const Extension* extension = GetExtensionForRenderViewHost( |
| 658 render_view_host); | 660 render_view_host); |
| 659 if (extension) | 661 if (extension) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 CreateBackgroundHostsForProfileStartup(GetProfile(), | 815 CreateBackgroundHostsForProfileStartup(GetProfile(), |
| 814 this, service->extensions()); | 816 this, service->extensions()); |
| 815 } | 817 } |
| 816 break; | 818 break; |
| 817 } | 819 } |
| 818 default: | 820 default: |
| 819 ExtensionProcessManager::Observe(type, source, details); | 821 ExtensionProcessManager::Observe(type, source, details); |
| 820 break; | 822 break; |
| 821 } | 823 } |
| 822 } | 824 } |
| OLD | NEW |