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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 GetWebContentsData(new_contents)->SetDiscardState(false); | 822 GetWebContentsData(new_contents)->SetDiscardState(false); |
| 823 // When ActiveTabChanged, |new_contents| purged state changes to be false. | 823 // When ActiveTabChanged, |new_contents| purged state changes to be false. |
| 824 GetWebContentsData(new_contents)->set_is_purged(false); | 824 GetWebContentsData(new_contents)->set_is_purged(false); |
| 825 // If |old_contents| is set, that tab has switched from being active to | 825 // If |old_contents| is set, that tab has switched from being active to |
| 826 // inactive, so record the time of that transition. | 826 // inactive, so record the time of that transition. |
| 827 if (old_contents) { | 827 if (old_contents) { |
| 828 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); | 828 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); |
| 829 // Re-setting time-to-purge every time a tab becomes inactive. | 829 // Re-setting time-to-purge every time a tab becomes inactive. |
| 830 GetWebContentsData(old_contents) | 830 GetWebContentsData(old_contents) |
| 831 ->set_time_to_purge(GetTimeToPurge(min_time_to_purge_)); | 831 ->set_time_to_purge(GetTimeToPurge(min_time_to_purge_)); |
| 832 // If |old_contents| isn't set, we didn't switch from anything, so don't | |
| 833 // record it. | |
| 834 RecordSwitchToTab(new_contents); | |
| 832 } | 835 } |
| 833 } | 836 } |
| 834 | 837 |
| 835 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, | 838 void TabManager::TabInsertedAt(TabStripModel* tab_strip_model, |
| 836 content::WebContents* contents, | 839 content::WebContents* contents, |
| 837 int index, | 840 int index, |
| 838 bool foreground) { | 841 bool foreground) { |
| 839 // Only interested in background tabs, as foreground tabs get taken care of by | 842 // Only interested in background tabs, as foreground tabs get taken care of by |
| 840 // ActiveTabChanged. | 843 // ActiveTabChanged. |
| 841 if (foreground) | 844 if (foreground) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 936 browser_info.window_is_active = browser->window()->IsActive(); | 939 browser_info.window_is_active = browser->window()->IsActive(); |
| 937 browser_info.window_is_minimized = browser->window()->IsMinimized(); | 940 browser_info.window_is_minimized = browser->window()->IsMinimized(); |
| 938 browser_info.window_bounds = browser->window()->GetBounds(); | 941 browser_info.window_bounds = browser->window()->GetBounds(); |
| 939 browser_info.browser_is_app = browser->is_app(); | 942 browser_info.browser_is_app = browser->is_app(); |
| 940 browser_info_list.push_back(browser_info); | 943 browser_info_list.push_back(browser_info); |
| 941 } | 944 } |
| 942 | 945 |
| 943 return browser_info_list; | 946 return browser_info_list; |
| 944 } | 947 } |
| 945 | 948 |
| 949 void TabManager::RecordSwitchToTab(content::WebContents* contents) const { | |
| 950 // TODO(shaseley): Change this test when the TabManager knows if we're in a | |
| 951 // background tab loading state. In that case, we'll want a separate metric | |
| 952 // for that case, and no metrics reported if we are simulaneously in session | |
| 953 // restore and background tab loading. | |
|
fmeawad
2017/06/27 21:22:02
nit: This TODO is implicit from the TODOs in the h
shaseley
2017/06/27 23:22:10
OK, that makes sense, I'll remove this comment.
| |
| 954 if (is_session_restore_loading_tabs_) { | |
| 955 UMA_HISTOGRAM_ENUMERATION("TabManager.SessionRestore.SwitchToTab", | |
| 956 GetWebContentsData(contents)->tab_loading_state(), | |
| 957 TAB_LOADING_STATE_MAX); | |
| 958 } | |
| 959 } | |
| 960 | |
| 946 } // namespace resource_coordinator | 961 } // namespace resource_coordinator |
| OLD | NEW |