| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "chrome/browser/sessions/base_session_service_delegate.h" | 9 #include "chrome/browser/sessions/base_session_service_delegate.h" |
| 10 #include "chrome/browser/sessions/session_backend.h" | 10 #include "chrome/browser/sessions/session_backend.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 base::TimeDelta::FromMilliseconds(kSaveDelayMS)); | 84 base::TimeDelta::FromMilliseconds(kSaveDelayMS)); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BaseSessionService::Save() { | 88 void BaseSessionService::Save() { |
| 89 DCHECK(backend()); | 89 DCHECK(backend()); |
| 90 | 90 |
| 91 if (pending_commands_.empty()) | 91 if (pending_commands_.empty()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 // We create a new ScopedVector which will receive all elements from the | |
| 95 // current commands. This will also clear the current list. | |
| 96 RunTaskOnBackendThread( | 94 RunTaskOnBackendThread( |
| 97 FROM_HERE, | 95 FROM_HERE, |
| 98 base::Bind(&SessionBackend::AppendCommands, backend(), | 96 base::Bind(&SessionBackend::AppendCommands, backend(), |
| 99 new ScopedVector<SessionCommand>(pending_commands_.Pass()), | 97 base::Passed(&pending_commands_), |
| 100 pending_reset_)); | 98 pending_reset_)); |
| 101 | 99 |
| 102 if (pending_reset_) { | 100 if (pending_reset_) { |
| 103 commands_since_reset_ = 0; | 101 commands_since_reset_ = 0; |
| 104 pending_reset_ = false; | 102 pending_reset_ = false; |
| 105 } | 103 } |
| 106 } | 104 } |
| 107 | 105 |
| 108 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { | 106 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { |
| 109 return url.is_valid() && delegate_->ShouldTrackEntry(url); | 107 return url.is_valid() && delegate_->ShouldTrackEntry(url); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 base::SequencedWorkerPool* pool = delegate_->GetBlockingPool(); | 135 base::SequencedWorkerPool* pool = delegate_->GetBlockingPool(); |
| 138 if (!pool->IsShutdownInProgress()) { | 136 if (!pool->IsShutdownInProgress()) { |
| 139 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); | 137 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); |
| 140 } else { | 138 } else { |
| 141 // Fall back to executing on the main thread if the sequence | 139 // Fall back to executing on the main thread if the sequence |
| 142 // worker pool has been requested to shutdown (around shutdown | 140 // worker pool has been requested to shutdown (around shutdown |
| 143 // time). | 141 // time). |
| 144 task.Run(); | 142 task.Run(); |
| 145 } | 143 } |
| 146 } | 144 } |
| OLD | NEW |