OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/leveldb/leveldb_mojo_proxy.h" | 5 #include "components/leveldb/leveldb_mojo_proxy.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 LevelDBMojoProxy::LockFile(OpaqueDir* dir, const std::string& path) { | 120 LevelDBMojoProxy::LockFile(OpaqueDir* dir, const std::string& path) { |
121 filesystem::FileError error = filesystem::FileError::FAILED; | 121 filesystem::FileError error = filesystem::FileError::FAILED; |
122 OpaqueLock* out_lock = nullptr; | 122 OpaqueLock* out_lock = nullptr; |
123 RunInternal(base::Bind(&LevelDBMojoProxy::LockFileImpl, this, dir, path, | 123 RunInternal(base::Bind(&LevelDBMojoProxy::LockFileImpl, this, dir, path, |
124 &error, &out_lock)); | 124 &error, &out_lock)); |
125 return std::make_pair(error, out_lock); | 125 return std::make_pair(error, out_lock); |
126 } | 126 } |
127 | 127 |
128 filesystem::FileError LevelDBMojoProxy::UnlockFile(OpaqueLock* lock) { | 128 filesystem::FileError LevelDBMojoProxy::UnlockFile(OpaqueLock* lock) { |
129 // Take ownership of the incoming lock so it gets destroyed whatever happens. | 129 // Take ownership of the incoming lock so it gets destroyed whatever happens. |
130 scoped_ptr<OpaqueLock> scoped_lock(lock); | 130 std::unique_ptr<OpaqueLock> scoped_lock(lock); |
131 filesystem::FileError error = filesystem::FileError::FAILED; | 131 filesystem::FileError error = filesystem::FileError::FAILED; |
132 RunInternal(base::Bind(&LevelDBMojoProxy::UnlockFileImpl, this, | 132 RunInternal(base::Bind(&LevelDBMojoProxy::UnlockFileImpl, this, |
133 base::Passed(&scoped_lock), &error)); | 133 base::Passed(&scoped_lock), &error)); |
134 return error; | 134 return error; |
135 } | 135 } |
136 | 136 |
137 LevelDBMojoProxy::~LevelDBMojoProxy() { | 137 LevelDBMojoProxy::~LevelDBMojoProxy() { |
138 DCHECK_EQ(0, outstanding_opaque_dirs_); | 138 DCHECK_EQ(0, outstanding_opaque_dirs_); |
139 } | 139 } |
140 | 140 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 completed = target->Lock(out_error); | 309 completed = target->Lock(out_error); |
310 DCHECK(completed); | 310 DCHECK(completed); |
311 | 311 |
312 if (*out_error == filesystem::FileError::OK) { | 312 if (*out_error == filesystem::FileError::OK) { |
313 OpaqueLock* l = new OpaqueLock; | 313 OpaqueLock* l = new OpaqueLock; |
314 l->lock_file = std::move(target); | 314 l->lock_file = std::move(target); |
315 *out_lock = l; | 315 *out_lock = l; |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 void LevelDBMojoProxy::UnlockFileImpl(scoped_ptr<OpaqueLock> lock, | 319 void LevelDBMojoProxy::UnlockFileImpl(std::unique_ptr<OpaqueLock> lock, |
320 filesystem::FileError* out_error) { | 320 filesystem::FileError* out_error) { |
321 lock->lock_file->Unlock(out_error); | 321 lock->lock_file->Unlock(out_error); |
322 } | 322 } |
323 | 323 |
324 } // namespace leveldb | 324 } // namespace leveldb |
OLD | NEW |