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

Unified Diff: components/sessions/core/base_session_service.cc

Issue 2600583002: Remove ScopedVector from components/sessions. (Closed)
Patch Set: include Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: components/sessions/core/base_session_service.cc
diff --git a/components/sessions/core/base_session_service.cc b/components/sessions/core/base_session_service.cc
index edc2431507c16ed56108b87220e30ad688b636b3..21726d042bd54aa9f5a117f31982919c6cc9830c 100644
--- a/components/sessions/core/base_session_service.cc
+++ b/components/sessions/core/base_session_service.cc
@@ -24,7 +24,7 @@ namespace {
void RunIfNotCanceled(
const base::CancelableTaskTracker::IsCanceledCallback& is_canceled,
const BaseSessionService::GetCommandsCallback& callback,
- ScopedVector<SessionCommand> commands) {
+ std::vector<std::unique_ptr<SessionCommand>> commands) {
if (is_canceled.Run())
return;
callback.Run(std::move(commands));
@@ -33,7 +33,7 @@ void RunIfNotCanceled(
void PostOrRunInternalGetCommandsCallback(
base::TaskRunner* task_runner,
const BaseSessionService::GetCommandsCallback& callback,
- ScopedVector<SessionCommand> commands) {
+ std::vector<std::unique_ptr<SessionCommand>> commands) {
if (task_runner->RunsTasksOnCurrentThread()) {
callback.Run(std::move(commands));
} else {
@@ -80,21 +80,22 @@ void BaseSessionService::ScheduleCommand(
std::unique_ptr<SessionCommand> command) {
DCHECK(command);
commands_since_reset_++;
- pending_commands_.push_back(command.release());
+ pending_commands_.push_back(std::move(command));
StartSaveTimer();
}
void BaseSessionService::AppendRebuildCommand(
std::unique_ptr<SessionCommand> command) {
DCHECK(command);
- pending_commands_.push_back(command.release());
+ pending_commands_.push_back(std::move(command));
}
void BaseSessionService::EraseCommand(SessionCommand* old_command) {
- ScopedVector<SessionCommand>::iterator it =
- std::find(pending_commands_.begin(),
- pending_commands_.end(),
- old_command);
+ auto it = std::find_if(
+ pending_commands_.begin(), pending_commands_.end(),
+ [old_command](const std::unique_ptr<SessionCommand>& command_ptr) {
+ return command_ptr.get() == old_command;
+ });
CHECK(it != pending_commands_.end());
pending_commands_.erase(it);
}
@@ -102,13 +103,13 @@ void BaseSessionService::EraseCommand(SessionCommand* old_command) {
void BaseSessionService::SwapCommand(
SessionCommand* old_command,
std::unique_ptr<SessionCommand> new_command) {
- ScopedVector<SessionCommand>::iterator it =
- std::find(pending_commands_.begin(),
- pending_commands_.end(),
- old_command);
+ auto it = std::find_if(
+ pending_commands_.begin(), pending_commands_.end(),
+ [old_command](const std::unique_ptr<SessionCommand>& command_ptr) {
+ return command_ptr.get() == old_command;
+ });
CHECK(it != pending_commands_.end());
- *it = new_command.release();
- delete old_command;
+ *it = std::move(new_command);
}
void BaseSessionService::ClearPendingCommands() {
@@ -134,7 +135,7 @@ void BaseSessionService::Save() {
if (pending_commands_.empty())
return;
- // We create a new ScopedVector which will receive all elements from the
+ // We create a new vector which will receive all elements from the
// current commands. This will also clear the current list.
RunTaskOnBackendThread(
FROM_HERE,
« no previous file with comments | « components/sessions/core/base_session_service.h ('k') | components/sessions/core/base_session_service_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698