OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_BASE_SESSION_SERVICE_H_ | 5 #ifndef COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ |
6 #define COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ | 6 #define COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
15 #include "components/sessions/core/sessions_export.h" | 16 #include "components/sessions/core/sessions_export.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 | 19 |
19 namespace sessions { | 20 namespace sessions { |
20 class BaseSessionServiceDelegate; | 21 class BaseSessionServiceDelegate; |
21 class SerializedNavigationEntry; | 22 class SerializedNavigationEntry; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Whether the next save resets the file before writing to it. | 63 // Whether the next save resets the file before writing to it. |
63 void set_pending_reset(bool value) { pending_reset_ = value; } | 64 void set_pending_reset(bool value) { pending_reset_ = value; } |
64 bool pending_reset() const { return pending_reset_; } | 65 bool pending_reset() const { return pending_reset_; } |
65 | 66 |
66 // Returns the number of commands sent down since the last reset. | 67 // Returns the number of commands sent down since the last reset. |
67 int commands_since_reset() const { return commands_since_reset_; } | 68 int commands_since_reset() const { return commands_since_reset_; } |
68 | 69 |
69 // Schedules a command. This adds |command| to pending_commands_ and | 70 // Schedules a command. This adds |command| to pending_commands_ and |
70 // invokes StartSaveTimer to start a timer that invokes Save at a later | 71 // invokes StartSaveTimer to start a timer that invokes Save at a later |
71 // time. | 72 // time. |
72 void ScheduleCommand(scoped_ptr<SessionCommand> command); | 73 void ScheduleCommand(std::unique_ptr<SessionCommand> command); |
73 | 74 |
74 // Appends a command as part of a general rebuild. This will neither count | 75 // Appends a command as part of a general rebuild. This will neither count |
75 // against a rebuild, nor will it trigger a save of commands. | 76 // against a rebuild, nor will it trigger a save of commands. |
76 void AppendRebuildCommand(scoped_ptr<SessionCommand> command); | 77 void AppendRebuildCommand(std::unique_ptr<SessionCommand> command); |
77 | 78 |
78 // Erase the |old_command| from the list of commands. | 79 // Erase the |old_command| from the list of commands. |
79 // The passed command will automatically be deleted. | 80 // The passed command will automatically be deleted. |
80 void EraseCommand(SessionCommand* old_command); | 81 void EraseCommand(SessionCommand* old_command); |
81 | 82 |
82 // Swap a |new_command| into the list of queued commands at the location of | 83 // Swap a |new_command| into the list of queued commands at the location of |
83 // the |old_command|. The |old_command| will be automatically deleted in the | 84 // the |old_command|. The |old_command| will be automatically deleted in the |
84 // process. | 85 // process. |
85 void SwapCommand(SessionCommand* old_command, | 86 void SwapCommand(SessionCommand* old_command, |
86 scoped_ptr<SessionCommand> new_command); | 87 std::unique_ptr<SessionCommand> new_command); |
87 | 88 |
88 // Clears all commands from the list. | 89 // Clears all commands from the list. |
89 void ClearPendingCommands(); | 90 void ClearPendingCommands(); |
90 | 91 |
91 // Starts the timer that invokes Save (if timer isn't already running). | 92 // Starts the timer that invokes Save (if timer isn't already running). |
92 void StartSaveTimer(); | 93 void StartSaveTimer(); |
93 | 94 |
94 // Passes all pending commands to the backend for saving. | 95 // Passes all pending commands to the backend for saving. |
95 void Save(); | 96 void Save(); |
96 | 97 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 // Used to invoke Save. | 130 // Used to invoke Save. |
130 base::WeakPtrFactory<BaseSessionService> weak_factory_; | 131 base::WeakPtrFactory<BaseSessionService> weak_factory_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(BaseSessionService); | 133 DISALLOW_COPY_AND_ASSIGN(BaseSessionService); |
133 }; | 134 }; |
134 | 135 |
135 } // namespace sessions | 136 } // namespace sessions |
136 | 137 |
137 #endif // COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ | 138 #endif // COMPONENTS_SESSIONS_CORE_BASE_SESSION_SERVICE_H_ |
OLD | NEW |