blob: 67fd97df0687713009696eed05e70145169e2bbf [file] [log] [blame]
[email protected]a636d8e52012-02-28 15:40:411// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]169627b2008-12-06 19:30:195#ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
6#define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
initial.commit09911bf2008-07-26 23:55:297
8#include <map>
[email protected]23da84e152010-07-14 01:29:059#include <string>
initial.commit09911bf2008-07-26 23:55:2910
11#include "base/basictypes.h"
[email protected]f9ffb892011-11-28 18:57:3112#include "base/callback.h"
[email protected]70eb8ed92010-06-10 18:13:1213#include "base/time.h"
[email protected]982921f12009-10-27 21:43:5314#include "chrome/browser/defaults.h"
[email protected]926bfeb2009-02-14 23:19:4715#include "chrome/browser/sessions/base_session_service.h"
[email protected]169627b2008-12-06 19:30:1916#include "chrome/browser/sessions/session_id.h"
[email protected]2ad4a902010-11-17 06:05:1317#include "chrome/browser/ui/browser.h"
18#include "chrome/browser/ui/browser_list.h"
[email protected]6c2381d2011-10-19 02:52:5319#include "content/public/browser/notification_observer.h"
20#include "content/public/browser/notification_registrar.h"
[email protected]400eaf82011-08-22 15:47:3921#include "ui/base/ui_base_types.h"
initial.commit09911bf2008-07-26 23:55:2922
initial.commit09911bf2008-07-26 23:55:2923class Profile;
initial.commit09911bf2008-07-26 23:55:2924class SessionCommand;
[email protected]c36a9e1d2012-06-05 14:31:0225class TabContents;
[email protected]169627b2008-12-06 19:30:1926struct SessionTab;
27struct SessionWindow;
[email protected]ad23a092011-12-28 07:02:0428
29namespace content {
30class NavigationEntry;
[email protected]40600152012-09-26 10:04:3131class WebContents;
[email protected]ad23a092011-12-28 07:02:0432}
initial.commit09911bf2008-07-26 23:55:2933
34// SessionService ------------------------------------------------------------
35
36// SessionService is responsible for maintaining the state of open windows
[email protected]6ea265a2008-10-30 02:58:3637// and tabs so that they can be restored at a later date. The state of the
38// currently open browsers is referred to as the current session.
initial.commit09911bf2008-07-26 23:55:2939//
[email protected]668cd422011-04-06 21:00:0140// SessionService supports restoring from the last session. The last session
41// typically corresponds to the last run of the browser, but not always. For
42// example, if the user has a tabbed browser and app window running, closes the
43// tabbed browser, then creates a new tabbed browser the current session is made
44// the last session and the current session reset. This is done to provide the
45// illusion that app windows run in separate processes. Similar behavior occurs
46// with incognito windows.
initial.commit09911bf2008-07-26 23:55:2947//
48// SessionService itself maintains a set of SessionCommands that allow
49// SessionService to rebuild the open state of the browser (as
50// SessionWindow, SessionTab and TabNavigation). The commands are periodically
51// flushed to SessionBackend and written to a file. Every so often
52// SessionService rebuilds the contents of the file from the open state
53// of the browser.
[email protected]169627b2008-12-06 19:30:1954class SessionService : public BaseSessionService,
[email protected]6c2381d2011-10-19 02:52:5355 public content::NotificationObserver {
[email protected]86ef6a392012-05-11 22:03:1156 friend class SessionServiceTestHelper;
initial.commit09911bf2008-07-26 23:55:2957 public:
[email protected]a636d8e52012-02-28 15:40:4158 // Used to distinguish an application window from a normal one.
59 enum AppType {
60 TYPE_APP,
61 TYPE_NORMAL
62 };
63
initial.commit09911bf2008-07-26 23:55:2964 // Creates a SessionService for the specified profile.
65 explicit SessionService(Profile* profile);
66 // For testing.
[email protected]5a82010a2009-02-14 01:33:0267 explicit SessionService(const FilePath& save_path);
initial.commit09911bf2008-07-26 23:55:2968
[email protected]f0a58a382011-04-26 16:09:2969 virtual ~SessionService();
70
[email protected]8ddbb642011-09-01 02:52:2071 // Returns true if a new window opening should really be treated like the
72 // start of a session (with potential session restore, startup URLs, etc.).
73 // In particular, this is true if there are no tabbed browsers running
74 // currently (eg. because only background or other app pages are running).
75 bool ShouldNewWindowStartSession();
76
[email protected]c9b19942010-03-26 15:58:0877 // Invoke at a point when you think session restore might occur. For example,
78 // during startup and window creation this is invoked to see if a session
79 // needs to be restored. If a session needs to be restored it is done so
80 // asynchronously and true is returned. If false is returned the session was
81 // not restored and the caller needs to create a new window.
82 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open);
83
initial.commit09911bf2008-07-26 23:55:2984 // Resets the contents of the file from the current state of all open
85 // browsers whose profile matches our profile.
86 void ResetFromCurrentBrowsers();
87
88 // Moves the current session to the last session. This is useful when a
89 // checkpoint occurs, such as when the user launches the app and no tabbed
90 // browsers are running.
91 void MoveCurrentSessionToLastSession();
92
93 // Associates a tab with a window.
94 void SetTabWindow(const SessionID& window_id,
95 const SessionID& tab_id);
96
97 // Sets the bounds of a window.
98 void SetWindowBounds(const SessionID& window_id,
99 const gfx::Rect& bounds,
[email protected]400eaf82011-08-22 15:47:39100 ui::WindowShowState show_state);
initial.commit09911bf2008-07-26 23:55:29101
102 // Sets the visual index of the tab in its parent window.
103 void SetTabIndexInWindow(const SessionID& window_id,
104 const SessionID& tab_id,
105 int new_index);
106
[email protected]5c0e6482009-07-14 20:20:09107 // Sets the pinned state of the tab.
108 void SetPinnedState(const SessionID& window_id,
109 const SessionID& tab_id,
110 bool is_pinned);
111
[email protected]c0e3ee42010-05-26 22:11:07112 // Notification that a tab has been closed. |closed_by_user_gesture| comes
[email protected]e6ff1d52012-04-17 20:00:40113 // from |WebContents::closed_by_user_gesture|; see it for details.
initial.commit09911bf2008-07-26 23:55:29114 //
115 // Note: this is invoked from the NavigationController's destructor, which is
116 // after the actual tab has been removed.
[email protected]c0e3ee42010-05-26 22:11:07117 void TabClosed(const SessionID& window_id,
118 const SessionID& tab_id,
119 bool closed_by_user_gesture);
initial.commit09911bf2008-07-26 23:55:29120
121 // Notification the window is about to close.
122 void WindowClosing(const SessionID& window_id);
123
124 // Notification a window has finished closing.
125 void WindowClosed(const SessionID& window_id);
126
[email protected]40600152012-09-26 10:04:31127 // Called when a tab is inserted.
128 void TabInserted(content::WebContents* contents);
129
130 // Called when a tab is closing.
131 void TabClosing(content::WebContents* contents);
132
initial.commit09911bf2008-07-26 23:55:29133 // Sets the type of window. In order for the contents of a window to be
134 // tracked SetWindowType must be invoked with a type we track
135 // (should_track_changes_for_browser_type returns true).
[email protected]a636d8e52012-02-28 15:40:41136 void SetWindowType(const SessionID& window_id,
137 Browser::Type type,
138 AppType app_type);
139
140 // Sets the application name of the specified window.
141 void SetWindowAppName(const SessionID& window_id,
142 const std::string& app_name);
initial.commit09911bf2008-07-26 23:55:29143
[email protected]c12bf1a12008-09-17 16:28:49144 // Invoked when the NavigationController has removed entries from the back of
145 // the list. |count| gives the number of entries in the navigation controller.
146 void TabNavigationPathPrunedFromBack(const SessionID& window_id,
147 const SessionID& tab_id,
148 int count);
149
150 // Invoked when the NavigationController has removed entries from the front of
151 // the list. |count| gives the number of entries that were removed.
152 void TabNavigationPathPrunedFromFront(const SessionID& window_id,
153 const SessionID& tab_id,
154 int count);
initial.commit09911bf2008-07-26 23:55:29155
156 // Updates the navigation entry for the specified tab.
157 void UpdateTabNavigation(const SessionID& window_id,
158 const SessionID& tab_id,
[email protected]9dd1d582012-09-19 04:04:16159 const TabNavigation& navigation);
initial.commit09911bf2008-07-26 23:55:29160
161 // Notification that a tab has restored its entries or a closed tab is being
162 // reused.
[email protected]337a286e2012-06-09 00:01:45163 void TabRestored(TabContents* tab, bool pinned);
initial.commit09911bf2008-07-26 23:55:29164
165 // Sets the index of the selected entry in the navigation controller for the
166 // specified tab.
167 void SetSelectedNavigationIndex(const SessionID& window_id,
168 const SessionID& tab_id,
169 int index);
170
171 // Sets the index of the selected tab in the specified window.
172 void SetSelectedTabInWindow(const SessionID& window_id, int index);
173
[email protected]8d0f3312012-08-18 01:47:53174 // Sets the user agent override of the specified tab.
175 void SetTabUserAgentOverride(const SessionID& window_id,
176 const SessionID& tab_id,
177 const std::string& user_agent_override);
178
initial.commit09911bf2008-07-26 23:55:29179 // Callback from GetSavedSession of GetLastSession.
180 //
181 // The contents of the supplied vector are deleted after the callback is
182 // notified. To take ownership of the vector clear it before returning.
183 //
184 // The time gives the time the session was closed.
[email protected]f9ffb892011-11-28 18:57:31185 typedef base::Callback<void(Handle, std::vector<SessionWindow*>*)>
[email protected]3acb70ef2010-03-01 18:44:38186 SessionCallback;
initial.commit09911bf2008-07-26 23:55:29187
188 // Fetches the contents of the last session, notifying the callback when
189 // done. If the callback is supplied an empty vector of SessionWindows
190 // it means the session could not be restored.
[email protected]169627b2008-12-06 19:30:19191 //
192 // The created request does NOT directly invoke the callback, rather the
193 // callback invokes OnGotSessionCommands from which we map the
194 // SessionCommands to browser state, then notify the callback.
initial.commit09911bf2008-07-26 23:55:29195 Handle GetLastSession(CancelableRequestConsumerBase* consumer,
[email protected]f9ffb892011-11-28 18:57:31196 const SessionCallback& callback);
[email protected]3acb70ef2010-03-01 18:44:38197
[email protected]70eb8ed92010-06-10 18:13:12198 // Overridden from BaseSessionService because we want some UMA reporting on
199 // session update activities.
[email protected]49fd7e22011-11-21 16:52:21200 virtual void Save() OVERRIDE;
[email protected]70eb8ed92010-06-10 18:13:12201
initial.commit09911bf2008-07-26 23:55:29202 private:
[email protected]23da84e152010-07-14 01:29:05203 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange;
204 typedef std::map<SessionID::id_type, SessionTab*> IdToSessionTab;
205 typedef std::map<SessionID::id_type, SessionWindow*> IdToSessionWindow;
206
initial.commit09911bf2008-07-26 23:55:29207
[email protected]97d2c1e2009-11-05 03:55:05208 // These types mirror Browser::Type, but are re-defined here because these
209 // specific enumeration _values_ are written into the session database and
210 // are needed to maintain forward compatibility.
[email protected]b35b26b32011-05-05 20:35:14211 // Note that we only store browsers of type TYPE_TABBED and TYPE_POPUP.
[email protected]97d2c1e2009-11-05 03:55:05212 enum WindowType {
[email protected]b35b26b32011-05-05 20:35:14213 TYPE_TABBED = 0,
214 TYPE_POPUP = 1
[email protected]97d2c1e2009-11-05 03:55:05215 };
216
[email protected]169627b2008-12-06 19:30:19217 void Init();
initial.commit09911bf2008-07-26 23:55:29218
[email protected]c9b19942010-03-26 15:58:08219 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need
220 // to restore, the tabs are added to it, otherwise a new browser is created.
221 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open,
222 Browser* browser);
223
[email protected]432115822011-07-10 15:52:27224 virtual void Observe(int type,
[email protected]6c2381d2011-10-19 02:52:53225 const content::NotificationSource& source,
[email protected]49fd7e22011-11-21 16:52:21226 const content::NotificationDetails& details) OVERRIDE;
[email protected]534e54b2008-08-13 15:40:09227
[email protected]fca656c2010-02-10 20:30:10228 // Sets the application extension id of the specified tab.
[email protected]98aa0b52010-05-06 17:03:08229 void SetTabExtensionAppID(const SessionID& window_id,
[email protected]fca656c2010-02-10 20:30:10230 const SessionID& tab_id,
[email protected]98aa0b52010-05-06 17:03:08231 const std::string& extension_app_id);
[email protected]fca656c2010-02-10 20:30:10232
initial.commit09911bf2008-07-26 23:55:29233 // Methods to create the various commands. It is up to the caller to delete
234 // the returned the SessionCommand* object.
235 SessionCommand* CreateSetSelectedTabInWindow(const SessionID& window_id,
236 int index);
237
238 SessionCommand* CreateSetTabWindowCommand(const SessionID& window_id,
239 const SessionID& tab_id);
240
241 SessionCommand* CreateSetWindowBoundsCommand(const SessionID& window_id,
242 const gfx::Rect& bounds,
[email protected]400eaf82011-08-22 15:47:39243 ui::WindowShowState show_state);
initial.commit09911bf2008-07-26 23:55:29244
245 SessionCommand* CreateSetTabIndexInWindowCommand(const SessionID& tab_id,
246 int new_index);
247
248 SessionCommand* CreateTabClosedCommand(SessionID::id_type tab_id);
249
250 SessionCommand* CreateWindowClosedCommand(SessionID::id_type tab_id);
251
initial.commit09911bf2008-07-26 23:55:29252 SessionCommand* CreateSetSelectedNavigationIndexCommand(
253 const SessionID& tab_id,
254 int index);
255
256 SessionCommand* CreateSetWindowTypeCommand(const SessionID& window_id,
[email protected]97d2c1e2009-11-05 03:55:05257 WindowType type);
initial.commit09911bf2008-07-26 23:55:29258
[email protected]5c0e6482009-07-14 20:20:09259 SessionCommand* CreatePinnedStateCommand(const SessionID& tab_id,
260 bool is_pinned);
261
[email protected]9cc8fd92012-06-22 21:20:55262 SessionCommand* CreateSessionStorageAssociatedCommand(
263 const SessionID& tab_id,
264 const std::string& session_storage_persistent_id);
265
[email protected]668cd422011-04-06 21:00:01266 // Callback from the backend for getting the commands from the save file.
267 // Converts the commands in SessionWindows and notifies the real callback.
[email protected]3acb70ef2010-03-01 18:44:38268 void OnGotSessionCommands(
initial.commit09911bf2008-07-26 23:55:29269 Handle handle,
[email protected]169627b2008-12-06 19:30:19270 scoped_refptr<InternalGetCommandsRequest> request);
initial.commit09911bf2008-07-26 23:55:29271
272 // Converts the commands into SessionWindows. On return any valid
273 // windows are added to valid_windows. It is up to the caller to delete
274 // the windows added to valid_windows.
275 //
276 // If ignore_recent_closes is true, any window/tab closes within in a certain
277 // time frame are ignored.
278 void RestoreSessionFromCommands(const std::vector<SessionCommand*>& commands,
279 std::vector<SessionWindow*>* valid_windows);
280
281 // Iterates through the vector updating the selected_tab_index of each
282 // SessionWindow based on the actual tabs that were restored.
283 void UpdateSelectedTabIndex(std::vector<SessionWindow*>* windows);
284
285 // Returns the window in windows with the specified id. If a window does
286 // not exist, one is created.
287 SessionWindow* GetWindow(SessionID::id_type window_id,
288 IdToSessionWindow* windows);
289
290 // Returns the tab with the specified id in tabs. If a tab does not exist,
291 // it is created.
292 SessionTab* GetTab(SessionID::id_type tab_id,
293 IdToSessionTab* tabs);
294
295 // Returns an iterator into navigations pointing to the navigation whose
296 // index matches |index|. If no navigation index matches |index|, the first
297 // navigation with an index > |index| is returned.
298 //
299 // This assumes the navigations are ordered by index in ascending order.
300 std::vector<TabNavigation>::iterator FindClosestNavigationWithIndex(
301 std::vector<TabNavigation>* navigations,
302 int index);
303
304 // Does the following:
305 // . Deletes and removes any windows with no tabs or windows with types other
306 // than tabbed_browser or browser. NOTE: constrained windows that have
307 // been dragged out are of type browser. As such, this preserves any dragged
308 // out constrained windows (aka popups that have been dragged out).
309 // . Sorts the tabs in windows with valid tabs based on the tabs
310 // visual order, and adds the valid windows to windows.
311 void SortTabsBasedOnVisualOrderAndPrune(
[email protected]23da84e152010-07-14 01:29:05312 std::map<int, SessionWindow*>* windows,
initial.commit09911bf2008-07-26 23:55:29313 std::vector<SessionWindow*>* valid_windows);
314
315 // Adds tabs to their parent window based on the tab's window_id. This
316 // ignores tabs with no navigations.
[email protected]23da84e152010-07-14 01:29:05317 void AddTabsToWindows(std::map<int, SessionTab*>* tabs,
318 std::map<int, SessionWindow*>* windows);
initial.commit09911bf2008-07-26 23:55:29319
320 // Creates tabs and windows from the specified commands. The created tabs
321 // and windows are added to |tabs| and |windows| respectively. It is up to
322 // the caller to delete the tabs and windows added to |tabs| and |windows|.
323 //
324 // This does NOT add any created SessionTabs to SessionWindow.tabs, that is
325 // done by AddTabsToWindows.
326 bool CreateTabsAndWindows(const std::vector<SessionCommand*>& data,
[email protected]23da84e152010-07-14 01:29:05327 std::map<int, SessionTab*>* tabs,
328 std::map<int, SessionWindow*>* windows);
initial.commit09911bf2008-07-26 23:55:29329
330 // Adds commands to commands that will recreate the state of the specified
[email protected]81898992011-06-14 22:15:00331 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each
332 // direction from the current navigation index).
initial.commit09911bf2008-07-26 23:55:29333 // A pair is added to tab_to_available_range indicating the range of
334 // indices that were written.
335 void BuildCommandsForTab(
336 const SessionID& window_id,
[email protected]337a286e2012-06-09 00:01:45337 TabContents* tab,
initial.commit09911bf2008-07-26 23:55:29338 int index_in_window,
[email protected]5c0e6482009-07-14 20:20:09339 bool is_pinned,
initial.commit09911bf2008-07-26 23:55:29340 std::vector<SessionCommand*>* commands,
341 IdToRange* tab_to_available_range);
342
343 // Adds commands to create the specified browser, and invokes
344 // BuildCommandsForTab for each of the tabs in the browser. This ignores
345 // any tabs not in the profile we were created with.
346 void BuildCommandsForBrowser(
347 Browser* browser,
348 std::vector<SessionCommand*>* commands,
349 IdToRange* tab_to_available_range,
350 std::set<SessionID::id_type>* windows_to_track);
351
352 // Iterates over all the known browsers invoking BuildCommandsForBrowser.
353 // This only adds browsers that should be tracked
354 // (should_track_changes_for_browser_type returns true). All browsers that
355 // are tracked are added to windows_to_track (as long as it is non-null).
356 void BuildCommandsFromBrowsers(
357 std::vector<SessionCommand*>* commands,
358 IdToRange* tab_to_available_range,
359 std::set<SessionID::id_type>* windows_to_track);
360
361 // Schedules a reset. A reset means the contents of the file are recreated
362 // from the state of the browser.
363 void ScheduleReset();
364
365 // Searches for a pending command that can be replaced with command.
366 // If one is found, pending command is removed, command is added to
367 // the pending commands and true is returned.
368 bool ReplacePendingCommand(SessionCommand* command);
369
370 // Schedules the specified command. This method takes ownership of the
371 // command.
[email protected]49fd7e22011-11-21 16:52:21372 virtual void ScheduleCommand(SessionCommand* command) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29373
374 // Converts all pending tab/window closes to commands and schedules them.
375 void CommitPendingCloses();
376
initial.commit09911bf2008-07-26 23:55:29377 // Returns true if there is only one window open with a single tab that shares
378 // our profile.
379 bool IsOnlyOneTabLeft();
380
[email protected]982921f12009-10-27 21:43:53381 // Returns true if there are open trackable browser windows whose ids do
382 // match |window_id| with our profile. A trackable window is a window from
383 // which |should_track_changes_for_browser_type| returns true. See
384 // |should_track_changes_for_browser_type| for details.
385 bool HasOpenTrackableBrowsers(const SessionID& window_id);
initial.commit09911bf2008-07-26 23:55:29386
387 // Returns true if changes to tabs in the specified window should be tracked.
388 bool ShouldTrackChangesToWindow(const SessionID& window_id);
389
390 // Returns true if we track changes to the specified browser type.
[email protected]a636d8e52012-02-28 15:40:41391 static bool should_track_changes_for_browser_type(
392 Browser::Type type,
393 AppType app_type);
initial.commit09911bf2008-07-26 23:55:29394
[email protected]4070a6b2009-11-05 23:33:55395 // Returns true if we should record a window close as pending.
396 // |has_open_trackable_browsers_| must be up-to-date before calling this.
397 bool should_record_close_as_pending() const {
398 // When this is called, the browser window being closed is still open, hence
399 // still in the browser list. If there is a browser window other than the
400 // one being closed but no trackable windows, then the others must be App
401 // windows or similar. In this case, we record the close as pending.
402 return !has_open_trackable_browsers_ &&
403 (!browser_defaults::kBrowserAliveWithNoWindows ||
[email protected]c4340bc02012-04-25 02:49:38404 force_browser_not_alive_with_no_windows_ ||
[email protected]4070a6b2009-11-05 23:33:55405 BrowserList::size() > 1);
[email protected]70eb8ed92010-06-10 18:13:12406 }
407
[email protected]23da84e152010-07-14 01:29:05408 // Call when certain session relevant notifications
409 // (tab_closed, nav_list_pruned) occur. In addition, this is
410 // currently called when Save() is called to compare how often the
411 // session data is currently saved verses when we may want to save it.
412 // It records the data in UMA stats.
[email protected]432115822011-07-10 15:52:27413 void RecordSessionUpdateHistogramData(int type,
[email protected]23da84e152010-07-14 01:29:05414 base::TimeTicks* last_updated_time);
415
416 // Helper methods to record the histogram data
417 void RecordUpdatedTabClosed(base::TimeDelta delta, bool use_long_period);
418 void RecordUpdatedNavListPruned(base::TimeDelta delta, bool use_long_period);
419 void RecordUpdatedNavEntryCommit(base::TimeDelta delta, bool use_long_period);
420 void RecordUpdatedSaveTime(base::TimeDelta delta, bool use_long_period);
421 void RecordUpdatedSessionNavigationOrTab(base::TimeDelta delta,
422 bool use_long_period);
[email protected]4070a6b2009-11-05 23:33:55423
[email protected]97d2c1e2009-11-05 03:55:05424 // Convert back/forward between the Browser and SessionService DB window
425 // types.
426 static WindowType WindowTypeForBrowserType(Browser::Type type);
427 static Browser::Type BrowserTypeForWindowType(WindowType type);
428
[email protected]6c2381d2011-10-19 02:52:53429 content::NotificationRegistrar registrar_;
[email protected]6a02963e2009-01-06 16:58:03430
initial.commit09911bf2008-07-26 23:55:29431 // Maps from session tab id to the range of navigation entries that has
432 // been written to disk.
433 //
434 // This is only used if not all the navigation entries have been
435 // written.
436 IdToRange tab_to_available_range_;
437
[email protected]6ea265a2008-10-30 02:58:36438 // When the user closes the last window, where the last window is the
initial.commit09911bf2008-07-26 23:55:29439 // last tabbed browser and no more tabbed browsers are open with the same
440 // profile, the window ID is added here. These IDs are only committed (which
441 // marks them as closed) if the user creates a new tabbed browser.
442 typedef std::set<SessionID::id_type> PendingWindowCloseIDs;
443 PendingWindowCloseIDs pending_window_close_ids_;
444
445 // Set of tabs that have been closed by way of the last window or last tab
446 // closing, but not yet committed.
447 typedef std::set<SessionID::id_type> PendingTabCloseIDs;
448 PendingTabCloseIDs pending_tab_close_ids_;
449
450 // When a window other than the last window (see description of
451 // pending_window_close_ids) is closed, the id is added to this set.
452 typedef std::set<SessionID::id_type> WindowClosingIDs;
453 WindowClosingIDs window_closing_ids_;
454
455 // Set of windows we're tracking changes to. This is only browsers that
456 // return true from should_track_changes_for_browser_type.
457 typedef std::set<SessionID::id_type> WindowsTracking;
458 WindowsTracking windows_tracking_;
459
[email protected]982921f12009-10-27 21:43:53460 // Are there any open trackable browsers?
461 bool has_open_trackable_browsers_;
initial.commit09911bf2008-07-26 23:55:29462
[email protected]6ea265a2008-10-30 02:58:36463 // If true and a new tabbed browser is created and there are no opened tabbed
[email protected]982921f12009-10-27 21:43:53464 // browser (has_open_trackable_browsers_ is false), then the current session
[email protected]668cd422011-04-06 21:00:01465 // is made the last session. See description above class for details on
466 // current/last session.
[email protected]6ea265a2008-10-30 02:58:36467 bool move_on_new_browser_;
[email protected]169627b2008-12-06 19:30:19468
[email protected]47db9a92011-01-24 20:10:13469 // Used for reporting frequency of session altering operations.
[email protected]23da84e152010-07-14 01:29:05470 base::TimeTicks last_updated_tab_closed_time_;
471 base::TimeTicks last_updated_nav_list_pruned_time_;
472 base::TimeTicks last_updated_nav_entry_commit_time_;
473 base::TimeTicks last_updated_save_time_;
474
475 // Constants used in calculating histogram data.
476 const base::TimeDelta save_delay_in_millis_;
477 const base::TimeDelta save_delay_in_mins_;
478 const base::TimeDelta save_delay_in_hrs_;
[email protected]70eb8ed92010-06-10 18:13:12479
[email protected]c4340bc02012-04-25 02:49:38480 // For browser_tests, since we want to simulate the browser shutting down
481 // without quitting.
482 bool force_browser_not_alive_with_no_windows_;
483
[email protected]169627b2008-12-06 19:30:19484 DISALLOW_COPY_AND_ASSIGN(SessionService);
initial.commit09911bf2008-07-26 23:55:29485};
486
[email protected]169627b2008-12-06 19:30:19487#endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_