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 #ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 5 #ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| 6 #define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 6 #define CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/resource_coordinator/tab_manager.h" | 10 #include "chrome/browser/resource_coordinator/tab_manager.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 namespace resource_coordinator { | 23 namespace resource_coordinator { |
| 24 | 24 |
| 25 // Tabs (WebContentsData) start in the not loading state, and transition to the | 25 // Tabs (WebContentsData) start in the not loading state, and transition to the |
| 26 // loading state when a navigation begins in the main frame of the associated | 26 // loading state when a navigation begins in the main frame of the associated |
| 27 // WebContents. The state changes to loaded when we receive the DidStopLoading* | 27 // WebContents. The state changes to loaded when we receive the DidStopLoading* |
| 28 // signal. The state can change from loaded to loading if another navigation | 28 // signal. The state can change from loaded to loading if another navigation |
| 29 // occurs in the main frame, which happens if the user navigates to a new page | 29 // occurs in the main frame, which happens if the user navigates to a new page |
| 30 // and the WebContents is reused. | 30 // and the WebContents is reused. |
| 31 // | 31 // |
| 32 // These values are used in the TabManager.SessionRestore.SwitchToTab UMA. | |
| 33 // | |
| 34 // TODO(shaseley): Add a reference to the new metric when background tab loading | |
| 35 // is done. | |
| 36 // | |
| 32 // TODO(shaseley): *switch to the new done signal (network and cpu quiescence) | 37 // TODO(shaseley): *switch to the new done signal (network and cpu quiescence) |
| 33 // when available. | 38 // when available. |
| 34 // | |
| 35 // TODO(shaseley): This will become an UMA histogram once the TabManager is | |
| 36 // aware of session restore begin/end and background tab loading begin/end. | |
| 37 enum TabLoadingState { | 39 enum TabLoadingState { |
| 38 TAB_IS_NOT_LOADING = 0, | 40 TAB_IS_NOT_LOADING = 0, |
|
lpy
2017/06/27 22:30:36
I think that TAB_IS_NOT_LOADING is not accurate, a
shaseley
2017/06/27 23:22:10
I know what you mean, the names are a little confu
| |
| 39 TAB_IS_LOADING = 1, | 41 TAB_IS_LOADING = 1, |
| 40 TAB_IS_LOADED = 2, | 42 TAB_IS_LOADED = 2, |
| 41 TAB_LOADING_STATE_MAX, | 43 TAB_LOADING_STATE_MAX, |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 // Internal class used by TabManager to record the needed data for | 46 // Internal class used by TabManager to record the needed data for |
| 45 // WebContentses. | 47 // WebContentses. |
| 46 class TabManager::WebContentsData | 48 class TabManager::WebContentsData |
| 47 : public content::WebContentsObserver, | 49 : public content::WebContentsObserver, |
| 48 public content::WebContentsUserData<TabManager::WebContentsData> { | 50 public content::WebContentsUserData<TabManager::WebContentsData> { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 124 |
| 123 // Returns the TabLoadingState of the tab. | 125 // Returns the TabLoadingState of the tab. |
| 124 TabLoadingState tab_loading_state() const { | 126 TabLoadingState tab_loading_state() const { |
| 125 return tab_data_.tab_loading_state; | 127 return tab_data_.tab_loading_state; |
| 126 } | 128 } |
| 127 | 129 |
| 128 private: | 130 private: |
| 129 // Needed to access tab_data_. | 131 // Needed to access tab_data_. |
| 130 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); | 132 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); |
| 131 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, TabLoadingState); | 133 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, TabLoadingState); |
| 134 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, HistogramsSessionRestoreSwitchToTab); | |
| 132 | 135 |
| 133 struct Data { | 136 struct Data { |
| 134 Data(); | 137 Data(); |
| 135 bool operator==(const Data& right) const; | 138 bool operator==(const Data& right) const; |
| 136 bool operator!=(const Data& right) const; | 139 bool operator!=(const Data& right) const; |
| 137 | 140 |
| 138 // Is the tab currently discarded? | 141 // Is the tab currently discarded? |
| 139 bool is_discarded; | 142 bool is_discarded; |
| 140 // Number of times the tab has been discarded. | 143 // Number of times the tab has been discarded. |
| 141 int discard_count; | 144 int discard_count; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 | 182 |
| 180 // True if the tab has been purged. | 183 // True if the tab has been purged. |
| 181 bool is_purged_; | 184 bool is_purged_; |
| 182 | 185 |
| 183 DISALLOW_COPY_AND_ASSIGN(WebContentsData); | 186 DISALLOW_COPY_AND_ASSIGN(WebContentsData); |
| 184 }; | 187 }; |
| 185 | 188 |
| 186 } // namespace resource_coordinator | 189 } // namespace resource_coordinator |
| 187 | 190 |
| 188 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 191 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
| OLD | NEW |