| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/history_report/delta_file_service.h" | 5 #include "chrome/browser/android/history_report/delta_file_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/android/history_report/delta_file_backend_leveldb.h" | 10 #include "chrome/browser/android/history_report/delta_file_backend_leveldb.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 worker_pool_token_, | 89 worker_pool_token_, |
| 90 FROM_HERE, | 90 FROM_HERE, |
| 91 base::Bind(&DoDeletePage, | 91 base::Bind(&DoDeletePage, |
| 92 base::Unretained(delta_file_backend_.get()), | 92 base::Unretained(delta_file_backend_.get()), |
| 93 url), | 93 url), |
| 94 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 94 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 95 } | 95 } |
| 96 | 96 |
| 97 int64_t DeltaFileService::Trim(int64_t lower_bound) { | 97 int64_t DeltaFileService::Trim(int64_t lower_bound) { |
| 98 int64_t result; | 98 int64_t result; |
| 99 base::WaitableEvent finished(false, false); | 99 base::WaitableEvent finished(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 100 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 100 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 101 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 101 pool->PostSequencedWorkerTaskWithShutdownBehavior( | 102 pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| 102 worker_pool_token_, | 103 worker_pool_token_, |
| 103 FROM_HERE, | 104 FROM_HERE, |
| 104 base::Bind(&DoTrim, | 105 base::Bind(&DoTrim, |
| 105 base::Unretained(delta_file_backend_.get()), | 106 base::Unretained(delta_file_backend_.get()), |
| 106 lower_bound, | 107 lower_bound, |
| 107 base::Unretained(&finished), | 108 base::Unretained(&finished), |
| 108 base::Unretained(&result)), | 109 base::Unretained(&result)), |
| 109 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 110 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 110 finished.Wait(); | 111 finished.Wait(); |
| 111 return result; | 112 return result; |
| 112 } | 113 } |
| 113 | 114 |
| 114 std::unique_ptr<std::vector<DeltaFileEntryWithData>> DeltaFileService::Query( | 115 std::unique_ptr<std::vector<DeltaFileEntryWithData>> DeltaFileService::Query( |
| 115 int64_t last_seq_no, | 116 int64_t last_seq_no, |
| 116 int32_t limit) { | 117 int32_t limit) { |
| 117 std::unique_ptr<std::vector<DeltaFileEntryWithData>> result; | 118 std::unique_ptr<std::vector<DeltaFileEntryWithData>> result; |
| 118 base::WaitableEvent finished(false, false); | 119 base::WaitableEvent finished(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 120 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 119 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 121 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 120 pool->PostSequencedWorkerTaskWithShutdownBehavior( | 122 pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| 121 worker_pool_token_, | 123 worker_pool_token_, |
| 122 FROM_HERE, | 124 FROM_HERE, |
| 123 base::Bind(&DoQuery, | 125 base::Bind(&DoQuery, |
| 124 base::Unretained(delta_file_backend_.get()), | 126 base::Unretained(delta_file_backend_.get()), |
| 125 last_seq_no, | 127 last_seq_no, |
| 126 limit, | 128 limit, |
| 127 base::Unretained(&finished), | 129 base::Unretained(&finished), |
| 128 base::Unretained(&result)), | 130 base::Unretained(&result)), |
| 129 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 131 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 130 finished.Wait(); | 132 finished.Wait(); |
| 131 return result; | 133 return result; |
| 132 } | 134 } |
| 133 | 135 |
| 134 bool DeltaFileService::Recreate(const std::vector<std::string>& urls) { | 136 bool DeltaFileService::Recreate(const std::vector<std::string>& urls) { |
| 135 bool result = false; | 137 bool result = false; |
| 136 base::WaitableEvent finished(false, false); | 138 base::WaitableEvent finished(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 139 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 137 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 140 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 138 pool->PostSequencedWorkerTaskWithShutdownBehavior( | 141 pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| 139 worker_pool_token_, | 142 worker_pool_token_, |
| 140 FROM_HERE, | 143 FROM_HERE, |
| 141 base::Bind(&DoRecreate, | 144 base::Bind(&DoRecreate, |
| 142 base::Unretained(delta_file_backend_.get()), | 145 base::Unretained(delta_file_backend_.get()), |
| 143 urls, | 146 urls, |
| 144 base::Unretained(&finished), | 147 base::Unretained(&finished), |
| 145 base::Unretained(&result)), | 148 base::Unretained(&result)), |
| 146 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 149 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 147 finished.Wait(); | 150 finished.Wait(); |
| 148 return result; | 151 return result; |
| 149 } | 152 } |
| 150 | 153 |
| 151 void DeltaFileService::Clear() { | 154 void DeltaFileService::Clear() { |
| 152 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 155 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 153 pool->PostSequencedWorkerTaskWithShutdownBehavior( | 156 pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| 154 worker_pool_token_, | 157 worker_pool_token_, |
| 155 FROM_HERE, | 158 FROM_HERE, |
| 156 base::Bind(&DoClear, | 159 base::Bind(&DoClear, |
| 157 base::Unretained(delta_file_backend_.get())), | 160 base::Unretained(delta_file_backend_.get())), |
| 158 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 161 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 159 } | 162 } |
| 160 | 163 |
| 161 std::string DeltaFileService::Dump() { | 164 std::string DeltaFileService::Dump() { |
| 162 std::string dump; | 165 std::string dump; |
| 163 base::WaitableEvent finished(false, false); | 166 base::WaitableEvent finished(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 167 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 164 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 168 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 165 pool->PostSequencedWorkerTaskWithShutdownBehavior( | 169 pool->PostSequencedWorkerTaskWithShutdownBehavior( |
| 166 worker_pool_token_, | 170 worker_pool_token_, |
| 167 FROM_HERE, | 171 FROM_HERE, |
| 168 base::Bind(&DoDump, | 172 base::Bind(&DoDump, |
| 169 base::Unretained(delta_file_backend_.get()), | 173 base::Unretained(delta_file_backend_.get()), |
| 170 base::Unretained(&finished), | 174 base::Unretained(&finished), |
| 171 base::Unretained(&dump)), | 175 base::Unretained(&dump)), |
| 172 base::SequencedWorkerPool::BLOCK_SHUTDOWN); | 176 base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
| 173 finished.Wait(); | 177 finished.Wait(); |
| 174 return dump; | 178 return dump; |
| 175 } | 179 } |
| 176 | 180 |
| 177 } // namespace history_report | 181 } // namespace history_report |
| OLD | NEW |