| 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/sessions/tab_loader.h" | 5 #include "chrome/browser/sessions/tab_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/memory_pressure_monitor.h" | 10 #include "base/memory/memory_pressure_monitor.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 176 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 177 if (browser && | 177 if (browser && |
| 178 browser->tab_strip_model()->GetActiveWebContents() != contents) { | 178 browser->tab_strip_model()->GetActiveWebContents() != contents) { |
| 179 // By default tabs are marked as visible. As only the active tab is | 179 // By default tabs are marked as visible. As only the active tab is |
| 180 // visible we need to explicitly tell non-active tabs they are hidden. | 180 // visible we need to explicitly tell non-active tabs they are hidden. |
| 181 // Without this call non-active tabs are not marked as backgrounded. | 181 // Without this call non-active tabs are not marked as backgrounded. |
| 182 // | 182 // |
| 183 // NOTE: We need to do this here rather than when the tab is added to | 183 // NOTE: We need to do this here rather than when the tab is added to |
| 184 // the Browser as at that time not everything has been created, so that | 184 // the Browser as at that time not everything has been created, so that |
| 185 // the call would do nothing. | 185 // the call would do nothing. |
| 186 contents->WasHidden(); | 186 // |
| 187 // TODO(tapted): See whether |initially_hidden| can instead be used when |
| 188 // creating the WebContents. |
| 189 contents->MarkBackgrounded(); |
| 187 } | 190 } |
| 188 } | 191 } |
| 189 } | 192 } |
| 190 | 193 |
| 191 if (!tabs_to_load_.empty()) | 194 if (!tabs_to_load_.empty()) |
| 192 StartTimer(); | 195 StartTimer(); |
| 193 } | 196 } |
| 194 | 197 |
| 195 void TabLoader::StartFirstTimer() { | 198 void TabLoader::StartFirstTimer() { |
| 196 force_load_timer_.Stop(); | 199 force_load_timer_.Stop(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // memory pressure. | 270 // memory pressure. |
| 268 stats_collector_->DeferTab(tab); | 271 stats_collector_->DeferTab(tab); |
| 269 } | 272 } |
| 270 // By calling |LoadNextTab| explicitly, we make sure that the | 273 // By calling |LoadNextTab| explicitly, we make sure that the |
| 271 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 274 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
| 272 LoadNextTab(); | 275 LoadNextTab(); |
| 273 } | 276 } |
| 274 | 277 |
| 275 // static | 278 // static |
| 276 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 279 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
| OLD | NEW |