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_BASE_SESSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_H_ |
6 #define CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback_old.h" | 10 #include "base/callback.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 #include "chrome/browser/sessions/session_id.h" | 15 #include "chrome/browser/sessions/session_id.h" |
15 #include "content/browser/cancelable_request.h" | 16 #include "content/browser/cancelable_request.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 | 18 |
18 class NavigationEntry; | 19 class NavigationEntry; |
19 class Profile; | 20 class Profile; |
20 class SessionBackend; | 21 class SessionBackend; |
21 class SessionCommand; | 22 class SessionCommand; |
22 class TabNavigation; | 23 class TabNavigation; |
(...skipping 25 matching lines...) Expand all Loading... |
48 Profile* profile, | 49 Profile* profile, |
49 const FilePath& path); | 50 const FilePath& path); |
50 | 51 |
51 Profile* profile() const { return profile_; } | 52 Profile* profile() const { return profile_; } |
52 | 53 |
53 // Deletes the last session. | 54 // Deletes the last session. |
54 void DeleteLastSession(); | 55 void DeleteLastSession(); |
55 | 56 |
56 class InternalGetCommandsRequest; | 57 class InternalGetCommandsRequest; |
57 | 58 |
58 typedef Callback2<Handle, scoped_refptr<InternalGetCommandsRequest> >::Type | 59 typedef base::Callback<void(Handle, |
| 60 scoped_refptr<InternalGetCommandsRequest>)> |
59 InternalGetCommandsCallback; | 61 InternalGetCommandsCallback; |
60 | 62 |
61 // Callback used when fetching the last session. The last session consists | 63 // Callback used when fetching the last session. The last session consists |
62 // of a vector of SessionCommands. | 64 // of a vector of SessionCommands. |
63 class InternalGetCommandsRequest : | 65 class InternalGetCommandsRequest : |
64 public CancelableRequest<InternalGetCommandsCallback> { | 66 public CancelableRequest<InternalGetCommandsCallback> { |
65 public: | 67 public: |
66 explicit InternalGetCommandsRequest(CallbackType* callback) | 68 explicit InternalGetCommandsRequest(const CallbackType& callback) |
67 : CancelableRequest<InternalGetCommandsCallback>(callback) { | 69 : CancelableRequest<InternalGetCommandsCallback>(callback) { |
68 } | 70 } |
69 | 71 |
70 // The commands. The backend fills this in for us. | 72 // The commands. The backend fills this in for us. |
71 std::vector<SessionCommand*> commands; | 73 std::vector<SessionCommand*> commands; |
72 | 74 |
73 protected: | 75 protected: |
74 virtual ~InternalGetCommandsRequest(); | 76 virtual ~InternalGetCommandsRequest(); |
75 | 77 |
76 private: | 78 private: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Path to read from. This is only used if profile_ is NULL. | 167 // Path to read from. This is only used if profile_ is NULL. |
166 const FilePath& path_; | 168 const FilePath& path_; |
167 | 169 |
168 // The backend. | 170 // The backend. |
169 scoped_refptr<SessionBackend> backend_; | 171 scoped_refptr<SessionBackend> backend_; |
170 | 172 |
171 // Thread backend tasks are run on, is NULL during testing. | 173 // Thread backend tasks are run on, is NULL during testing. |
172 base::Thread* backend_thread_; | 174 base::Thread* backend_thread_; |
173 | 175 |
174 // Used to invoke Save. | 176 // Used to invoke Save. |
175 ScopedRunnableMethodFactory<BaseSessionService> save_factory_; | 177 base::WeakPtrFactory<BaseSessionService> weak_factory_; |
176 | 178 |
177 // Commands we need to send over to the backend. | 179 // Commands we need to send over to the backend. |
178 std::vector<SessionCommand*> pending_commands_; | 180 std::vector<SessionCommand*> pending_commands_; |
179 | 181 |
180 // Whether the backend file should be recreated the next time we send | 182 // Whether the backend file should be recreated the next time we send |
181 // over the commands. | 183 // over the commands. |
182 bool pending_reset_; | 184 bool pending_reset_; |
183 | 185 |
184 // The number of commands sent to the backend before doing a reset. | 186 // The number of commands sent to the backend before doing a reset. |
185 int commands_since_reset_; | 187 int commands_since_reset_; |
186 | 188 |
187 DISALLOW_COPY_AND_ASSIGN(BaseSessionService); | 189 DISALLOW_COPY_AND_ASSIGN(BaseSessionService); |
188 }; | 190 }; |
189 | 191 |
190 #endif // CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_H_ | 192 #endif // CHROME_BROWSER_SESSIONS_BASE_SESSION_SERVICE_H_ |
OLD | NEW |