Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h" | 7 #include "base/metrics/histogram.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" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 } | 165 } |
| 166 | 166 |
| 167 TabManager::WebContentsData::Data::Data() | 167 TabManager::WebContentsData::Data::Data() |
| 168 : is_discarded_(false), | 168 : is_discarded_(false), |
| 169 discard_count_(0), | 169 discard_count_(0), |
| 170 is_recently_audible_(false), | 170 is_recently_audible_(false), |
| 171 last_audio_change_time_(TimeTicks::UnixEpoch()), | 171 last_audio_change_time_(TimeTicks::UnixEpoch()), |
| 172 last_discard_time_(TimeTicks::UnixEpoch()), | 172 last_discard_time_(TimeTicks::UnixEpoch()), |
| 173 last_reload_time_(TimeTicks::UnixEpoch()), | 173 last_reload_time_(TimeTicks::UnixEpoch()), |
| 174 last_inactive_time_(TimeTicks::UnixEpoch()), | 174 last_inactive_time_(TimeTicks::UnixEpoch()), |
| 175 engagement_score_(-1.0) {} | 175 engagement_score_(-1.0), |
| 176 is_discardable(true) {} | |
| 176 | 177 |
| 177 bool TabManager::WebContentsData::Data::operator==(const Data& right) const { | 178 bool TabManager::WebContentsData::Data::operator==(const Data& right) const { |
| 178 return is_discarded_ == right.is_discarded_ && | 179 return is_discarded_ == right.is_discarded_ && |
| 179 is_recently_audible_ == right.is_recently_audible_ && | 180 is_recently_audible_ == right.is_recently_audible_ && |
| 180 last_audio_change_time_ == right.last_audio_change_time_ && | 181 last_audio_change_time_ == right.last_audio_change_time_ && |
| 181 last_discard_time_ == right.last_discard_time_ && | 182 last_discard_time_ == right.last_discard_time_ && |
| 182 last_reload_time_ == right.last_reload_time_ && | 183 last_reload_time_ == right.last_reload_time_ && |
| 183 last_inactive_time_ == right.last_inactive_time_ && | 184 last_inactive_time_ == right.last_inactive_time_ && |
| 184 engagement_score_ == right.engagement_score_; | 185 engagement_score_ == right.engagement_score_; |
| 185 } | 186 } |
| 186 | 187 |
| 187 bool TabManager::WebContentsData::Data::operator!=(const Data& right) const { | 188 bool TabManager::WebContentsData::Data::operator!=(const Data& right) const { |
| 188 return !(*this == right); | 189 return !(*this == right); |
| 189 } | 190 } |
| 190 | 191 |
| 192 void TabManager::WebContentsData::SetDiscardableState(bool state) { | |
| 193 if (tab_data_.is_discardable == state) | |
| 194 return; | |
| 195 | |
| 196 tab_data_.is_discardable = state; | |
| 197 | |
| 198 // TabManager could not exist in tests. | |
|
Georges Khalil
2016/07/21 20:51:51
I don't think that's true anymore. We don't need t
Anderson Silva
2016/07/21 21:14:49
Done.
| |
| 199 if (g_browser_process->GetTabManager()) { | |
| 200 g_browser_process->GetTabManager()->OnDiscardableStateChange(web_contents(), | |
| 201 state); | |
| 202 } | |
| 203 } | |
| 204 | |
| 205 bool TabManager::WebContentsData::IsDiscardable() { | |
| 206 return tab_data_.is_discardable; | |
| 207 } | |
| 208 | |
| 191 } // namespace memory | 209 } // namespace memory |
| OLD | NEW |