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 // | |
32 // TODO(shaseley): *switch to the new done signal (network and cpu quiescence) | 34 // TODO(shaseley): *switch to the new done signal (network and cpu quiescence) |
33 // when available. | 35 // 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 { | 36 enum TabLoadingState { |
Mark P
2017/06/29 18:25:51
This needs the standard warning about changing val
shaseley
2017/06/29 19:45:16
Done.
| |
38 TAB_IS_NOT_LOADING = 0, | 37 TAB_IS_NOT_LOADING = 0, |
39 TAB_IS_LOADING = 1, | 38 TAB_IS_LOADING = 1, |
40 TAB_IS_LOADED = 2, | 39 TAB_IS_LOADED = 2, |
41 TAB_LOADING_STATE_MAX, | 40 TAB_LOADING_STATE_MAX, |
42 }; | 41 }; |
43 | 42 |
44 // Internal class used by TabManager to record the needed data for | 43 // Internal class used by TabManager to record the needed data for |
45 // WebContentses. | 44 // WebContentses. |
46 class TabManager::WebContentsData | 45 class TabManager::WebContentsData |
47 : public content::WebContentsObserver, | 46 : public content::WebContentsObserver, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 | 121 |
123 // Returns the TabLoadingState of the tab. | 122 // Returns the TabLoadingState of the tab. |
124 TabLoadingState tab_loading_state() const { | 123 TabLoadingState tab_loading_state() const { |
125 return tab_data_.tab_loading_state; | 124 return tab_data_.tab_loading_state; |
126 } | 125 } |
127 | 126 |
128 private: | 127 private: |
129 // Needed to access tab_data_. | 128 // Needed to access tab_data_. |
130 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); | 129 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, CopyState); |
131 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, TabLoadingState); | 130 FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, TabLoadingState); |
131 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, HistogramsSessionRestoreSwitchToTab); | |
132 | 132 |
133 struct Data { | 133 struct Data { |
134 Data(); | 134 Data(); |
135 bool operator==(const Data& right) const; | 135 bool operator==(const Data& right) const; |
136 bool operator!=(const Data& right) const; | 136 bool operator!=(const Data& right) const; |
137 | 137 |
138 // Is the tab currently discarded? | 138 // Is the tab currently discarded? |
139 bool is_discarded; | 139 bool is_discarded; |
140 // Number of times the tab has been discarded. | 140 // Number of times the tab has been discarded. |
141 int discard_count; | 141 int discard_count; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 179 |
180 // True if the tab has been purged. | 180 // True if the tab has been purged. |
181 bool is_purged_; | 181 bool is_purged_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(WebContentsData); | 183 DISALLOW_COPY_AND_ASSIGN(WebContentsData); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace resource_coordinator | 186 } // namespace resource_coordinator |
187 | 187 |
188 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ | 188 #endif // CHROME_BROWSER_RESOURCE_COORDINATOR_TAB_MANAGER_WEB_CONTENTS_DATA_H_ |
OLD | NEW |