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

Side by Side Diff: components/leveldb/leveldb_mojo_proxy.cc

Issue 1995753002: [mojo-edk] Expose portable API for platform handle wrapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 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 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"
11 #include "mojo/platform_handle/platform_handle_functions.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "mojo/public/cpp/system/platform_handle.h"
13 13
14 namespace leveldb { 14 namespace leveldb {
15 15
16 struct LevelDBMojoProxy::OpaqueLock { 16 struct LevelDBMojoProxy::OpaqueLock {
17 filesystem::mojom::FilePtr lock_file; 17 filesystem::mojom::FilePtr lock_file;
18 }; 18 };
19 19
20 struct LevelDBMojoProxy::OpaqueDir { 20 struct LevelDBMojoProxy::OpaqueDir {
21 explicit OpaqueDir( 21 explicit OpaqueDir(
22 mojo::InterfacePtrInfo<filesystem::mojom::Directory> directory_info) { 22 mojo::InterfacePtrInfo<filesystem::mojom::Directory> directory_info) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 base::File* output_file) { 182 base::File* output_file) {
183 mojo::ScopedHandle handle; 183 mojo::ScopedHandle handle;
184 filesystem::mojom::FileError error = filesystem::mojom::FileError::FAILED; 184 filesystem::mojom::FileError error = filesystem::mojom::FileError::FAILED;
185 bool completed = dir->directory->OpenFileHandle(mojo::String::From(name), 185 bool completed = dir->directory->OpenFileHandle(mojo::String::From(name),
186 open_flags, &error, &handle); 186 open_flags, &error, &handle);
187 DCHECK(completed); 187 DCHECK(completed);
188 188
189 if (error != filesystem::mojom::FileError::OK) { 189 if (error != filesystem::mojom::FileError::OK) {
190 *output_file = base::File(static_cast<base::File::Error>(error)); 190 *output_file = base::File(static_cast<base::File::Error>(error));
191 } else { 191 } else {
192 MojoPlatformHandle platform_handle; 192 base::PlatformFile platform_file;
193 MojoResult extract_result = 193 MojoResult unwrap_result = mojo::UnwrapPlatformFile(std::move(handle),
194 MojoExtractPlatformHandle(handle.release().value(), &platform_handle); 194 &platform_file);
195 195 if (unwrap_result == MOJO_RESULT_OK) {
196 if (extract_result == MOJO_RESULT_OK) { 196 *output_file = base::File(platform_file);
197 *output_file = base::File(platform_handle);
198 } else { 197 } else {
199 NOTREACHED(); 198 NOTREACHED();
200 *output_file = base::File(base::File::Error::FILE_ERROR_FAILED); 199 *output_file = base::File(base::File::Error::FILE_ERROR_FAILED);
201 } 200 }
202 } 201 }
203 } 202 }
204 203
205 void LevelDBMojoProxy::SyncDirectoryImpl( 204 void LevelDBMojoProxy::SyncDirectoryImpl(
206 OpaqueDir* dir, 205 OpaqueDir* dir,
207 std::string name, 206 std::string name,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 *out_lock = l; 320 *out_lock = l;
322 } 321 }
323 } 322 }
324 323
325 void LevelDBMojoProxy::UnlockFileImpl(std::unique_ptr<OpaqueLock> lock, 324 void LevelDBMojoProxy::UnlockFileImpl(std::unique_ptr<OpaqueLock> lock,
326 filesystem::mojom::FileError* out_error) { 325 filesystem::mojom::FileError* out_error) {
327 lock->lock_file->Unlock(out_error); 326 lock->lock_file->Unlock(out_error);
328 } 327 }
329 328
330 } // namespace leveldb 329 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/font_service/public/cpp/font_service_thread.cc ('k') | components/mus/gles2/command_buffer_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698