Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: chrome/browser/sessions/session_service.h

Issue 672083002: Refactoring of SessionService to get componentized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing windows compile problem Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/task/cancelable_task_tracker.h" 15 #include "base/task/cancelable_task_tracker.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/sessions/base_session_service.h" 18 #include "chrome/browser/sessions/base_session_service.h"
19 #include "chrome/browser/sessions/session_service_commands.h"
20 #include "chrome/browser/sessions/session_service_utils.h"
19 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_list_observer.h" 23 #include "chrome/browser/ui/browser_list_observer.h"
22 #include "components/keyed_service/core/keyed_service.h" 24 #include "components/keyed_service/core/keyed_service.h"
23 #include "components/sessions/session_id.h"
24 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
26 #include "ui/base/ui_base_types.h" 27 #include "ui/base/ui_base_types.h"
27 28
28 class Profile; 29 class Profile;
29 class SessionCommand; 30 class SessionCommand;
30 struct SessionTab; 31 struct SessionTab;
31 struct SessionWindow; 32 struct SessionWindow;
32 33
33 namespace content { 34 namespace content {
34 class NavigationEntry; 35 class NavigationEntry;
35 class WebContents; 36 class WebContents;
36 } 37 }
37 38
38 // SessionService ------------------------------------------------------------ 39 // SessionService ------------------------------------------------------------
39 40
40 // SessionService is responsible for maintaining the state of open windows 41 // SessionService is responsible for maintaining the state of open windows
41 // and tabs so that they can be restored at a later date. The state of the 42 // and tabs so that they can be restored at a later date. The state of the
42 // currently open browsers is referred to as the current session. 43 // currently open browsers is referred to as the current session.
43 // 44 //
44 // SessionService supports restoring from the last session. The last session 45 // SessionService supports restoring from the last session. The last session
45 // typically corresponds to the last run of the browser, but not always. For 46 // typically corresponds to the last run of the browser, but not always. For
46 // example, if the user has a tabbed browser and app window running, closes the 47 // example, if the user has a tabbed browser and app window running, closes the
47 // tabbed browser, then creates a new tabbed browser the current session is made 48 // tabbed browser, then creates a new tabbed browser the current session is made
48 // the last session and the current session reset. This is done to provide the 49 // the last session and the current session reset. This is done to provide the
49 // illusion that app windows run in separate processes. Similar behavior occurs 50 // illusion that app windows run in separate processes. Similar behavior occurs
50 // with incognito windows. 51 // with incognito windows.
51 // 52 //
52 // SessionService itself maintains a set of SessionCommands that allow 53 // SessionService itself uses functions from session_service_commands to store
53 // SessionService to rebuild the open state of the browser (as SessionWindow, 54 // commands which can rebuild the open state of the browser (as |SessionWindow|,
54 // SessionTab and SerializedNavigationEntry). The commands are periodically 55 // |SessionTab| and |SerializedNavigationEntry|). The commands are periodically
55 // flushed to SessionBackend and written to a file. Every so often 56 // flushed to |SessionBackend| and written to a file. Every so often
56 // SessionService rebuilds the contents of the file from the open state of the 57 // |SessionService| rebuilds the contents of the file from the open state of the
57 // browser. 58 // browser.
58 class SessionService : public BaseSessionService, 59 class SessionService : public BaseSessionService,
59 public KeyedService, 60 public KeyedService,
60 public content::NotificationObserver, 61 public content::NotificationObserver,
61 public chrome::BrowserListObserver { 62 public chrome::BrowserListObserver {
62 friend class SessionServiceTestHelper; 63 friend class SessionServiceTestHelper;
63 public: 64 public:
64 // Used to distinguish an application window from a normal one. 65 // Used to distinguish an application from a ordinary content window.
65 enum AppType { 66 enum AppType {
66 TYPE_APP, 67 TYPE_APP,
67 TYPE_NORMAL 68 TYPE_NORMAL
68 }; 69 };
69 70
70 // Creates a SessionService for the specified profile. 71 // Creates a SessionService for the specified profile.
71 explicit SessionService(Profile* profile); 72 explicit SessionService(Profile* profile);
72 // For testing. 73 // For testing.
73 explicit SessionService(const base::FilePath& save_path); 74 explicit SessionService(const base::FilePath& save_path);
74 75
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void WindowClosed(const SessionID& window_id); 138 void WindowClosed(const SessionID& window_id);
138 139
139 // Called when a tab is inserted. 140 // Called when a tab is inserted.
140 void TabInserted(content::WebContents* contents); 141 void TabInserted(content::WebContents* contents);
141 142
142 // Called when a tab is closing. 143 // Called when a tab is closing.
143 void TabClosing(content::WebContents* contents); 144 void TabClosing(content::WebContents* contents);
144 145
145 // Sets the type of window. In order for the contents of a window to be 146 // Sets the type of window. In order for the contents of a window to be
146 // tracked SetWindowType must be invoked with a type we track 147 // tracked SetWindowType must be invoked with a type we track
147 // (should_track_changes_for_browser_type returns true). 148 // (ShouldRestoreOfWindowType returns true).
148 void SetWindowType(const SessionID& window_id, 149 void SetWindowType(const SessionID& window_id,
149 Browser::Type type, 150 Browser::Type type,
150 AppType app_type); 151 AppType app_type);
151 152
152 // Sets the application name of the specified window. 153 // Sets the application name of the specified window.
153 void SetWindowAppName(const SessionID& window_id, 154 void SetWindowAppName(const SessionID& window_id,
154 const std::string& app_name); 155 const std::string& app_name);
155 156
156 // Invoked when the NavigationController has removed entries from the back of 157 // Invoked when the NavigationController has removed entries from the back of
157 // the list. |count| gives the number of entries in the navigation controller. 158 // the list. |count| gives the number of entries in the navigation controller.
(...skipping 24 matching lines...) Expand all
182 int index); 183 int index);
183 184
184 // Sets the index of the selected tab in the specified window. 185 // Sets the index of the selected tab in the specified window.
185 void SetSelectedTabInWindow(const SessionID& window_id, int index); 186 void SetSelectedTabInWindow(const SessionID& window_id, int index);
186 187
187 // Sets the user agent override of the specified tab. 188 // Sets the user agent override of the specified tab.
188 void SetTabUserAgentOverride(const SessionID& window_id, 189 void SetTabUserAgentOverride(const SessionID& window_id,
189 const SessionID& tab_id, 190 const SessionID& tab_id,
190 const std::string& user_agent_override); 191 const std::string& user_agent_override);
191 192
193 // Sets the application extension id of the specified tab.
194 void SetTabExtensionAppID(const SessionID& window_id,
195 const SessionID& tab_id,
196 const std::string& extension_app_id);
197
192 // Callback from GetLastSession. 198 // Callback from GetLastSession.
193 // The second parameter is the id of the window that was last active. 199 // The second parameter is the id of the window that was last active.
194 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> 200 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)>
195 SessionCallback; 201 SessionCallback;
196 202
197 // Fetches the contents of the last session, notifying the callback when 203 // Fetches the contents of the last session, notifying the callback when
198 // done. If the callback is supplied an empty vector of SessionWindows 204 // done. If the callback is supplied an empty vector of SessionWindows
199 // it means the session could not be restored. 205 // it means the session could not be restored.
200 base::CancelableTaskTracker::TaskId GetLastSession( 206 base::CancelableTaskTracker::TaskId GetLastSession(
201 const SessionCallback& callback, 207 const SessionCallback& callback,
202 base::CancelableTaskTracker* tracker); 208 base::CancelableTaskTracker* tracker);
203 209
204 // Overridden from BaseSessionService because we want some UMA reporting on 210 // Overridden from BaseSessionService because we want some UMA reporting on
205 // session update activities. 211 // session update activities.
206 void Save() override; 212 void Save() override;
207 213
208 private: 214 private:
209 // Allow tests to access our innards for testing purposes. 215 // Allow tests to access our innards for testing purposes.
210 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation1); 216 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation1);
211 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation2); 217 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation2);
212 FRIEND_TEST_ALL_PREFIXES(NoStartupWindowTest, DontInitSessionServiceForApps); 218 FRIEND_TEST_ALL_PREFIXES(NoStartupWindowTest, DontInitSessionServiceForApps);
213 219
214 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange; 220 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange;
215 typedef std::map<SessionID::id_type, SessionTab*> IdToSessionTab;
216 typedef std::map<SessionID::id_type, SessionWindow*> IdToSessionWindow;
217
218
219 // These types mirror Browser::Type, but are re-defined here because these
220 // specific enumeration _values_ are written into the session database and
221 // are needed to maintain forward compatibility.
222 // Note that we only store browsers of type TYPE_TABBED and TYPE_POPUP.
223 enum WindowType {
224 TYPE_TABBED = 0,
225 TYPE_POPUP = 1
226 };
227 221
228 void Init(); 222 void Init();
229 223
224 // Returns true if a window of given |window_type| and |app_type| should get
225 // restored upon session restore.
226 bool ShouldRestoreWindowOfType(SessionWindow::WindowType type,
227 AppType app_type) const;
228
229 // Removes unrestorable windows from the previous windows list.
230 void RemoveUnusedRestoreWindows(std::vector<SessionWindow*>* window_list);
231
230 // Returns true if we have scheduled any commands, or any scheduled commands 232 // Returns true if we have scheduled any commands, or any scheduled commands
231 // have been saved. 233 // have been saved.
232 bool processed_any_commands(); 234 bool processed_any_commands();
233 235
234 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need 236 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need
235 // to restore, the tabs are added to it, otherwise a new browser is created. 237 // to restore, the tabs are added to it, otherwise a new browser is created.
236 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open, 238 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open,
237 Browser* browser); 239 Browser* browser);
238 240
239 void Observe(int type, 241 void Observe(int type,
240 const content::NotificationSource& source, 242 const content::NotificationSource& source,
241 const content::NotificationDetails& details) override; 243 const content::NotificationDetails& details) override;
242 244
243 // chrome::BrowserListObserver 245 // chrome::BrowserListObserver
244 void OnBrowserAdded(Browser* browser) override {} 246 void OnBrowserAdded(Browser* browser) override {}
245 void OnBrowserRemoved(Browser* browser) override {} 247 void OnBrowserRemoved(Browser* browser) override {}
246 void OnBrowserSetLastActive(Browser* browser) override; 248 void OnBrowserSetLastActive(Browser* browser) override;
247 249
248 // Sets the application extension id of the specified tab.
249 void SetTabExtensionAppID(const SessionID& window_id,
250 const SessionID& tab_id,
251 const std::string& extension_app_id);
252
253 // Methods to create the various commands. It is up to the caller to delete
254 // the returned the SessionCommand* object.
255 SessionCommand* CreateSetSelectedTabInWindow(const SessionID& window_id,
256 int index);
257
258 SessionCommand* CreateSetTabWindowCommand(const SessionID& window_id,
259 const SessionID& tab_id);
260
261 SessionCommand* CreateSetWindowBoundsCommand(const SessionID& window_id,
262 const gfx::Rect& bounds,
263 ui::WindowShowState show_state);
264
265 SessionCommand* CreateSetTabIndexInWindowCommand(const SessionID& tab_id,
266 int new_index);
267
268 SessionCommand* CreateTabClosedCommand(SessionID::id_type tab_id);
269
270 SessionCommand* CreateWindowClosedCommand(SessionID::id_type tab_id);
271
272 SessionCommand* CreateSetSelectedNavigationIndexCommand(
273 const SessionID& tab_id,
274 int index);
275
276 SessionCommand* CreateSetWindowTypeCommand(const SessionID& window_id,
277 WindowType type);
278
279 SessionCommand* CreatePinnedStateCommand(const SessionID& tab_id,
280 bool is_pinned);
281
282 SessionCommand* CreateSessionStorageAssociatedCommand(
283 const SessionID& tab_id,
284 const std::string& session_storage_persistent_id);
285
286 SessionCommand* CreateSetActiveWindowCommand(const SessionID& window_id);
287
288 // Converts |commands| to SessionWindows and notifies the callback. 250 // Converts |commands| to SessionWindows and notifies the callback.
289 void OnGotSessionCommands(const SessionCallback& callback, 251 void OnGotSessionCommands(const SessionCallback& callback,
290 ScopedVector<SessionCommand> commands); 252 ScopedVector<SessionCommand> commands);
291 253
292 // Converts the commands into SessionWindows. On return any valid
293 // windows are added to valid_windows. It is up to the caller to delete
294 // the windows added to valid_windows. |active_window_id| will be set with the
295 // id of the last active window, but it's only valid when this id corresponds
296 // to the id of one of the windows in valid_windows.
297 void RestoreSessionFromCommands(const std::vector<SessionCommand*>& commands,
298 std::vector<SessionWindow*>* valid_windows,
299 SessionID::id_type* active_window_id);
300
301 // Iterates through the vector updating the selected_tab_index of each
302 // SessionWindow based on the actual tabs that were restored.
303 void UpdateSelectedTabIndex(std::vector<SessionWindow*>* windows);
304
305 // Returns the window in windows with the specified id. If a window does
306 // not exist, one is created.
307 SessionWindow* GetWindow(SessionID::id_type window_id,
308 IdToSessionWindow* windows);
309
310 // Returns the tab with the specified id in tabs. If a tab does not exist,
311 // it is created.
312 SessionTab* GetTab(SessionID::id_type tab_id,
313 IdToSessionTab* tabs);
314
315 // Returns an iterator into navigations pointing to the navigation whose
316 // index matches |index|. If no navigation index matches |index|, the first
317 // navigation with an index > |index| is returned.
318 //
319 // This assumes the navigations are ordered by index in ascending order.
320 std::vector<sessions::SerializedNavigationEntry>::iterator
321 FindClosestNavigationWithIndex(
322 std::vector<sessions::SerializedNavigationEntry>* navigations,
323 int index);
324
325 // Does the following:
326 // . Deletes and removes any windows with no tabs or windows with types other
327 // than tabbed_browser or browser. NOTE: constrained windows that have
328 // been dragged out are of type browser. As such, this preserves any dragged
329 // out constrained windows (aka popups that have been dragged out).
330 // . Sorts the tabs in windows with valid tabs based on the tabs
331 // visual order, and adds the valid windows to windows.
332 void SortTabsBasedOnVisualOrderAndPrune(
333 std::map<int, SessionWindow*>* windows,
334 std::vector<SessionWindow*>* valid_windows);
335
336 // Adds tabs to their parent window based on the tab's window_id. This
337 // ignores tabs with no navigations.
338 void AddTabsToWindows(std::map<int, SessionTab*>* tabs,
339 std::map<int, SessionWindow*>* windows);
340
341 // Creates tabs and windows from the commands specified in |data|. The created
342 // tabs and windows are added to |tabs| and |windows| respectively, with the
343 // id of the active window set in |active_window_id|. It is up to the caller
344 // to delete the tabs and windows added to |tabs| and |windows|.
345 //
346 // This does NOT add any created SessionTabs to SessionWindow.tabs, that is
347 // done by AddTabsToWindows.
348 bool CreateTabsAndWindows(const std::vector<SessionCommand*>& data,
349 std::map<int, SessionTab*>* tabs,
350 std::map<int, SessionWindow*>* windows,
351 SessionID::id_type* active_window_id);
352
353 // 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
354 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each 255 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each
355 // direction from the current navigation index). 256 // direction from the current navigation index).
356 // 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
357 // indices that were written. 258 // indices that were written.
358 void BuildCommandsForTab( 259 void BuildCommandsForTab(
359 const SessionID& window_id, 260 const SessionID& window_id,
360 content::WebContents* tab, 261 content::WebContents* tab,
361 int index_in_window, 262 int index_in_window,
362 bool is_pinned, 263 bool is_pinned,
363 std::vector<SessionCommand*>* commands, 264 std::vector<SessionCommand*>* commands,
364 IdToRange* tab_to_available_range); 265 IdToRange* tab_to_available_range);
365 266
366 // Adds commands to create the specified browser, and invokes 267 // Adds commands to create the specified browser, and invokes
367 // BuildCommandsForTab for each of the tabs in the browser. This ignores 268 // BuildCommandsForTab for each of the tabs in the browser. This ignores
368 // any tabs not in the profile we were created with. 269 // any tabs not in the profile we were created with.
369 void BuildCommandsForBrowser( 270 void BuildCommandsForBrowser(
370 Browser* browser, 271 Browser* browser,
371 std::vector<SessionCommand*>* commands, 272 std::vector<SessionCommand*>* commands,
372 IdToRange* tab_to_available_range, 273 IdToRange* tab_to_available_range,
373 std::set<SessionID::id_type>* windows_to_track); 274 std::set<SessionID::id_type>* windows_to_track);
374 275
375 // Iterates over all the known browsers invoking BuildCommandsForBrowser. 276 // Iterates over all the known browsers invoking BuildCommandsForBrowser.
376 // This only adds browsers that should be tracked 277 // This only adds browsers that should be tracked (|ShouldRestoreWindowOfType|
377 // (should_track_changes_for_browser_type returns true). All browsers that 278 // returns true). All browsers that are tracked are added to windows_to_track
378 // are tracked are added to windows_to_track (as long as it is non-null). 279 // (as long as it is non-null).
379 void BuildCommandsFromBrowsers( 280 void BuildCommandsFromBrowsers(
380 std::vector<SessionCommand*>* commands, 281 std::vector<SessionCommand*>* commands,
381 IdToRange* tab_to_available_range, 282 IdToRange* tab_to_available_range,
382 std::set<SessionID::id_type>* windows_to_track); 283 std::set<SessionID::id_type>* windows_to_track);
383 284
384 // Schedules a reset. A reset means the contents of the file are recreated 285 // Schedules a reset of the existing commands. A reset means the contents
385 // from the state of the browser. 286 // of the file are recreated from the state of the browser.
386 void ScheduleReset(); 287 void ScheduleResetCommands();
387
388 // Searches for a pending command that can be replaced with command.
389 // If one is found, pending command is removed, command is added to
390 // the pending commands and true is returned.
391 bool ReplacePendingCommand(SessionCommand* command);
392 288
393 // Schedules the specified command. This method takes ownership of the 289 // Schedules the specified command. This method takes ownership of the
394 // command. 290 // command.
395 void ScheduleCommand(SessionCommand* command) override; 291 void ScheduleCommand(SessionCommand* command) override;
396 292
397 // Converts all pending tab/window closes to commands and schedules them. 293 // Converts all pending tab/window closes to commands and schedules them.
398 void CommitPendingCloses(); 294 void CommitPendingCloses();
399 295
400 // Returns true if there is only one window open with a single tab that shares 296 // Returns true if there is only one window open with a single tab that shares
401 // our profile. 297 // our profile.
402 bool IsOnlyOneTabLeft() const; 298 bool IsOnlyOneTabLeft() const;
403 299
404 // Returns true if there are open trackable browser windows whose ids do 300 // Returns true if there are open trackable browser windows whose ids do
405 // match |window_id| with our profile. A trackable window is a window from 301 // match |window_id| with our profile. A trackable window is a window from
406 // which |should_track_changes_for_browser_type| returns true. See 302 // which |ShouldRestoreWindowOfType| returns true. See
407 // |should_track_changes_for_browser_type| for details. 303 // |ShouldRestoreWindowOfType| for details.
408 bool HasOpenTrackableBrowsers(const SessionID& window_id) const; 304 bool HasOpenTrackableBrowsers(const SessionID& window_id) const;
409 305
410 // Returns true if changes to tabs in the specified window should be tracked. 306 // Returns true if changes to tabs in the specified window should be tracked.
411 bool ShouldTrackChangesToWindow(const SessionID& window_id) const; 307 bool ShouldTrackChangesToWindow(const SessionID& window_id) const;
412 308
413 // Returns true if we track changes to the specified browser. 309 // Returns true if we track changes to the specified browser.
414 bool ShouldTrackBrowser(Browser* browser) const; 310 bool ShouldTrackBrowser(Browser* browser) const;
415 311
416 // Returns true if we track changes to the specified browser type.
417 static bool should_track_changes_for_browser_type(
418 Browser::Type type,
419 AppType app_type);
420
421 // Call when certain session relevant notifications 312 // Call when certain session relevant notifications
422 // (tab_closed, nav_list_pruned) occur. In addition, this is 313 // (tab_closed, nav_list_pruned) occur. In addition, this is
423 // currently called when Save() is called to compare how often the 314 // currently called when Save() is called to compare how often the
424 // session data is currently saved verses when we may want to save it. 315 // session data is currently saved verses when we may want to save it.
425 // It records the data in UMA stats. 316 // It records the data in UMA stats.
426 void RecordSessionUpdateHistogramData(int type, 317 void RecordSessionUpdateHistogramData(int type,
427 base::TimeTicks* last_updated_time); 318 base::TimeTicks* last_updated_time);
428 319
429 // Helper methods to record the histogram data 320 // Helper methods to record the histogram data
430 void RecordUpdatedTabClosed(base::TimeDelta delta, bool use_long_period); 321 void RecordUpdatedTabClosed(base::TimeDelta delta, bool use_long_period);
431 void RecordUpdatedNavListPruned(base::TimeDelta delta, bool use_long_period); 322 void RecordUpdatedNavListPruned(base::TimeDelta delta, bool use_long_period);
432 void RecordUpdatedNavEntryCommit(base::TimeDelta delta, bool use_long_period); 323 void RecordUpdatedNavEntryCommit(base::TimeDelta delta, bool use_long_period);
433 void RecordUpdatedSaveTime(base::TimeDelta delta, bool use_long_period); 324 void RecordUpdatedSaveTime(base::TimeDelta delta, bool use_long_period);
434 void RecordUpdatedSessionNavigationOrTab(base::TimeDelta delta, 325 void RecordUpdatedSessionNavigationOrTab(base::TimeDelta delta,
435 bool use_long_period); 326 bool use_long_period);
436 327
437 // Deletes session data if no windows are open for the current profile. 328 // Deletes session data if no windows are open for the current profile.
438 void MaybeDeleteSessionOnlyData(); 329 void MaybeDeleteSessionOnlyData();
439 330
440 // Convert back/forward between the Browser and SessionService DB window
441 // types.
442 static WindowType WindowTypeForBrowserType(Browser::Type type);
443 static Browser::Type BrowserTypeForWindowType(WindowType type);
444
445 // The profile. This may be null during testing. 331 // The profile. This may be null during testing.
446 Profile* profile_; 332 Profile* profile_;
447 333
448 content::NotificationRegistrar registrar_; 334 content::NotificationRegistrar registrar_;
449 335
450 // Maps from session tab id to the range of navigation entries that has 336 // Maps from session tab id to the range of navigation entries that has
451 // been written to disk. 337 // been written to disk.
452 // 338 //
453 // This is only used if not all the navigation entries have been 339 // This is only used if not all the navigation entries have been
454 // written. 340 // written.
(...skipping 10 matching lines...) Expand all
465 // closing, but not yet committed. 351 // closing, but not yet committed.
466 typedef std::set<SessionID::id_type> PendingTabCloseIDs; 352 typedef std::set<SessionID::id_type> PendingTabCloseIDs;
467 PendingTabCloseIDs pending_tab_close_ids_; 353 PendingTabCloseIDs pending_tab_close_ids_;
468 354
469 // When a window other than the last window (see description of 355 // When a window other than the last window (see description of
470 // pending_window_close_ids) is closed, the id is added to this set. 356 // pending_window_close_ids) is closed, the id is added to this set.
471 typedef std::set<SessionID::id_type> WindowClosingIDs; 357 typedef std::set<SessionID::id_type> WindowClosingIDs;
472 WindowClosingIDs window_closing_ids_; 358 WindowClosingIDs window_closing_ids_;
473 359
474 // Set of windows we're tracking changes to. This is only browsers that 360 // Set of windows we're tracking changes to. This is only browsers that
475 // return true from should_track_changes_for_browser_type. 361 // return true from |ShouldRestoreWindowOfType|.
476 typedef std::set<SessionID::id_type> WindowsTracking; 362 typedef std::set<SessionID::id_type> WindowsTracking;
477 WindowsTracking windows_tracking_; 363 WindowsTracking windows_tracking_;
478 364
479 // Are there any open trackable browsers? 365 // Are there any open trackable browsers?
480 bool has_open_trackable_browsers_; 366 bool has_open_trackable_browsers_;
481 367
482 // If true and a new tabbed browser is created and there are no opened tabbed 368 // If true and a new tabbed browser is created and there are no opened tabbed
483 // browser (has_open_trackable_browsers_ is false), then the current session 369 // browser (has_open_trackable_browsers_ is false), then the current session
484 // is made the last session. See description above class for details on 370 // is made the last session. See description above class for details on
485 // current/last session. 371 // current/last session.
(...skipping 13 matching lines...) Expand all
499 // For browser_tests, since we want to simulate the browser shutting down 385 // For browser_tests, since we want to simulate the browser shutting down
500 // without quitting. 386 // without quitting.
501 bool force_browser_not_alive_with_no_windows_; 387 bool force_browser_not_alive_with_no_windows_;
502 388
503 base::WeakPtrFactory<SessionService> weak_factory_; 389 base::WeakPtrFactory<SessionService> weak_factory_;
504 390
505 DISALLOW_COPY_AND_ASSIGN(SessionService); 391 DISALLOW_COPY_AND_ASSIGN(SessionService);
506 }; 392 };
507 393
508 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ 394 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698