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

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: Created 6 years, 2 months 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
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"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 21 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_list_observer.h" 22 #include "chrome/browser/ui/browser_list_observer.h"
22 #include "components/keyed_service/core/keyed_service.h" 23 #include "components/keyed_service/core/keyed_service.h"
23 #include "components/sessions/session_id.h" 24 #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;
(...skipping 13 matching lines...) Expand all
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 maintains a set of SessionServiceCommands that allow
53 // SessionService to rebuild the open state of the browser (as SessionWindow, 54 // SessionService to 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,
63 public SessionServiceCommands {
62 friend class SessionServiceTestHelper; 64 friend class SessionServiceTestHelper;
63 public: 65 public:
64 // Used to distinguish an application window from a normal one.
65 enum AppType {
66 TYPE_APP,
67 TYPE_NORMAL
68 };
69
70 // Creates a SessionService for the specified profile. 66 // Creates a SessionService for the specified profile.
71 explicit SessionService(Profile* profile); 67 explicit SessionService(Profile* profile);
72 // For testing. 68 // For testing.
73 explicit SessionService(const base::FilePath& save_path); 69 explicit SessionService(const base::FilePath& save_path);
74 70
75 ~SessionService() override; 71 ~SessionService() override;
76 72
77 // This may be NULL during testing. 73 // This may be NULL during testing.
78 Profile* profile() const { return profile_; } 74 Profile* profile() const { return profile_; }
79 75
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void WindowClosed(const SessionID& window_id); 133 void WindowClosed(const SessionID& window_id);
138 134
139 // Called when a tab is inserted. 135 // Called when a tab is inserted.
140 void TabInserted(content::WebContents* contents); 136 void TabInserted(content::WebContents* contents);
141 137
142 // Called when a tab is closing. 138 // Called when a tab is closing.
143 void TabClosing(content::WebContents* contents); 139 void TabClosing(content::WebContents* contents);
144 140
145 // Sets the type of window. In order for the contents of a window to be 141 // 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 142 // tracked SetWindowType must be invoked with a type we track
147 // (should_track_changes_for_browser_type returns true). 143 // (ShouldTrackChangesOfWindowType returns true).
148 void SetWindowType(const SessionID& window_id, 144 void SetWindowType(const SessionID& window_id,
149 Browser::Type type, 145 Browser::Type type,
150 AppType app_type); 146 AppType app_type);
151 147
152 // Sets the application name of the specified window. 148 // Sets the application name of the specified window.
153 void SetWindowAppName(const SessionID& window_id, 149 void SetWindowAppName(const SessionID& window_id,
154 const std::string& app_name); 150 const std::string& app_name);
155 151
156 // Invoked when the NavigationController has removed entries from the back of 152 // Invoked when the NavigationController has removed entries from the back of
157 // the list. |count| gives the number of entries in the navigation controller. 153 // the list. |count| gives the number of entries in the navigation controller.
(...skipping 24 matching lines...) Expand all
182 int index); 178 int index);
183 179
184 // Sets the index of the selected tab in the specified window. 180 // Sets the index of the selected tab in the specified window.
185 void SetSelectedTabInWindow(const SessionID& window_id, int index); 181 void SetSelectedTabInWindow(const SessionID& window_id, int index);
186 182
187 // Sets the user agent override of the specified tab. 183 // Sets the user agent override of the specified tab.
188 void SetTabUserAgentOverride(const SessionID& window_id, 184 void SetTabUserAgentOverride(const SessionID& window_id,
189 const SessionID& tab_id, 185 const SessionID& tab_id,
190 const std::string& user_agent_override); 186 const std::string& user_agent_override);
191 187
192 // Callback from GetLastSession. 188 // Sets the application extension id of the specified tab.
193 // The second parameter is the id of the window that was last active. 189 void SetTabExtensionAppID(const SessionID& window_id,
194 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> 190 const SessionID& tab_id,
195 SessionCallback; 191 const std::string& extension_app_id);
196 192
197 // Fetches the contents of the last session, notifying the callback when
198 // done. If the callback is supplied an empty vector of SessionWindows
199 // it means the session could not be restored.
200 base::CancelableTaskTracker::TaskId GetLastSession(
201 const SessionCallback& callback,
202 base::CancelableTaskTracker* tracker);
203 193
194 // SessionServiceCommands:
195 bool ShouldTrackChangesOfWindowType(SessionWindow::WindowType type,
196 AppType app_type) const override;
197 void ScheduleResetCommands() override;
204 // Overridden from BaseSessionService because we want some UMA reporting on 198 // Overridden from BaseSessionService because we want some UMA reporting on
205 // session update activities. 199 // session update activities.
206 void Save() override; 200 void Save() override;
207 201
208 private: 202 private:
209 // Allow tests to access our innards for testing purposes. 203 // Allow tests to access our innards for testing purposes.
210 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation1); 204 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation1);
211 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation2); 205 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation2);
212 FRIEND_TEST_ALL_PREFIXES(NoStartupWindowTest, DontInitSessionServiceForApps); 206 FRIEND_TEST_ALL_PREFIXES(NoStartupWindowTest, DontInitSessionServiceForApps);
213 207
214 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange; 208 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 209
228 void Init(); 210 void Init();
229 211
230 // Returns true if we have scheduled any commands, or any scheduled commands 212 // Returns true if we have scheduled any commands, or any scheduled commands
231 // have been saved. 213 // have been saved.
232 bool processed_any_commands(); 214 bool processed_any_commands();
233 215
234 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need 216 // 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. 217 // to restore, the tabs are added to it, otherwise a new browser is created.
236 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open, 218 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open,
237 Browser* browser); 219 Browser* browser);
238 220
239 void Observe(int type, 221 void Observe(int type,
240 const content::NotificationSource& source, 222 const content::NotificationSource& source,
241 const content::NotificationDetails& details) override; 223 const content::NotificationDetails& details) override;
242 224
243 // chrome::BrowserListObserver 225 // chrome::BrowserListObserver
244 void OnBrowserAdded(Browser* browser) override {} 226 void OnBrowserAdded(Browser* browser) override {}
245 void OnBrowserRemoved(Browser* browser) override {} 227 void OnBrowserRemoved(Browser* browser) override {}
246 void OnBrowserSetLastActive(Browser* browser) override; 228 void OnBrowserSetLastActive(Browser* browser) override;
247 229
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.
289 void OnGotSessionCommands(const SessionCallback& callback,
290 ScopedVector<SessionCommand> commands);
291
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 230 // Adds commands to commands that will recreate the state of the specified
354 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each 231 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each
355 // direction from the current navigation index). 232 // direction from the current navigation index).
356 // A pair is added to tab_to_available_range indicating the range of 233 // A pair is added to tab_to_available_range indicating the range of
357 // indices that were written. 234 // indices that were written.
358 void BuildCommandsForTab( 235 void BuildCommandsForTab(
359 const SessionID& window_id, 236 const SessionID& window_id,
360 content::WebContents* tab, 237 content::WebContents* tab,
361 int index_in_window, 238 int index_in_window,
362 bool is_pinned, 239 bool is_pinned,
363 std::vector<SessionCommand*>* commands, 240 std::vector<SessionCommand*>* commands,
364 IdToRange* tab_to_available_range); 241 IdToRange* tab_to_available_range);
365 242
366 // Adds commands to create the specified browser, and invokes 243 // Adds commands to create the specified browser, and invokes
367 // BuildCommandsForTab for each of the tabs in the browser. This ignores 244 // BuildCommandsForTab for each of the tabs in the browser. This ignores
368 // any tabs not in the profile we were created with. 245 // any tabs not in the profile we were created with.
369 void BuildCommandsForBrowser( 246 void BuildCommandsForBrowser(
370 Browser* browser, 247 Browser* browser,
371 std::vector<SessionCommand*>* commands, 248 std::vector<SessionCommand*>* commands,
372 IdToRange* tab_to_available_range, 249 IdToRange* tab_to_available_range,
373 std::set<SessionID::id_type>* windows_to_track); 250 std::set<SessionID::id_type>* windows_to_track);
374 251
375 // Iterates over all the known browsers invoking BuildCommandsForBrowser. 252 // Iterates over all the known browsers invoking BuildCommandsForBrowser.
376 // This only adds browsers that should be tracked 253 // This only adds browsers that should be tracked
377 // (should_track_changes_for_browser_type returns true). All browsers that 254 // (ShouldTrackChangesOfWindowType returns true). All browsers that
378 // are tracked are added to windows_to_track (as long as it is non-null). 255 // are tracked are added to windows_to_track (as long as it is non-null).
379 void BuildCommandsFromBrowsers( 256 void BuildCommandsFromBrowsers(
380 std::vector<SessionCommand*>* commands, 257 std::vector<SessionCommand*>* commands,
381 IdToRange* tab_to_available_range, 258 IdToRange* tab_to_available_range,
382 std::set<SessionID::id_type>* windows_to_track); 259 std::set<SessionID::id_type>* windows_to_track);
383 260
384 // Schedules a reset. A reset means the contents of the file are recreated
385 // from the state of the browser.
386 void ScheduleReset();
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
393 // Schedules the specified command. This method takes ownership of the
394 // command.
395 void ScheduleCommand(SessionCommand* command) override;
396
397 // Converts all pending tab/window closes to commands and schedules them. 261 // Converts all pending tab/window closes to commands and schedules them.
398 void CommitPendingCloses(); 262 void CommitPendingCloses();
399 263
400 // Returns true if there is only one window open with a single tab that shares 264 // Returns true if there is only one window open with a single tab that shares
401 // our profile. 265 // our profile.
402 bool IsOnlyOneTabLeft() const; 266 bool IsOnlyOneTabLeft() const;
403 267
404 // Returns true if there are open trackable browser windows whose ids do 268 // 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 269 // match |window_id| with our profile. A trackable window is a window from
406 // which |should_track_changes_for_browser_type| returns true. See 270 // which |ShouldTrackChangesOfWindowType| returns true. See
407 // |should_track_changes_for_browser_type| for details. 271 // |ShouldTrackChangesOfWindowType| for details.
408 bool HasOpenTrackableBrowsers(const SessionID& window_id) const; 272 bool HasOpenTrackableBrowsers(const SessionID& window_id) const;
409 273
410 // Returns true if changes to tabs in the specified window should be tracked. 274 // Returns true if changes to tabs in the specified window should be tracked.
411 bool ShouldTrackChangesToWindow(const SessionID& window_id) const; 275 bool ShouldTrackChangesToWindow(const SessionID& window_id) const;
412 276
413 // Returns true if we track changes to the specified browser. 277 // Returns true if we track changes to the specified browser.
414 bool ShouldTrackBrowser(Browser* browser) const; 278 bool ShouldTrackBrowser(Browser* browser) const;
415 279
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 280 // Call when certain session relevant notifications
422 // (tab_closed, nav_list_pruned) occur. In addition, this is 281 // (tab_closed, nav_list_pruned) occur. In addition, this is
423 // currently called when Save() is called to compare how often the 282 // 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. 283 // session data is currently saved verses when we may want to save it.
425 // It records the data in UMA stats. 284 // It records the data in UMA stats.
426 void RecordSessionUpdateHistogramData(int type, 285 void RecordSessionUpdateHistogramData(int type,
427 base::TimeTicks* last_updated_time); 286 base::TimeTicks* last_updated_time);
428 287
429 // Helper methods to record the histogram data 288 // Helper methods to record the histogram data
430 void RecordUpdatedTabClosed(base::TimeDelta delta, bool use_long_period); 289 void RecordUpdatedTabClosed(base::TimeDelta delta, bool use_long_period);
431 void RecordUpdatedNavListPruned(base::TimeDelta delta, bool use_long_period); 290 void RecordUpdatedNavListPruned(base::TimeDelta delta, bool use_long_period);
432 void RecordUpdatedNavEntryCommit(base::TimeDelta delta, bool use_long_period); 291 void RecordUpdatedNavEntryCommit(base::TimeDelta delta, bool use_long_period);
433 void RecordUpdatedSaveTime(base::TimeDelta delta, bool use_long_period); 292 void RecordUpdatedSaveTime(base::TimeDelta delta, bool use_long_period);
434 void RecordUpdatedSessionNavigationOrTab(base::TimeDelta delta, 293 void RecordUpdatedSessionNavigationOrTab(base::TimeDelta delta,
435 bool use_long_period); 294 bool use_long_period);
436 295
437 // Deletes session data if no windows are open for the current profile. 296 // Deletes session data if no windows are open for the current profile.
438 void MaybeDeleteSessionOnlyData(); 297 void MaybeDeleteSessionOnlyData();
439 298
440 // Convert back/forward between the Browser and SessionService DB window 299 // Convert back/forward between the Browser and SessionService DB window
441 // types. 300 // types.
442 static WindowType WindowTypeForBrowserType(Browser::Type type); 301 static SessionWindow::WindowType WindowTypeForBrowserType(Browser::Type type);
443 static Browser::Type BrowserTypeForWindowType(WindowType type); 302 static Browser::Type BrowserTypeForWindowType(SessionWindow::WindowType type);
444 303
445 // The profile. This may be null during testing. 304 // The profile. This may be null during testing.
446 Profile* profile_; 305 Profile* profile_;
447 306
448 content::NotificationRegistrar registrar_; 307 content::NotificationRegistrar registrar_;
449 308
450 // Maps from session tab id to the range of navigation entries that has 309 // Maps from session tab id to the range of navigation entries that has
451 // been written to disk. 310 // been written to disk.
452 // 311 //
453 // This is only used if not all the navigation entries have been 312 // This is only used if not all the navigation entries have been
(...skipping 11 matching lines...) Expand all
465 // closing, but not yet committed. 324 // closing, but not yet committed.
466 typedef std::set<SessionID::id_type> PendingTabCloseIDs; 325 typedef std::set<SessionID::id_type> PendingTabCloseIDs;
467 PendingTabCloseIDs pending_tab_close_ids_; 326 PendingTabCloseIDs pending_tab_close_ids_;
468 327
469 // When a window other than the last window (see description of 328 // 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. 329 // pending_window_close_ids) is closed, the id is added to this set.
471 typedef std::set<SessionID::id_type> WindowClosingIDs; 330 typedef std::set<SessionID::id_type> WindowClosingIDs;
472 WindowClosingIDs window_closing_ids_; 331 WindowClosingIDs window_closing_ids_;
473 332
474 // Set of windows we're tracking changes to. This is only browsers that 333 // Set of windows we're tracking changes to. This is only browsers that
475 // return true from should_track_changes_for_browser_type. 334 // return true from ShouldTrackChangesOfWindowType.
476 typedef std::set<SessionID::id_type> WindowsTracking; 335 typedef std::set<SessionID::id_type> WindowsTracking;
477 WindowsTracking windows_tracking_; 336 WindowsTracking windows_tracking_;
478 337
479 // Are there any open trackable browsers? 338 // Are there any open trackable browsers?
480 bool has_open_trackable_browsers_; 339 bool has_open_trackable_browsers_;
481 340
482 // If true and a new tabbed browser is created and there are no opened tabbed 341 // 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 342 // browser (has_open_trackable_browsers_ is false), then the current session
484 // is made the last session. See description above class for details on 343 // is made the last session. See description above class for details on
485 // current/last session. 344 // current/last session.
486 bool move_on_new_browser_; 345 bool move_on_new_browser_;
487 346
488 // Used for reporting frequency of session altering operations. 347 // Used for reporting frequency of session altering operations.
489 base::TimeTicks last_updated_tab_closed_time_; 348 base::TimeTicks last_updated_tab_closed_time_;
490 base::TimeTicks last_updated_nav_list_pruned_time_; 349 base::TimeTicks last_updated_nav_list_pruned_time_;
491 base::TimeTicks last_updated_nav_entry_commit_time_; 350 base::TimeTicks last_updated_nav_entry_commit_time_;
492 base::TimeTicks last_updated_save_time_; 351 base::TimeTicks last_updated_save_time_;
493 352
494 // Constants used in calculating histogram data. 353 // Constants used in calculating histogram data.
495 const base::TimeDelta save_delay_in_millis_; 354 const base::TimeDelta save_delay_in_millis_;
496 const base::TimeDelta save_delay_in_mins_; 355 const base::TimeDelta save_delay_in_mins_;
497 const base::TimeDelta save_delay_in_hrs_; 356 const base::TimeDelta save_delay_in_hrs_;
498 357
499 // For browser_tests, since we want to simulate the browser shutting down 358 // For browser_tests, since we want to simulate the browser shutting down
500 // without quitting. 359 // without quitting.
501 bool force_browser_not_alive_with_no_windows_; 360 bool force_browser_not_alive_with_no_windows_;
502 361
503 base::WeakPtrFactory<SessionService> weak_factory_;
504
505 DISALLOW_COPY_AND_ASSIGN(SessionService); 362 DISALLOW_COPY_AND_ASSIGN(SessionService);
506 }; 363 };
507 364
508 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ 365 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698