OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "chrome/browser/sessions/base_session_service.h" | 13 #include "chrome/browser/sessions/base_session_service.h" |
14 #include "chrome/browser/sessions/session_command.h" | 14 #include "chrome/browser/sessions/session_command.h" |
15 #include "net/base/file_stream.h" | 15 |
| 16 namespace net { |
| 17 class FileStream; |
| 18 } |
16 | 19 |
17 // SessionBackend ------------------------------------------------------------- | 20 // SessionBackend ------------------------------------------------------------- |
18 | 21 |
19 // SessionBackend is the backend used by BaseSessionService. It is responsible | 22 // SessionBackend is the backend used by BaseSessionService. It is responsible |
20 // for maintaining two files: | 23 // for maintaining two files: |
21 // . The current file, which is the file commands passed to AppendCommands | 24 // . The current file, which is the file commands passed to AppendCommands |
22 // get written to. | 25 // get written to. |
23 // . The last file. When created the current file is moved to the last | 26 // . The last file. When created the current file is moved to the last |
24 // file. | 27 // file. |
25 // | 28 // |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 89 |
87 // Reads the commands from the current file. | 90 // Reads the commands from the current file. |
88 // | 91 // |
89 // On success, the read commands are added to commands. It is up to the | 92 // On success, the read commands are added to commands. It is up to the |
90 // caller to delete the commands. | 93 // caller to delete the commands. |
91 bool ReadCurrentSessionCommandsImpl(std::vector<SessionCommand*>* commands); | 94 bool ReadCurrentSessionCommandsImpl(std::vector<SessionCommand*>* commands); |
92 | 95 |
93 private: | 96 private: |
94 friend class base::RefCountedThreadSafe<SessionBackend>; | 97 friend class base::RefCountedThreadSafe<SessionBackend>; |
95 | 98 |
96 ~SessionBackend() {} | 99 ~SessionBackend(); |
97 | 100 |
98 // If current_session_file_ is open, it is truncated so that it is essentially | 101 // If current_session_file_ is open, it is truncated so that it is essentially |
99 // empty (only contains the header). If current_session_file_ isn't open, it | 102 // empty (only contains the header). If current_session_file_ isn't open, it |
100 // is is opened and the header is written to it. After this | 103 // is is opened and the header is written to it. After this |
101 // current_session_file_ contains no commands. | 104 // current_session_file_ contains no commands. |
102 // NOTE: current_session_file_ may be NULL if the file couldn't be opened or | 105 // NOTE: current_session_file_ may be NULL if the file couldn't be opened or |
103 // the header couldn't be written. | 106 // the header couldn't be written. |
104 void ResetFile(); | 107 void ResetFile(); |
105 | 108 |
106 // Opens the current file and writes the header. On success a handle to | 109 // Opens the current file and writes the header. On success a handle to |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Main thread, all others on the IO thread, hence lazy initialization. | 142 // Main thread, all others on the IO thread, hence lazy initialization. |
140 bool inited_; | 143 bool inited_; |
141 | 144 |
142 // If true, the file is empty (no commands have been added to it). | 145 // If true, the file is empty (no commands have been added to it). |
143 bool empty_file_; | 146 bool empty_file_; |
144 | 147 |
145 DISALLOW_COPY_AND_ASSIGN(SessionBackend); | 148 DISALLOW_COPY_AND_ASSIGN(SessionBackend); |
146 }; | 149 }; |
147 | 150 |
148 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ | 151 #endif // CHROME_BROWSER_SESSIONS_SESSION_BACKEND_H_ |
OLD | NEW |