| 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 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 content::WebContents* source_web_contents, | 84 content::WebContents* source_web_contents, |
| 85 const sessions::SessionTab& tab, | 85 const sessions::SessionTab& tab, |
| 86 WindowOpenDisposition disposition); | 86 WindowOpenDisposition disposition); |
| 87 | 87 |
| 88 // Returns true if we're in the process of restoring |profile|. | 88 // Returns true if we're in the process of restoring |profile|. |
| 89 static bool IsRestoring(const Profile* profile); | 89 static bool IsRestoring(const Profile* profile); |
| 90 | 90 |
| 91 // Returns true if synchronously restoring a session. | 91 // Returns true if synchronously restoring a session. |
| 92 static bool IsRestoringSynchronously(); | 92 static bool IsRestoringSynchronously(); |
| 93 | 93 |
| 94 // Register callbacks for session restore events. These callbacks are stored | 94 // Registers a callback that is notified every time session restore completes. |
| 95 // in |on_session_restored_callbacks_|. | 95 // Note that 'complete' means all the browsers and tabs have been created but |
| 96 // The callback is supplied an integer arg representing a tab count. The exact | 96 // have not necessarily finished loading. The integer supplied to the callback |
| 97 // meaning and timing depend upon the restore type: | 97 // indicates the number of tabs that were created. |
| 98 // - SessionRestore::SYNCHRONOUS: the parameter is the number of tabs that | |
| 99 // were created. Additionally the callback is invoked immediately after the | |
| 100 // tabs have been created. That is, the tabs are not necessarily loading. | |
| 101 // - For all other restore types the parameter is the number of tabs that were | |
| 102 // restored and is sent after all tabs have started loading. Additionally if a | |
| 103 // request to restore tabs comes in while a previous request to restore tabs | |
| 104 // has not yet completed (loading tabs is throttled), then the callback is | |
| 105 // only notified once both sets of tabs have started loading and with the | |
| 106 // total number of tabs for both restores. | |
| 107 static CallbackSubscription RegisterOnSessionRestoredCallback( | 98 static CallbackSubscription RegisterOnSessionRestoredCallback( |
| 108 const base::Callback<void(int)>& callback); | 99 const base::Callback<void(int)>& callback); |
| 109 | 100 |
| 110 // The max number of non-selected tabs SessionRestore loads when restoring | 101 // The max number of non-selected tabs SessionRestore loads when restoring |
| 111 // a session. A value of 0 indicates all tabs are loaded at once. | 102 // a session. A value of 0 indicates all tabs are loaded at once. |
| 112 static size_t num_tabs_to_load_; | 103 static size_t num_tabs_to_load_; |
| 113 | 104 |
| 114 private: | 105 private: |
| 115 SessionRestore(); | 106 SessionRestore(); |
| 116 | 107 |
| 117 // Accessor for |*on_session_restored_callbacks_|. Creates a new object the | 108 // Accessor for |*on_session_restored_callbacks_|. Creates a new object the |
| 118 // first time so that it always returns a valid object. | 109 // first time so that it always returns a valid object. |
| 119 static CallbackList* on_session_restored_callbacks() { | 110 static CallbackList* on_session_restored_callbacks() { |
| 120 if (!on_session_restored_callbacks_) | 111 if (!on_session_restored_callbacks_) |
| 121 on_session_restored_callbacks_ = new CallbackList(); | 112 on_session_restored_callbacks_ = new CallbackList(); |
| 122 return on_session_restored_callbacks_; | 113 return on_session_restored_callbacks_; |
| 123 } | 114 } |
| 124 | 115 |
| 125 // Contains all registered callbacks for session restore notifications. | 116 // Contains all registered callbacks for session restore notifications. |
| 126 static CallbackList* on_session_restored_callbacks_; | 117 static CallbackList* on_session_restored_callbacks_; |
| 127 | 118 |
| 128 DISALLOW_COPY_AND_ASSIGN(SessionRestore); | 119 DISALLOW_COPY_AND_ASSIGN(SessionRestore); |
| 129 }; | 120 }; |
| 130 | 121 |
| 131 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 122 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
| OLD | NEW |