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 |
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/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
16 #include "chrome/browser/profiles/profile_keyed_service.h" | 16 #include "chrome/browser/profiles/profile_keyed_service.h" |
17 #include "chrome/browser/sessions/base_session_service.h" | 17 #include "chrome/browser/sessions/base_session_service.h" |
18 #include "chrome/browser/sessions/session_id.h" | 18 #include "chrome/browser/sessions/session_id.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
21 #include "chrome/browser/ui/browser_list_observer.h" | 21 #include "chrome/browser/ui/browser_list_observer.h" |
22 #include "chrome/common/cancelable_task_tracker.h" | 22 #include "chrome/common/cancelable_task_tracker.h" |
23 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
25 #include "ui/base/ui_base_types.h" | 25 #include "ui/base/ui_base_types.h" |
26 | 26 |
27 class Profile; | 27 class Profile; |
28 class SessionCommand; | 28 class SessionCommand; |
29 struct SessionTab; | 29 struct SessionTab; |
30 struct SessionWindow; | 30 struct SessionWindow; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // Returns true if we should record a window close as pending. | 411 // Returns true if we should record a window close as pending. |
412 // |has_open_trackable_browsers_| must be up-to-date before calling this. | 412 // |has_open_trackable_browsers_| must be up-to-date before calling this. |
413 bool should_record_close_as_pending() const { | 413 bool should_record_close_as_pending() const { |
414 // When this is called, the browser window being closed is still open, hence | 414 // When this is called, the browser window being closed is still open, hence |
415 // still in the browser list. If there is a browser window other than the | 415 // still in the browser list. If there is a browser window other than the |
416 // one being closed but no trackable windows, then the others must be App | 416 // one being closed but no trackable windows, then the others must be App |
417 // windows or similar. In this case, we record the close as pending. | 417 // windows or similar. In this case, we record the close as pending. |
418 return !has_open_trackable_browsers_ && | 418 return !has_open_trackable_browsers_ && |
419 (!browser_defaults::kBrowserAliveWithNoWindows || | 419 (!browser_defaults::kBrowserAliveWithNoWindows || |
420 force_browser_not_alive_with_no_windows_ || | 420 force_browser_not_alive_with_no_windows_ || |
421 BrowserList::size() > 1); | 421 chrome::GetTotalBrowserCount() > 1); |
422 } | 422 } |
423 | 423 |
424 // Call when certain session relevant notifications | 424 // Call when certain session relevant notifications |
425 // (tab_closed, nav_list_pruned) occur. In addition, this is | 425 // (tab_closed, nav_list_pruned) occur. In addition, this is |
426 // currently called when Save() is called to compare how often the | 426 // currently called when Save() is called to compare how often the |
427 // session data is currently saved verses when we may want to save it. | 427 // session data is currently saved verses when we may want to save it. |
428 // It records the data in UMA stats. | 428 // It records the data in UMA stats. |
429 void RecordSessionUpdateHistogramData(int type, | 429 void RecordSessionUpdateHistogramData(int type, |
430 base::TimeTicks* last_updated_time); | 430 base::TimeTicks* last_updated_time); |
431 | 431 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const base::TimeDelta save_delay_in_hrs_; | 494 const base::TimeDelta save_delay_in_hrs_; |
495 | 495 |
496 // For browser_tests, since we want to simulate the browser shutting down | 496 // For browser_tests, since we want to simulate the browser shutting down |
497 // without quitting. | 497 // without quitting. |
498 bool force_browser_not_alive_with_no_windows_; | 498 bool force_browser_not_alive_with_no_windows_; |
499 | 499 |
500 DISALLOW_COPY_AND_ASSIGN(SessionService); | 500 DISALLOW_COPY_AND_ASSIGN(SessionService); |
501 }; | 501 }; |
502 | 502 |
503 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 503 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
OLD | NEW |