Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/resource_coordinator/tab_manager.h" | 5 #include "chrome/browser/resource_coordinator/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 17 matching lines...) Expand all Loading... | |
| 28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
| 29 #include "base/time/tick_clock.h" | 29 #include "base/time/tick_clock.h" |
| 30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 32 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 32 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 33 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" | 33 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" |
| 34 #include "chrome/browser/memory/oom_memory_details.h" | 34 #include "chrome/browser/memory/oom_memory_details.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/resource_coordinator/tab_manager_observer.h" | 36 #include "chrome/browser/resource_coordinator/tab_manager_observer.h" |
| 37 #include "chrome/browser/resource_coordinator/tab_manager_web_contents_data.h" | 37 #include "chrome/browser/resource_coordinator/tab_manager_web_contents_data.h" |
| 38 #include "chrome/browser/sessions/tab_loader.h" | |
| 38 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 39 #include "chrome/browser/ui/browser_list.h" | 40 #include "chrome/browser/ui/browser_list.h" |
| 40 #include "chrome/browser/ui/browser_window.h" | 41 #include "chrome/browser/ui/browser_window.h" |
| 41 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 42 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 42 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 43 #include "chrome/browser/ui/tabs/tab_utils.h" | 44 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 44 #include "chrome/common/chrome_constants.h" | 45 #include "chrome/common/chrome_constants.h" |
| 45 #include "chrome/common/chrome_features.h" | 46 #include "chrome/common/chrome_features.h" |
| 46 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 | 130 |
| 130 TabManager::TabManager() | 131 TabManager::TabManager() |
| 131 : discard_count_(0), | 132 : discard_count_(0), |
| 132 recent_tab_discard_(false), | 133 recent_tab_discard_(false), |
| 133 discard_once_(false), | 134 discard_once_(false), |
| 134 #if !defined(OS_CHROMEOS) | 135 #if !defined(OS_CHROMEOS) |
| 135 minimum_protection_time_(base::TimeDelta::FromMinutes(10)), | 136 minimum_protection_time_(base::TimeDelta::FromMinutes(10)), |
| 136 #endif | 137 #endif |
| 137 browser_tab_strip_tracker_(this, nullptr, nullptr), | 138 browser_tab_strip_tracker_(this, nullptr, nullptr), |
| 138 test_tick_clock_(nullptr), | 139 test_tick_clock_(nullptr), |
| 140 in_session_restore_tab_loading_(false), | |
|
lpy
2017/06/23 22:35:57
is_in_session_restore_tab_loading_
ducbui
2017/06/23 23:30:14
Done.
| |
| 141 session_restore_observer_instance_(this), | |
| 139 weak_ptr_factory_(this) { | 142 weak_ptr_factory_(this) { |
| 140 #if defined(OS_CHROMEOS) | 143 #if defined(OS_CHROMEOS) |
| 141 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); | 144 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); |
| 142 #endif | 145 #endif |
| 143 browser_tab_strip_tracker_.Init(); | 146 browser_tab_strip_tracker_.Init(); |
| 144 } | 147 } |
| 145 | 148 |
| 146 TabManager::~TabManager() { | 149 TabManager::~TabManager() { |
| 147 Stop(); | 150 Stop(); |
| 148 } | 151 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 | 471 |
| 469 // Being more recently active is more important. | 472 // Being more recently active is more important. |
| 470 return first.last_active > second.last_active; | 473 return first.last_active > second.last_active; |
| 471 } | 474 } |
| 472 | 475 |
| 473 // static | 476 // static |
| 474 int64_t TabManager::IdFromWebContents(WebContents* web_contents) { | 477 int64_t TabManager::IdFromWebContents(WebContents* web_contents) { |
| 475 return reinterpret_cast<int64_t>(web_contents); | 478 return reinterpret_cast<int64_t>(web_contents); |
| 476 } | 479 } |
| 477 | 480 |
| 481 void TabManager::OnSessionRestoreTabLoadingStarted() { | |
| 482 DCHECK(!in_session_restore_tab_loading_); | |
| 483 in_session_restore_tab_loading_ = true; | |
| 484 } | |
| 485 | |
| 486 void TabManager::OnSessionRestoreTabLoadingEnded() { | |
| 487 DCHECK(in_session_restore_tab_loading_); | |
| 488 in_session_restore_tab_loading_ = false; | |
| 489 } | |
| 490 | |
| 478 /////////////////////////////////////////////////////////////////////////////// | 491 /////////////////////////////////////////////////////////////////////////////// |
| 479 // TabManager, private: | 492 // TabManager, private: |
| 480 | 493 |
| 481 void TabManager::OnDiscardedStateChange(content::WebContents* contents, | 494 void TabManager::OnDiscardedStateChange(content::WebContents* contents, |
| 482 bool is_discarded) { | 495 bool is_discarded) { |
| 483 for (TabManagerObserver& observer : observers_) | 496 for (TabManagerObserver& observer : observers_) |
| 484 observer.OnDiscardedStateChange(contents, is_discarded); | 497 observer.OnDiscardedStateChange(contents, is_discarded); |
| 485 } | 498 } |
| 486 | 499 |
| 487 void TabManager::OnAutoDiscardableStateChange(content::WebContents* contents, | 500 void TabManager::OnAutoDiscardableStateChange(content::WebContents* contents, |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 896 browser_info.window_is_active = browser->window()->IsActive(); | 909 browser_info.window_is_active = browser->window()->IsActive(); |
| 897 browser_info.window_is_minimized = browser->window()->IsMinimized(); | 910 browser_info.window_is_minimized = browser->window()->IsMinimized(); |
| 898 browser_info.window_bounds = browser->window()->GetBounds(); | 911 browser_info.window_bounds = browser->window()->GetBounds(); |
| 899 browser_info.browser_is_app = browser->is_app(); | 912 browser_info.browser_is_app = browser->is_app(); |
| 900 browser_info_list.push_back(browser_info); | 913 browser_info_list.push_back(browser_info); |
| 901 } | 914 } |
| 902 | 915 |
| 903 return browser_info_list; | 916 return browser_info_list; |
| 904 } | 917 } |
| 905 | 918 |
| 919 TabManager::SessionRestoreObserverInstance::SessionRestoreObserverInstance( | |
| 920 TabManager* tab_manager) | |
| 921 : tab_manager_(tab_manager) { | |
| 922 SessionRestoreObserver::AddObserver(this); | |
| 923 } | |
| 924 | |
| 925 TabManager::SessionRestoreObserverInstance::~SessionRestoreObserverInstance() { | |
| 926 SessionRestoreObserver::RemoveObserver(this); | |
| 927 } | |
| 928 | |
| 929 // SessionRestoreObserver implementation: | |
| 930 void TabManager::SessionRestoreObserverInstance::OnTabLoadingStarted() { | |
| 931 tab_manager_->OnSessionRestoreTabLoadingStarted(); | |
| 932 } | |
| 933 | |
| 934 void TabManager::SessionRestoreObserverInstance::OnTabLoadingEnded() { | |
| 935 tab_manager_->OnSessionRestoreTabLoadingEnded(); | |
| 936 } | |
| 937 | |
| 906 } // namespace resource_coordinator | 938 } // namespace resource_coordinator |
| OLD | NEW |