Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: components/sessions/core/session_backend.h

Issue 2600583002: Remove ScopedVector from components/sessions. (Closed)
Patch Set: include Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 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 COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_ 5 #ifndef COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_
6 #define COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_ 6 #define COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // Moves the current file to the last file, and recreates the current file. 58 // Moves the current file to the last file, and recreates the current file.
59 // 59 //
60 // NOTE: this is invoked before every command, and does nothing if we've 60 // NOTE: this is invoked before every command, and does nothing if we've
61 // already Init'ed. 61 // already Init'ed.
62 void Init(); 62 void Init();
63 bool inited() const { return inited_; } 63 bool inited() const { return inited_; }
64 64
65 // Appends the specified commands to the current file. If reset_first is 65 // Appends the specified commands to the current file. If reset_first is
66 // true the the current file is recreated. 66 // true the the current file is recreated.
67 void AppendCommands(ScopedVector<sessions::SessionCommand> commands, 67 void AppendCommands(
68 bool reset_first); 68 std::vector<std::unique_ptr<sessions::SessionCommand>> commands,
69 bool reset_first);
69 70
70 // Invoked from the service to read the commands that make up the last 71 // Invoked from the service to read the commands that make up the last
71 // session, invokes ReadLastSessionCommandsImpl to do the work. 72 // session, invokes ReadLastSessionCommandsImpl to do the work.
72 void ReadLastSessionCommands( 73 void ReadLastSessionCommands(
73 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled, 74 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled,
74 const sessions::BaseSessionService::GetCommandsCallback& callback); 75 const sessions::BaseSessionService::GetCommandsCallback& callback);
75 76
76 // Reads the commands from the last file. 77 // Reads the commands from the last file.
77 // 78 //
78 // On success, the read commands are added to commands. 79 // On success, the read commands are added to commands.
79 bool ReadLastSessionCommandsImpl( 80 bool ReadLastSessionCommandsImpl(
80 ScopedVector<sessions::SessionCommand>* commands); 81 std::vector<std::unique_ptr<sessions::SessionCommand>>* commands);
81 82
82 // Deletes the file containing the commands for the last session. 83 // Deletes the file containing the commands for the last session.
83 void DeleteLastSession(); 84 void DeleteLastSession();
84 85
85 // Moves the current session to the last and resets the current. This is 86 // Moves the current session to the last and resets the current. This is
86 // called during startup and if the user launchs the app and no tabbed 87 // called during startup and if the user launchs the app and no tabbed
87 // browsers are running. 88 // browsers are running.
88 void MoveCurrentSessionToLastSession(); 89 void MoveCurrentSessionToLastSession();
89 90
90 // Reads the commands from the current file. 91 // Reads the commands from the current file.
91 // 92 //
92 // On success, the read commands are added to commands. It is up to the 93 // On success, the read commands are added to commands. It is up to the
93 // caller to delete the commands. 94 // caller to delete the commands.
94 bool ReadCurrentSessionCommandsImpl( 95 bool ReadCurrentSessionCommandsImpl(
95 ScopedVector<sessions::SessionCommand>* commands); 96 std::vector<std::unique_ptr<sessions::SessionCommand>>* commands);
96 97
97 private: 98 private:
98 friend class base::RefCountedThreadSafe<SessionBackend>; 99 friend class base::RefCountedThreadSafe<SessionBackend>;
99 100
100 ~SessionBackend(); 101 ~SessionBackend();
101 102
102 // If current_session_file_ is open, it is truncated so that it is essentially 103 // If current_session_file_ is open, it is truncated so that it is essentially
103 // empty (only contains the header). If current_session_file_ isn't open, it 104 // empty (only contains the header). If current_session_file_ isn't open, it
104 // is is opened and the header is written to it. After this 105 // is is opened and the header is written to it. After this
105 // current_session_file_ contains no commands. 106 // current_session_file_ contains no commands.
106 // NOTE: current_session_file_ may be NULL if the file couldn't be opened or 107 // NOTE: current_session_file_ may be NULL if the file couldn't be opened or
107 // the header couldn't be written. 108 // the header couldn't be written.
108 void ResetFile(); 109 void ResetFile();
109 110
110 // Opens the current file and writes the header. On success a handle to 111 // Opens the current file and writes the header. On success a handle to
111 // the file is returned. 112 // the file is returned.
112 base::File* OpenAndWriteHeader(const base::FilePath& path); 113 base::File* OpenAndWriteHeader(const base::FilePath& path);
113 114
114 // Appends the specified commands to the specified file. 115 // Appends the specified commands to the specified file.
115 bool AppendCommandsToFile( 116 bool AppendCommandsToFile(
116 base::File* file, 117 base::File* file,
117 const ScopedVector<sessions::SessionCommand>& commands); 118 const std::vector<std::unique_ptr<sessions::SessionCommand>>& commands);
118 119
119 const sessions::BaseSessionService::SessionType type_; 120 const sessions::BaseSessionService::SessionType type_;
120 121
121 // Returns the path to the last file. 122 // Returns the path to the last file.
122 base::FilePath GetLastSessionPath(); 123 base::FilePath GetLastSessionPath();
123 124
124 // Returns the path to the current file. 125 // Returns the path to the current file.
125 base::FilePath GetCurrentSessionPath(); 126 base::FilePath GetCurrentSessionPath();
126 127
127 // Directory files are relative to. 128 // Directory files are relative to.
(...skipping 11 matching lines...) Expand all
139 140
140 // If true, the file is empty (no commands have been added to it). 141 // If true, the file is empty (no commands have been added to it).
141 bool empty_file_; 142 bool empty_file_;
142 143
143 DISALLOW_COPY_AND_ASSIGN(SessionBackend); 144 DISALLOW_COPY_AND_ASSIGN(SessionBackend);
144 }; 145 };
145 146
146 } // namespace sessions 147 } // namespace sessions
147 148
148 #endif // COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_ 149 #endif // COMPONENTS_SESSIONS_CORE_SESSION_BACKEND_H_
OLDNEW
« no previous file with comments | « components/sessions/core/persistent_tab_restore_service.cc ('k') | components/sessions/core/session_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698