ducbui | 1b859735 | 2017-06-27 17:06:38 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_OBSERVER_H_ |
| 6 | #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_OBSERVER_H_ |
| 7 | |
Duc Bui | 16a6e80 | 2017-08-02 16:22:53 | [diff] [blame] | 8 | namespace content { |
| 9 | class WebContents; |
| 10 | } |
| 11 | |
Nancy Wang | c76e0a5 | 2021-09-13 19:47:32 | [diff] [blame^] | 12 | class Profile; |
| 13 | |
Duc Bui | bf1f569 | 2017-07-19 14:42:07 | [diff] [blame] | 14 | // Observer of events during session restore. This observer does not cover |
| 15 | // SessionRestoreImpl::RestoreForeignTab() which restores a single foreign tab. |
ducbui | 1b859735 | 2017-06-27 17:06:38 | [diff] [blame] | 16 | class SessionRestoreObserver { |
| 17 | public: |
Duc Bui | bf1f569 | 2017-07-19 14:42:07 | [diff] [blame] | 18 | // OnSessionRestoreStartedLoadingTabs() is called from session restore |
| 19 | // prior to creating the first tab from session restore. Session restore may |
| 20 | // do processing before this, and if no tabs are created (there was no |
| 21 | // previous session, or perhaps the data was corrupt) this is not called. |
| 22 | // OnSessionRestoreStartedLoadingTabs() is *not* called if another session |
| 23 | // restore is triggered while waiting for a load to complete. |
ducbui | 1b859735 | 2017-06-27 17:06:38 | [diff] [blame] | 24 | virtual void OnSessionRestoreStartedLoadingTabs() {} |
| 25 | |
Duc Bui | bf1f569 | 2017-07-19 14:42:07 | [diff] [blame] | 26 | // OnSessionRestoreFinishedLoadingTabs() is called once all the tabs created |
| 27 | // by session restore have completed loading (or loading is canceled because |
| 28 | // of memory pressure). This is called on the last session restore when |
| 29 | // multiple concurrent session restores (on all profiles) occur. |
ducbui | 1b859735 | 2017-06-27 17:06:38 | [diff] [blame] | 30 | virtual void OnSessionRestoreFinishedLoadingTabs() {} |
Duc Bui | 16a6e80 | 2017-08-02 16:22:53 | [diff] [blame] | 31 | |
| 32 | // OnWillRestoreTab() is called right after a tab is created by session |
| 33 | // restore. |
| 34 | virtual void OnWillRestoreTab(content::WebContents* web_contents) {} |
Nancy Wang | c76e0a5 | 2021-09-13 19:47:32 | [diff] [blame^] | 35 | |
| 36 | // OnGotSession() is called right after windows are read from the last session |
| 37 | // restore file. If windows are read by AppSessionService for app windows, |
| 38 | // `for_app` is true. Otherwise, `for_app` is false. This function is used |
| 39 | // for debug only. |
| 40 | virtual void OnGotSession(Profile* profile, bool for_app, int window_count) {} |
ducbui | 1b859735 | 2017-06-27 17:06:38 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_OBSERVER_H_ |