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

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

Issue 2387603003: Resume a backgrounded renderer that was purged and suspended (Closed)
Patch Set: Fixed Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_web_contents_data.h" 5 #include "chrome/browser/memory/tab_manager_web_contents_data.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/tick_clock.h" 8 #include "base/time/tick_clock.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/engagement/site_engagement_service.h" 10 #include "chrome/browser/engagement/site_engagement_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 14
15 using base::TimeTicks; 15 using base::TimeTicks;
16 using content::WebContents; 16 using content::WebContents;
17 17
18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(memory::TabManager::WebContentsData); 18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(memory::TabManager::WebContentsData);
19 19
20 namespace memory { 20 namespace memory {
21 21
22 TabManager::WebContentsData::WebContentsData(content::WebContents* web_contents) 22 TabManager::WebContentsData::WebContentsData(content::WebContents* web_contents)
23 : WebContentsObserver(web_contents), test_tick_clock_(nullptr) {} 23 : WebContentsObserver(web_contents),
24 test_tick_clock_(nullptr),
25 last_purge_and_suspend_modified_time_(
26 base::TimeTicks::FromInternalValue(0)),
27 purge_and_suspend_state_(BACKGROUNDED) {}
haraken 2016/10/19 08:57:54 Is it okay to unconditionally set the initial valu
tasak 2016/10/19 10:17:13 In PurgeAndSuspendBackgroundedTabs, firstly we che
24 28
25 TabManager::WebContentsData::~WebContentsData() {} 29 TabManager::WebContentsData::~WebContentsData() {}
26 30
27 void TabManager::WebContentsData::DidStartLoading() { 31 void TabManager::WebContentsData::DidStartLoading() {
28 // Marks the tab as no longer discarded if it has been reloaded from another 32 // Marks the tab as no longer discarded if it has been reloaded from another
29 // source (ie: context menu). 33 // source (ie: context menu).
30 SetDiscardState(false); 34 SetDiscardState(false);
31 } 35 }
32 36
33 void TabManager::WebContentsData::WebContentsDestroyed() { 37 void TabManager::WebContentsData::WebContentsDestroyed() {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 195
192 tab_data_.is_auto_discardable = state; 196 tab_data_.is_auto_discardable = state;
193 g_browser_process->GetTabManager()->OnAutoDiscardableStateChange( 197 g_browser_process->GetTabManager()->OnAutoDiscardableStateChange(
194 web_contents(), state); 198 web_contents(), state);
195 } 199 }
196 200
197 bool TabManager::WebContentsData::IsAutoDiscardable() { 201 bool TabManager::WebContentsData::IsAutoDiscardable() {
198 return tab_data_.is_auto_discardable; 202 return tab_data_.is_auto_discardable;
199 } 203 }
200 204
205 void TabManager::WebContentsData::SetPurgeAndSuspendState(
206 PurgeAndSuspendState state) {
207 last_purge_and_suspend_modified_time_ = TimeTicks::Now();
208 purge_and_suspend_state_ = state;
209 }
210
211 base::TimeTicks TabManager::WebContentsData::LastPurgeAndSuspendModifiedTime()
212 const {
213 return last_purge_and_suspend_modified_time_;
214 }
215
216 TabManager::PurgeAndSuspendState
217 TabManager::WebContentsData::GetPurgeAndSuspendState() const {
218 return purge_and_suspend_state_;
219 }
220
201 } // namespace memory 221 } // namespace memory
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698