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

Side by Side Diff: chrome/browser/memory/tab_manager.cc

Issue 2574663002: TabManager checks if ServiceWorker exists on the suspending process (Closed)
Patch Set: Created 4 years 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 | « no previous file | content/browser/service_worker/embedded_worker_registry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/memory/tab_manager.h" 5 #include "chrome/browser/memory/tab_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/common/chrome_constants.h" 44 #include "chrome/common/chrome_constants.h"
45 #include "chrome/common/chrome_features.h" 45 #include "chrome/common/chrome_features.h"
46 #include "chrome/common/chrome_switches.h" 46 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/url_constants.h" 47 #include "chrome/common/url_constants.h"
48 #include "components/metrics/system_memory_stats_recorder.h" 48 #include "components/metrics/system_memory_stats_recorder.h"
49 #include "components/variations/variations_associated_data.h" 49 #include "components/variations/variations_associated_data.h"
50 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/memory_pressure_controller.h" 51 #include "content/public/browser/memory_pressure_controller.h"
52 #include "content/public/browser/navigation_controller.h" 52 #include "content/public/browser/navigation_controller.h"
53 #include "content/public/browser/render_process_host.h" 53 #include "content/public/browser/render_process_host.h"
54 #include "content/public/browser/service_worker_context.h"
55 #include "content/public/browser/storage_partition.h"
54 #include "content/public/browser/web_contents.h" 56 #include "content/public/browser/web_contents.h"
55 #include "content/public/common/page_importance_signals.h" 57 #include "content/public/common/page_importance_signals.h"
56 58
57 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
58 #include "ash/common/multi_profile_uma.h" 60 #include "ash/common/multi_profile_uma.h"
59 #include "ash/common/session/session_state_delegate.h" 61 #include "ash/common/session/session_state_delegate.h"
60 #include "ash/common/wm_shell.h" 62 #include "ash/common/wm_shell.h"
61 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" 63 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h"
62 #endif 64 #endif
63 65
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // A renderer can be suspended if it's not playing media. 454 // A renderer can be suspended if it's not playing media.
453 auto tab_stats = GetUnsortedTabStats(); 455 auto tab_stats = GetUnsortedTabStats();
454 for (auto& tab : tab_stats) { 456 for (auto& tab : tab_stats) {
455 if (tab.child_process_host_id != render_process_id) 457 if (tab.child_process_host_id != render_process_id)
456 continue; 458 continue;
457 WebContents* web_contents = GetWebContentsById(tab.tab_contents_id); 459 WebContents* web_contents = GetWebContentsById(tab.tab_contents_id);
458 if (!web_contents) 460 if (!web_contents)
459 return false; 461 return false;
460 if (IsMediaTab(web_contents)) 462 if (IsMediaTab(web_contents))
461 return false; 463 return false;
464
465 content::ServiceWorkerContext* sw_context =
466 content::BrowserContext::GetDefaultStoragePartition(
467 web_contents->GetBrowserContext())->GetServiceWorkerContext();
468 DCHECK(!sw_context);
469 // -- THIS MUST BE CALLED ON THE IO THREAD --
470 if (sw_context->IsServiceWorkerExistsOnProcess(render_process_id))
shimazu 2016/12/13 04:16:36 This is a problem. Do you have any good idea to ca
nhiroki 2016/12/13 04:33:59 Are we on the UI thread here? If so, we could use
nhiroki 2016/12/13 04:34:56 (without thread hopping)
bashi 2016/12/13 04:40:17 Thank you for the info. Yes, we may want to use wo
471 return false;
462 } 472 }
463 return true; 473 return true;
464 } 474 }
465 475
466 // static 476 // static
467 bool TabManager::CompareTabStats(const TabStats& first, 477 bool TabManager::CompareTabStats(const TabStats& first,
468 const TabStats& second) { 478 const TabStats& second) {
469 // Being currently selected is most important to protect. 479 // Being currently selected is most important to protect.
470 if (first.is_selected != second.is_selected) 480 if (first.is_selected != second.is_selected)
471 return first.is_selected; 481 return first.is_selected;
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // platform. 1038 // platform.
1029 std::string allow_multiple_discards = variations::GetVariationParamValue( 1039 std::string allow_multiple_discards = variations::GetVariationParamValue(
1030 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); 1040 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
1031 return (allow_multiple_discards != "true"); 1041 return (allow_multiple_discards != "true");
1032 #else 1042 #else
1033 return false; 1043 return false;
1034 #endif 1044 #endif
1035 } 1045 }
1036 1046
1037 } // namespace memory 1047 } // namespace memory
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698