OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/sessions/base_session_service.h" | 12 #include "chrome/browser/sessions/base_session_service.h" |
13 #include "chrome/browser/sessions/session_command.h" | 13 #include "chrome/browser/sessions/session_command.h" |
| 14 #include "chrome/common/cancelable_task_tracker.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class FileStream; | 17 class FileStream; |
17 } | 18 } |
18 | 19 |
19 // SessionBackend ------------------------------------------------------------- | 20 // SessionBackend ------------------------------------------------------------- |
20 | 21 |
21 // SessionBackend is the backend used by BaseSessionService. It is responsible | 22 // SessionBackend is the backend used by BaseSessionService. It is responsible |
22 // for maintaining two files: | 23 // for maintaining two files: |
23 // . The current file, which is the file commands passed to AppendCommands | 24 // . The current file, which is the file commands passed to AppendCommands |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // true the the current file is recreated. | 59 // true the the current file is recreated. |
59 // | 60 // |
60 // NOTE: this deletes SessionCommands in commands as well as the supplied | 61 // NOTE: this deletes SessionCommands in commands as well as the supplied |
61 // vector. | 62 // vector. |
62 void AppendCommands(std::vector<SessionCommand*>* commands, | 63 void AppendCommands(std::vector<SessionCommand*>* commands, |
63 bool reset_first); | 64 bool reset_first); |
64 | 65 |
65 // Invoked from the service to read the commands that make up the last | 66 // Invoked from the service to read the commands that make up the last |
66 // session, invokes ReadLastSessionCommandsImpl to do the work. | 67 // session, invokes ReadLastSessionCommandsImpl to do the work. |
67 void ReadLastSessionCommands( | 68 void ReadLastSessionCommands( |
68 scoped_refptr<BaseSessionService::InternalGetCommandsRequest> request); | 69 const CancelableTaskTracker::IsCanceledCallback& is_canceled, |
| 70 const BaseSessionService::InternalGetCommandsCallback& callback); |
69 | 71 |
70 // Reads the commands from the last file. | 72 // Reads the commands from the last file. |
71 // | 73 // |
72 // On success, the read commands are added to commands. It is up to the | 74 // On success, the read commands are added to commands. It is up to the |
73 // caller to delete the commands. | 75 // caller to delete the commands. |
74 bool ReadLastSessionCommandsImpl(std::vector<SessionCommand*>* commands); | 76 bool ReadLastSessionCommandsImpl(std::vector<SessionCommand*>* commands); |
75 | 77 |
76 // Deletes the file containing the commands for the last session. | 78 // Deletes the file containing the commands for the last session. |
77 void DeleteLastSession(); | 79 void DeleteLastSession(); |
78 | 80 |
79 // Moves the current session to the last and resets the current. This is | 81 // Moves the current session to the last and resets the current. This is |
80 // called during startup and if the user launchs the app and no tabbed | 82 // called during startup and if the user launchs the app and no tabbed |
81 // browsers are running. | 83 // browsers are running. |
82 void MoveCurrentSessionToLastSession(); | 84 void MoveCurrentSessionToLastSession(); |
83 | 85 |
84 // Invoked from the service to read the commands that make up the current | |
85 // session, invokes ReadCurrentSessionCommandsImpl to do the work. | |
86 void ReadCurrentSessionCommands( | |
87 scoped_refptr<BaseSessionService::InternalGetCommandsRequest> request); | |
88 | |
89 // Reads the commands from the current file. | 86 // Reads the commands from the current file. |
90 // | 87 // |
91 // On success, the read commands are added to commands. It is up to the | 88 // On success, the read commands are added to commands. It is up to the |
92 // caller to delete the commands. | 89 // caller to delete the commands. |
93 bool ReadCurrentSessionCommandsImpl(std::vector<SessionCommand*>* commands); | 90 bool ReadCurrentSessionCommandsImpl(std::vector<SessionCommand*>* commands); |
94 | 91 |
95 private: | 92 private: |
96 friend class base::RefCountedThreadSafe<SessionBackend>; | 93 friend class base::RefCountedThreadSafe<SessionBackend>; |
97 | 94 |
98 ~SessionBackend(); | 95 ~SessionBackend(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Main thread, all others on the IO thread, hence lazy initialization. | 131 // Main thread, all others on the IO thread, hence lazy initialization. |
135 bool inited_; | 132 bool inited_; |
136 | 133 |
137 // If true, the file is empty (no commands have been added to it). | 134 // If true, the file is empty (no commands have been added to it). |
138 bool empty_file_; | 135 bool empty_file_; |
139 | 136 |
140 DISALLOW_COPY_AND_ASSIGN(SessionBackend); | 137 DISALLOW_COPY_AND_ASSIGN(SessionBackend); |
141 }; | 138 }; |
142 | 139 |
143 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ | 140 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ |
OLD | NEW |