| 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 "base/task/cancelable_task_tracker.h" |
| 12 #include "chrome/browser/sessions/base_session_service.h" | 13 #include "chrome/browser/sessions/base_session_service.h" |
| 13 #include "chrome/browser/sessions/session_command.h" | 14 #include "chrome/browser/sessions/session_command.h" |
| 14 #include "chrome/common/cancelable_task_tracker.h" | |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class FileStream; | 17 class FileStream; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // SessionBackend ------------------------------------------------------------- | 20 // SessionBackend ------------------------------------------------------------- |
| 21 | 21 |
| 22 // SessionBackend is the backend used by BaseSessionService. It is responsible | 22 // SessionBackend is the backend used by BaseSessionService. It is responsible |
| 23 // for maintaining two files: | 23 // for maintaining two files: |
| 24 // . The current file, which is the file commands passed to AppendCommands | 24 // . The current file, which is the file commands passed to AppendCommands |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // true the the current file is recreated. | 60 // true the the current file is recreated. |
| 61 // | 61 // |
| 62 // NOTE: this deletes SessionCommands in commands as well as the supplied | 62 // NOTE: this deletes SessionCommands in commands as well as the supplied |
| 63 // vector. | 63 // vector. |
| 64 void AppendCommands(std::vector<SessionCommand*>* commands, | 64 void AppendCommands(std::vector<SessionCommand*>* commands, |
| 65 bool reset_first); | 65 bool reset_first); |
| 66 | 66 |
| 67 // Invoked from the service to read the commands that make up the last | 67 // Invoked from the service to read the commands that make up the last |
| 68 // session, invokes ReadLastSessionCommandsImpl to do the work. | 68 // session, invokes ReadLastSessionCommandsImpl to do the work. |
| 69 void ReadLastSessionCommands( | 69 void ReadLastSessionCommands( |
| 70 const CancelableTaskTracker::IsCanceledCallback& is_canceled, | 70 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled, |
| 71 const BaseSessionService::InternalGetCommandsCallback& callback); | 71 const BaseSessionService::InternalGetCommandsCallback& callback); |
| 72 | 72 |
| 73 // Reads the commands from the last file. | 73 // Reads the commands from the last file. |
| 74 // | 74 // |
| 75 // On success, the read commands are added to commands. It is up to the | 75 // On success, the read commands are added to commands. It is up to the |
| 76 // caller to delete the commands. | 76 // caller to delete the commands. |
| 77 bool ReadLastSessionCommandsImpl(std::vector<SessionCommand*>* commands); | 77 bool ReadLastSessionCommandsImpl(std::vector<SessionCommand*>* commands); |
| 78 | 78 |
| 79 // Deletes the file containing the commands for the last session. | 79 // Deletes the file containing the commands for the last session. |
| 80 void DeleteLastSession(); | 80 void DeleteLastSession(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Main thread, all others on the IO thread, hence lazy initialization. | 132 // Main thread, all others on the IO thread, hence lazy initialization. |
| 133 bool inited_; | 133 bool inited_; |
| 134 | 134 |
| 135 // If true, the file is empty (no commands have been added to it). | 135 // If true, the file is empty (no commands have been added to it). |
| 136 bool empty_file_; | 136 bool empty_file_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(SessionBackend); | 138 DISALLOW_COPY_AND_ASSIGN(SessionBackend); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ | 141 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ |
| OLD | NEW |