| 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/env_mojo.h" | 5 #include "components/leveldb/env_mojo.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 std::string fname = my_lock ? my_lock->name() : "(invalid)"; | 352 std::string fname = my_lock ? my_lock->name() : "(invalid)"; |
| 353 TRACE_EVENT1("leveldb", "MojoEnv::UnlockFile", "fname", fname); | 353 TRACE_EVENT1("leveldb", "MojoEnv::UnlockFile", "fname", fname); |
| 354 | 354 |
| 355 filesystem::mojom::FileError err = thread_->UnlockFile(my_lock->TakeLock()); | 355 filesystem::mojom::FileError err = thread_->UnlockFile(my_lock->TakeLock()); |
| 356 delete my_lock; | 356 delete my_lock; |
| 357 return FilesystemErrorToStatus(err, fname, leveldb_env::kUnlockFile); | 357 return FilesystemErrorToStatus(err, fname, leveldb_env::kUnlockFile); |
| 358 } | 358 } |
| 359 | 359 |
| 360 Status MojoEnv::GetTestDirectory(std::string* path) { | 360 Status MojoEnv::GetTestDirectory(std::string* path) { |
| 361 // TODO(erg): This method is actually only used from the test harness in | 361 // TODO(erg): This method is actually only used from the test harness in |
| 362 // leveldb. And when we go and port that test stuff to a mojo apptest, we | 362 // leveldb. And when we go and port that test stuff to a shell::ServiceTest, |
| 363 // probably won't use it since the mojo filesystem actually handles temporary | 363 // we probably won't use it since the mojo filesystem actually handles |
| 364 // filesystems just fine. | 364 // temporary filesystems just fine. |
| 365 NOTREACHED(); | 365 NOTREACHED(); |
| 366 return Status::OK(); | 366 return Status::OK(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 Status MojoEnv::NewLogger(const std::string& fname, Logger** result) { | 369 Status MojoEnv::NewLogger(const std::string& fname, Logger** result) { |
| 370 TRACE_EVENT1("leveldb", "MojoEnv::NewLogger", "fname", fname); | 370 TRACE_EVENT1("leveldb", "MojoEnv::NewLogger", "fname", fname); |
| 371 base::File f(thread_->OpenFileHandle( | 371 base::File f(thread_->OpenFileHandle( |
| 372 dir_, mojo::String::From(fname), | 372 dir_, mojo::String::From(fname), |
| 373 filesystem::mojom::kCreateAlways | filesystem::mojom::kFlagWrite)); | 373 filesystem::mojom::kCreateAlways | filesystem::mojom::kFlagWrite)); |
| 374 if (!f.IsValid()) { | 374 if (!f.IsValid()) { |
| 375 *result = NULL; | 375 *result = NULL; |
| 376 return MakeIOError(fname, "Unable to create log file", | 376 return MakeIOError(fname, "Unable to create log file", |
| 377 leveldb_env::kNewLogger, f.error_details()); | 377 leveldb_env::kNewLogger, f.error_details()); |
| 378 } else { | 378 } else { |
| 379 *result = new leveldb::ChromiumLogger(std::move(f)); | 379 *result = new leveldb::ChromiumLogger(std::move(f)); |
| 380 return Status::OK(); | 380 return Status::OK(); |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace leveldb | 384 } // namespace leveldb |
| OLD | NEW |