OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 5 #ifndef COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "components/sessions/session_id.h" | 11 #include "components/sessions/session_id.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class CancelableTaskTracker; | 14 class CancelableTaskTracker; |
| 15 class SequencedWorkerPool; |
15 } | 16 } |
16 | 17 |
17 namespace sessions { | 18 namespace sessions { |
18 struct SessionWindow; | 19 struct SessionWindow; |
19 } | 20 } |
20 | 21 |
21 class GURL; | 22 class GURL; |
22 | 23 |
23 namespace sessions { | 24 namespace sessions { |
24 | 25 |
25 struct SessionWindow; | 26 struct SessionWindow; |
26 | 27 |
27 // Callback from TabRestoreServiceClient::GetLastSession. | 28 // Callback from TabRestoreServiceClient::GetLastSession. |
28 // The second parameter is the id of the window that was last active. | 29 // The second parameter is the id of the window that was last active. |
29 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> | 30 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> |
30 GetLastSessionCallback; | 31 GetLastSessionCallback; |
31 | 32 |
32 // A client interface that needs to be supplied to the tab restore service by | 33 // A client interface that needs to be supplied to the tab restore service by |
33 // the embedder. | 34 // the embedder. |
34 class TabRestoreServiceClient { | 35 class TabRestoreServiceClient { |
35 public: | 36 public: |
36 virtual ~TabRestoreServiceClient() {} | 37 virtual ~TabRestoreServiceClient() {} |
37 | 38 |
| 39 // Returns whether a given URL should be tracked for restoring. |
| 40 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; |
| 41 |
| 42 // Get the sequenced worker pool for running tasks on the backend thread as |
| 43 // long as the system is not shutting down. |
| 44 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
| 45 |
38 // Returns the path of the directory to save state into. | 46 // Returns the path of the directory to save state into. |
39 virtual base::FilePath GetPathToSaveTo() = 0; | 47 virtual base::FilePath GetPathToSaveTo() = 0; |
40 | 48 |
41 // Returns the URL that corresponds to the new tab page. | 49 // Returns the URL that corresponds to the new tab page. |
42 virtual GURL GetNewTabURL() = 0; | 50 virtual GURL GetNewTabURL() = 0; |
43 | 51 |
44 // Returns whether there is a previous session to load. | 52 // Returns whether there is a previous session to load. |
45 virtual bool HasLastSession() = 0; | 53 virtual bool HasLastSession() = 0; |
46 | 54 |
47 // Fetches the contents of the last session, notifying the callback when | 55 // Fetches the contents of the last session, notifying the callback when |
48 // done. If the callback is supplied an empty vector of SessionWindows | 56 // done. If the callback is supplied an empty vector of SessionWindows |
49 // it means the session could not be restored. | 57 // it means the session could not be restored. |
50 virtual void GetLastSession(const GetLastSessionCallback& callback, | 58 virtual void GetLastSession(const GetLastSessionCallback& callback, |
51 base::CancelableTaskTracker* tracker) = 0; | 59 base::CancelableTaskTracker* tracker) = 0; |
52 | 60 |
53 // Called when a tab is restored. |url| is the URL that the tab is currently | 61 // Called when a tab is restored. |url| is the URL that the tab is currently |
54 // visiting. | 62 // visiting. |
55 virtual void OnTabRestored(const GURL& url) {} | 63 virtual void OnTabRestored(const GURL& url) {} |
56 }; | 64 }; |
57 | 65 |
58 } // namespace sessions | 66 } // namespace sessions |
59 | 67 |
60 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 68 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
OLD | NEW |