| 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Adds commands to commands that will recreate the state of the specified | 254 // Adds commands to commands that will recreate the state of the specified |
| 255 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each | 255 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each |
| 256 // direction from the current navigation index). | 256 // direction from the current navigation index). |
| 257 // A pair is added to tab_to_available_range indicating the range of | 257 // A pair is added to tab_to_available_range indicating the range of |
| 258 // indices that were written. | 258 // indices that were written. |
| 259 void BuildCommandsForTab( | 259 void BuildCommandsForTab( |
| 260 const SessionID& window_id, | 260 const SessionID& window_id, |
| 261 content::WebContents* tab, | 261 content::WebContents* tab, |
| 262 int index_in_window, | 262 int index_in_window, |
| 263 bool is_pinned, | 263 bool is_pinned, |
| 264 std::vector<SessionCommand*>* commands, | 264 ScopedVector<SessionCommand>* commands, |
| 265 IdToRange* tab_to_available_range); | 265 IdToRange* tab_to_available_range); |
| 266 | 266 |
| 267 // Adds commands to create the specified browser, and invokes | 267 // Adds commands to create the specified browser, and invokes |
| 268 // BuildCommandsForTab for each of the tabs in the browser. This ignores | 268 // BuildCommandsForTab for each of the tabs in the browser. This ignores |
| 269 // any tabs not in the profile we were created with. | 269 // any tabs not in the profile we were created with. |
| 270 void BuildCommandsForBrowser( | 270 void BuildCommandsForBrowser( |
| 271 Browser* browser, | 271 Browser* browser, |
| 272 std::vector<SessionCommand*>* commands, | 272 ScopedVector<SessionCommand>* commands, |
| 273 IdToRange* tab_to_available_range, | 273 IdToRange* tab_to_available_range, |
| 274 std::set<SessionID::id_type>* windows_to_track); | 274 std::set<SessionID::id_type>* windows_to_track); |
| 275 | 275 |
| 276 // Iterates over all the known browsers invoking BuildCommandsForBrowser. | 276 // Iterates over all the known browsers invoking BuildCommandsForBrowser. |
| 277 // This only adds browsers that should be tracked (|ShouldRestoreWindowOfType| | 277 // This only adds browsers that should be tracked (|ShouldRestoreWindowOfType| |
| 278 // returns true). All browsers that are tracked are added to windows_to_track | 278 // returns true). All browsers that are tracked are added to windows_to_track |
| 279 // (as long as it is non-null). | 279 // (as long as it is non-null). |
| 280 void BuildCommandsFromBrowsers( | 280 void BuildCommandsFromBrowsers( |
| 281 std::vector<SessionCommand*>* commands, | 281 ScopedVector<SessionCommand>* commands, |
| 282 IdToRange* tab_to_available_range, | 282 IdToRange* tab_to_available_range, |
| 283 std::set<SessionID::id_type>* windows_to_track); | 283 std::set<SessionID::id_type>* windows_to_track); |
| 284 | 284 |
| 285 // Schedules a reset of the existing commands. A reset means the contents | 285 // Schedules a reset of the existing commands. A reset means the contents |
| 286 // of the file are recreated from the state of the browser. | 286 // of the file are recreated from the state of the browser. |
| 287 void ScheduleResetCommands(); | 287 void ScheduleResetCommands(); |
| 288 | 288 |
| 289 // Schedules the specified command. This method takes ownership of the | 289 // Schedules the specified command. |
| 290 // command. | 290 void ScheduleCommand(scoped_ptr<SessionCommand> command) override; |
| 291 void ScheduleCommand(SessionCommand* command) override; | |
| 292 | 291 |
| 293 // Converts all pending tab/window closes to commands and schedules them. | 292 // Converts all pending tab/window closes to commands and schedules them. |
| 294 void CommitPendingCloses(); | 293 void CommitPendingCloses(); |
| 295 | 294 |
| 296 // Returns true if there is only one window open with a single tab that shares | 295 // Returns true if there is only one window open with a single tab that shares |
| 297 // our profile. | 296 // our profile. |
| 298 bool IsOnlyOneTabLeft() const; | 297 bool IsOnlyOneTabLeft() const; |
| 299 | 298 |
| 300 // Returns true if there are open trackable browser windows whose ids do | 299 // Returns true if there are open trackable browser windows whose ids do |
| 301 // match |window_id| with our profile. A trackable window is a window from | 300 // match |window_id| with our profile. A trackable window is a window from |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // For browser_tests, since we want to simulate the browser shutting down | 384 // For browser_tests, since we want to simulate the browser shutting down |
| 386 // without quitting. | 385 // without quitting. |
| 387 bool force_browser_not_alive_with_no_windows_; | 386 bool force_browser_not_alive_with_no_windows_; |
| 388 | 387 |
| 389 base::WeakPtrFactory<SessionService> weak_factory_; | 388 base::WeakPtrFactory<SessionService> weak_factory_; |
| 390 | 389 |
| 391 DISALLOW_COPY_AND_ASSIGN(SessionService); | 390 DISALLOW_COPY_AND_ASSIGN(SessionService); |
| 392 }; | 391 }; |
| 393 | 392 |
| 394 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 393 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| OLD | NEW |