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

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

Issue 2044813002: Revert of Fix event page process cleanup when running in --isolate-extensions mode. (patchset #6 id… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2761
Patch Set: Created 4 years, 6 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/process_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 base::Bind(&ProcessManager::CloseLazyBackgroundPageNow, 563 base::Bind(&ProcessManager::CloseLazyBackgroundPageNow,
564 weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), 564 weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id),
565 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec)); 565 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec));
566 } 566 }
567 567
568 void ProcessManager::OnNetworkRequestStarted( 568 void ProcessManager::OnNetworkRequestStarted(
569 content::RenderFrameHost* render_frame_host, 569 content::RenderFrameHost* render_frame_host,
570 uint64_t request_id) { 570 uint64_t request_id) {
571 ExtensionHost* host = GetBackgroundHostForExtension( 571 ExtensionHost* host = GetBackgroundHostForExtension(
572 GetExtensionID(render_frame_host)); 572 GetExtensionID(render_frame_host));
573 if (!host || !IsFrameInExtensionHost(host, render_frame_host)) 573 auto result = pending_network_requests_.insert(request_id);
574 return;
575
576 auto result =
577 pending_network_requests_.insert(std::make_pair(request_id, host));
578 DCHECK(result.second) << "Duplicate network request IDs."; 574 DCHECK(result.second) << "Duplicate network request IDs.";
579 575 if (host && IsFrameInExtensionHost(host, render_frame_host)) {
580 IncrementLazyKeepaliveCount(host->extension()); 576 IncrementLazyKeepaliveCount(host->extension());
581 host->OnNetworkRequestStarted(request_id); 577 host->OnNetworkRequestStarted(request_id);
578 }
582 } 579 }
583 580
584 void ProcessManager::OnNetworkRequestDone( 581 void ProcessManager::OnNetworkRequestDone(
585 content::RenderFrameHost* render_frame_host, 582 content::RenderFrameHost* render_frame_host,
586 uint64_t request_id) { 583 uint64_t request_id) {
587 auto result = pending_network_requests_.find(request_id); 584 ExtensionHost* host = GetBackgroundHostForExtension(
588 if (result == pending_network_requests_.end()) 585 GetExtensionID(render_frame_host));
589 return; 586 if (host && IsFrameInExtensionHost(host, render_frame_host)) {
590 587 host->OnNetworkRequestDone(request_id);
591 // The cached |host| can be invalid, if it was deleted between the time it 588 if (pending_network_requests_.erase(request_id))
592 // was inserted in the map and the look up. It is checked to ensure it is in 589 DecrementLazyKeepaliveCount(host->extension());
593 // the list of existing background_hosts_. 590 }
594 ExtensionHost* host = result->second;
595 pending_network_requests_.erase(result);
596
597 if (background_hosts_.find(host) == background_hosts_.end())
598 return;
599
600 DCHECK(IsFrameInExtensionHost(host, render_frame_host));
601
602 host->OnNetworkRequestDone(request_id);
603 DecrementLazyKeepaliveCount(host->extension());
604 } 591 }
605 592
606 void ProcessManager::CancelSuspend(const Extension* extension) { 593 void ProcessManager::CancelSuspend(const Extension* extension) {
607 bool& is_closing = background_page_data_[extension->id()].is_closing; 594 bool& is_closing = background_page_data_[extension->id()].is_closing;
608 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); 595 ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
609 if (host && is_closing) { 596 if (host && is_closing) {
610 is_closing = false; 597 is_closing = false;
611 host->render_process_host()->Send( 598 host->render_process_host()->Send(
612 new ExtensionMsg_CancelSuspend(extension->id())); 599 new ExtensionMsg_CancelSuspend(extension->id()));
613 // This increment / decrement is to simulate an instantaneous event. This 600 // This increment / decrement is to simulate an instantaneous event. This
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 975 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
989 BrowserContext* original_context = 976 BrowserContext* original_context =
990 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); 977 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context());
991 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); 978 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url);
992 } 979 }
993 980
994 return ProcessManager::GetSiteInstanceForURL(url); 981 return ProcessManager::GetSiteInstanceForURL(url);
995 } 982 }
996 983
997 } // namespace extensions 984 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/process_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698