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

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

Issue 2028873002: Fix event page process cleanup when running in --isolate-extensions mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. 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/logging.h" 10 #include "base/logging.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 extension_id, 562 extension_id,
563 sequence_id), 563 sequence_id),
564 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec)); 564 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec));
565 } 565 }
566 566
567 void ProcessManager::OnNetworkRequestStarted( 567 void ProcessManager::OnNetworkRequestStarted(
568 content::RenderFrameHost* render_frame_host, 568 content::RenderFrameHost* render_frame_host,
569 uint64_t request_id) { 569 uint64_t request_id) {
570 ExtensionHost* host = GetBackgroundHostForExtension( 570 ExtensionHost* host = GetBackgroundHostForExtension(
571 GetExtensionID(render_frame_host)); 571 GetExtensionID(render_frame_host));
572 auto result = pending_network_requests_.insert(request_id); 572 if (!host || !IsFrameInExtensionHost(host, render_frame_host))
573 return;
574
575 auto result =
576 pending_network_requests_.insert(std::make_pair(request_id, host));
573 DCHECK(result.second) << "Duplicate network request IDs."; 577 DCHECK(result.second) << "Duplicate network request IDs.";
574 if (host && IsFrameInExtensionHost(host, render_frame_host)) { 578
575 IncrementLazyKeepaliveCount(host->extension()); 579 IncrementLazyKeepaliveCount(host->extension());
576 host->OnNetworkRequestStarted(request_id); 580 host->OnNetworkRequestStarted(request_id);
577 }
578 } 581 }
579 582
580 void ProcessManager::OnNetworkRequestDone( 583 void ProcessManager::OnNetworkRequestDone(
581 content::RenderFrameHost* render_frame_host, 584 content::RenderFrameHost* render_frame_host,
582 uint64_t request_id) { 585 uint64_t request_id) {
583 ExtensionHost* host = GetBackgroundHostForExtension( 586 auto result = pending_network_requests_.find(request_id);
584 GetExtensionID(render_frame_host)); 587 if (result == pending_network_requests_.end())
585 if (host && IsFrameInExtensionHost(host, render_frame_host)) { 588 return;
586 host->OnNetworkRequestDone(request_id); 589
587 if (pending_network_requests_.erase(request_id)) 590 // The cached |host| can be invalid, if it was deleted between the time it
588 DecrementLazyKeepaliveCount(host->extension()); 591 // was inserted in the map and the look up. It is checked to ensure it is in
589 } 592 // the list of existing background_hosts_.
593 ExtensionHost* host = result->second;
594 pending_network_requests_.erase(result);
595
596 if (background_hosts_.find(host) == background_hosts_.end())
597 return;
598
599 DCHECK(IsFrameInExtensionHost(host, render_frame_host));
600
601 host->OnNetworkRequestDone(request_id);
602 DecrementLazyKeepaliveCount(host->extension());
590 } 603 }
591 604
592 void ProcessManager::CancelSuspend(const Extension* extension) { 605 void ProcessManager::CancelSuspend(const Extension* extension) {
593 bool& is_closing = background_page_data_[extension->id()].is_closing; 606 bool& is_closing = background_page_data_[extension->id()].is_closing;
594 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); 607 ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
595 if (host && is_closing) { 608 if (host && is_closing) {
596 is_closing = false; 609 is_closing = false;
597 host->render_process_host()->Send( 610 host->render_process_host()->Send(
598 new ExtensionMsg_CancelSuspend(extension->id())); 611 new ExtensionMsg_CancelSuspend(extension->id()));
599 // This increment / decrement is to simulate an instantaneous event. This 612 // This increment / decrement is to simulate an instantaneous event. This
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 990 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
978 BrowserContext* original_context = 991 BrowserContext* original_context =
979 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); 992 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context());
980 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); 993 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url);
981 } 994 }
982 995
983 return ProcessManager::GetSiteInstanceForURL(url); 996 return ProcessManager::GetSiteInstanceForURL(url);
984 } 997 }
985 998
986 } // namespace extensions 999 } // 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