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

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

Issue 1366393002: Prevent imbalanced keepalive counts in ProcessManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 2 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 extension_id, 546 extension_id,
547 sequence_id), 547 sequence_id),
548 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec)); 548 base::TimeDelta::FromMilliseconds(g_event_page_suspending_time_msec));
549 } 549 }
550 550
551 void ProcessManager::OnNetworkRequestStarted( 551 void ProcessManager::OnNetworkRequestStarted(
552 content::RenderFrameHost* render_frame_host, 552 content::RenderFrameHost* render_frame_host,
553 uint64 request_id) { 553 uint64 request_id) {
554 ExtensionHost* host = GetBackgroundHostForExtension( 554 ExtensionHost* host = GetBackgroundHostForExtension(
555 GetExtensionID(render_frame_host)); 555 GetExtensionID(render_frame_host));
556 auto result = pending_network_requests_.insert(request_id);
557 DCHECK(result.second) << "Duplicate network request IDs.";
556 if (host && IsFrameInExtensionHost(host, render_frame_host)) { 558 if (host && IsFrameInExtensionHost(host, render_frame_host)) {
557 IncrementLazyKeepaliveCount(host->extension()); 559 IncrementLazyKeepaliveCount(host->extension());
558 host->OnNetworkRequestStarted(request_id); 560 host->OnNetworkRequestStarted(request_id);
559 } 561 }
560 } 562 }
561 563
562 void ProcessManager::OnNetworkRequestDone( 564 void ProcessManager::OnNetworkRequestDone(
563 content::RenderFrameHost* render_frame_host, 565 content::RenderFrameHost* render_frame_host,
564 uint64 request_id) { 566 uint64 request_id) {
565 ExtensionHost* host = GetBackgroundHostForExtension( 567 ExtensionHost* host = GetBackgroundHostForExtension(
566 GetExtensionID(render_frame_host)); 568 GetExtensionID(render_frame_host));
567 if (host && IsFrameInExtensionHost(host, render_frame_host)) { 569 if (host && IsFrameInExtensionHost(host, render_frame_host)) {
568 host->OnNetworkRequestDone(request_id); 570 host->OnNetworkRequestDone(request_id);
569 DecrementLazyKeepaliveCount(host->extension()); 571 if (pending_network_requests_.erase(request_id))
572 DecrementLazyKeepaliveCount(host->extension());
570 } 573 }
571 } 574 }
572 575
573 void ProcessManager::CancelSuspend(const Extension* extension) { 576 void ProcessManager::CancelSuspend(const Extension* extension) {
574 bool& is_closing = background_page_data_[extension->id()].is_closing; 577 bool& is_closing = background_page_data_[extension->id()].is_closing;
575 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); 578 ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
576 if (host && is_closing) { 579 if (host && is_closing) {
577 is_closing = false; 580 is_closing = false;
578 host->render_process_host()->Send( 581 host->render_process_host()->Send(
579 new ExtensionMsg_CancelSuspend(extension->id())); 582 new ExtensionMsg_CancelSuspend(extension->id()));
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 961 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
959 BrowserContext* original_context = 962 BrowserContext* original_context =
960 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); 963 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context());
961 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); 964 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url);
962 } 965 }
963 966
964 return ProcessManager::GetSiteInstanceForURL(url); 967 return ProcessManager::GetSiteInstanceForURL(url);
965 } 968 }
966 969
967 } // namespace extensions 970 } // 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