OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_TAB_RESTORE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 SessionID::id_type id, | 168 SessionID::id_type id, |
169 bool replace_existing_tab); | 169 bool replace_existing_tab); |
170 | 170 |
171 // Loads the tabs and previous session. This does nothing if the tabs | 171 // Loads the tabs and previous session. This does nothing if the tabs |
172 // from the previous session have already been loaded. | 172 // from the previous session have already been loaded. |
173 void LoadTabsFromLastSession(); | 173 void LoadTabsFromLastSession(); |
174 | 174 |
175 // Max number of entries we'll keep around. | 175 // Max number of entries we'll keep around. |
176 static const size_t kMaxEntries; | 176 static const size_t kMaxEntries; |
177 | 177 |
178 // Creates and add entries to |entries| for each of the windows in |windows|. | |
179 void CreateEntriesFromWindows(std::vector<SessionWindow*>* windows, | |
180 std::vector<Entry*>* entries); | |
181 | |
182 protected: | 178 protected: |
183 virtual void Save(); | 179 virtual void Save(); |
184 | 180 |
185 virtual ~TabRestoreService(); | 181 virtual ~TabRestoreService(); |
186 | 182 |
187 private: | 183 private: |
188 // Used to indicate what has loaded. | 184 // Used to indicate what has loaded. |
189 enum LoadState { | 185 enum LoadState { |
190 // Indicates we haven't loaded anything. | 186 // Indicates we haven't loaded anything. |
191 NOT_LOADED = 1 << 0, | 187 NOT_LOADED = 1 << 0, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // Finds tab entries with the old browser_id and sets it to the new one. | 284 // Finds tab entries with the old browser_id and sets it to the new one. |
289 void UpdateTabBrowserIDs(SessionID::id_type old_id, | 285 void UpdateTabBrowserIDs(SessionID::id_type old_id, |
290 SessionID::id_type new_id); | 286 SessionID::id_type new_id); |
291 | 287 |
292 // Callback from SessionService when we've received the windows from the | 288 // Callback from SessionService when we've received the windows from the |
293 // previous session. This creates and add entries to |staging_entries_| | 289 // previous session. This creates and add entries to |staging_entries_| |
294 // and invokes LoadStateChanged. | 290 // and invokes LoadStateChanged. |
295 void OnGotPreviousSession(Handle handle, | 291 void OnGotPreviousSession(Handle handle, |
296 std::vector<SessionWindow*>* windows); | 292 std::vector<SessionWindow*>* windows); |
297 | 293 |
| 294 // Creates and add entries to |entries| for each of the windows in |windows|. |
| 295 void CreateEntriesFromWindows( |
| 296 std::vector<SessionWindow*>* windows, |
| 297 std::vector<Entry*>* entries); |
| 298 |
298 // Converts a SessionWindow into a Window, returning true on success. We use 0 | 299 // Converts a SessionWindow into a Window, returning true on success. We use 0 |
299 // as the timestamp here since we do not know when the window/tab was closed. | 300 // as the timestamp here since we do not know when the window/tab was closed. |
300 bool ConvertSessionWindowToWindow( | 301 bool ConvertSessionWindowToWindow( |
301 SessionWindow* session_window, | 302 SessionWindow* session_window, |
302 Window* window); | 303 Window* window); |
303 | 304 |
304 // Invoked when previous tabs or session is loaded. If both have finished | 305 // Invoked when previous tabs or session is loaded. If both have finished |
305 // loading the entries in staging_entries_ are added to entries_ and | 306 // loading the entries in staging_entries_ are added to entries_ and |
306 // observers are notified. | 307 // observers are notified. |
307 void LoadStateChanged(); | 308 void LoadStateChanged(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // entries_. | 345 // entries_. |
345 std::vector<Entry*> staging_entries_; | 346 std::vector<Entry*> staging_entries_; |
346 | 347 |
347 TimeFactory* time_factory_; | 348 TimeFactory* time_factory_; |
348 | 349 |
349 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); | 350 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); |
350 }; | 351 }; |
351 | 352 |
352 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 353 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
353 | 354 |
OLD | NEW |