OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/process_manager.h" | 5 #include "extensions/browser/process_manager.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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 UnregisterRenderViewHost(view); | 672 UnregisterRenderViewHost(view); |
673 } | 673 } |
674 | 674 |
675 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 675 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
676 if (host) | 676 if (host) |
677 CloseBackgroundHost(host); | 677 CloseBackgroundHost(host); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 void ProcessManager::OnNetworkRequestStarted( | 681 void ProcessManager::OnNetworkRequestStarted( |
682 content::RenderFrameHost* render_frame_host) { | 682 content::RenderFrameHost* render_frame_host, |
| 683 uint64 request_id) { |
683 ExtensionHost* host = GetBackgroundHostForExtension( | 684 ExtensionHost* host = GetBackgroundHostForExtension( |
684 GetExtensionIDFromFrame(render_frame_host)); | 685 GetExtensionIDFromFrame(render_frame_host)); |
685 if (host && IsFrameInExtensionHost(host, render_frame_host)) | 686 if (host && IsFrameInExtensionHost(host, render_frame_host)) { |
686 IncrementLazyKeepaliveCount(host->extension()); | 687 IncrementLazyKeepaliveCount(host->extension()); |
| 688 host->OnNetworkRequestStarted(request_id); |
| 689 } |
687 } | 690 } |
688 | 691 |
689 void ProcessManager::OnNetworkRequestDone( | 692 void ProcessManager::OnNetworkRequestDone( |
690 content::RenderFrameHost* render_frame_host) { | 693 content::RenderFrameHost* render_frame_host, |
| 694 uint64 request_id) { |
691 ExtensionHost* host = GetBackgroundHostForExtension( | 695 ExtensionHost* host = GetBackgroundHostForExtension( |
692 GetExtensionIDFromFrame(render_frame_host)); | 696 GetExtensionIDFromFrame(render_frame_host)); |
693 if (host && IsFrameInExtensionHost(host, render_frame_host)) | 697 if (host && IsFrameInExtensionHost(host, render_frame_host)) { |
| 698 host->OnNetworkRequestDone(request_id); |
694 DecrementLazyKeepaliveCount(host->extension()); | 699 DecrementLazyKeepaliveCount(host->extension()); |
| 700 } |
695 } | 701 } |
696 | 702 |
697 void ProcessManager::CancelSuspend(const Extension* extension) { | 703 void ProcessManager::CancelSuspend(const Extension* extension) { |
698 bool& is_closing = background_page_data_[extension->id()].is_closing; | 704 bool& is_closing = background_page_data_[extension->id()].is_closing; |
699 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); | 705 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); |
700 if (host && is_closing) { | 706 if (host && is_closing) { |
701 is_closing = false; | 707 is_closing = false; |
702 host->render_view_host()->Send( | 708 host->render_view_host()->Send( |
703 new ExtensionMsg_CancelSuspend(extension->id())); | 709 new ExtensionMsg_CancelSuspend(extension->id())); |
704 // This increment / decrement is to simulate an instantaneous event. This | 710 // This increment / decrement is to simulate an instantaneous event. This |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 | 930 |
925 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) { | 931 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) { |
926 linked_ptr<base::ElapsedTimer> since_suspended( | 932 linked_ptr<base::ElapsedTimer> since_suspended( |
927 background_page_data_[host->extension()->id()]. | 933 background_page_data_[host->extension()->id()]. |
928 since_suspended.release()); | 934 since_suspended.release()); |
929 if (since_suspended.get()) { | 935 if (since_suspended.get()) { |
930 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", | 936 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", |
931 since_suspended->Elapsed()); | 937 since_suspended->Elapsed()); |
932 } | 938 } |
933 } | 939 } |
| 940 FOR_EACH_OBSERVER(ProcessManagerObserver, observer_list_, |
| 941 OnBackgroundHostCreated(host)); |
934 } | 942 } |
935 | 943 |
936 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { | 944 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { |
937 ExtensionId extension_id = host->extension_id(); | 945 ExtensionId extension_id = host->extension_id(); |
938 CHECK(host->extension_host_type() == | 946 CHECK(host->extension_host_type() == |
939 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 947 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
940 delete host; | 948 delete host; |
941 // |host| should deregister itself from our structures. | 949 // |host| should deregister itself from our structures. |
942 CHECK(background_hosts_.find(host) == background_hosts_.end()); | 950 CHECK(background_hosts_.find(host) == background_hosts_.end()); |
943 | 951 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 1033 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
1026 BrowserContext* original_context = | 1034 BrowserContext* original_context = |
1027 ExtensionsBrowserClient::Get()->GetOriginalContext(GetBrowserContext()); | 1035 ExtensionsBrowserClient::Get()->GetOriginalContext(GetBrowserContext()); |
1028 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); | 1036 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); |
1029 } | 1037 } |
1030 | 1038 |
1031 return ProcessManager::GetSiteInstanceForURL(url); | 1039 return ProcessManager::GetSiteInstanceForURL(url); |
1032 } | 1040 } |
1033 | 1041 |
1034 } // namespace extensions | 1042 } // namespace extensions |
OLD | NEW |