Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2011 The LevelDB 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. See the AUTHORS file for names of contributors. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
| 4 | 4 |
| 5 #include "third_party/leveldatabase/env_chromium.h" | 5 #include "third_party/leveldatabase/env_chromium.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <dirent.h> | 8 #include <dirent.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #endif | 10 #endif |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 case kWritableFileFlush: | 351 case kWritableFileFlush: |
| 352 return "WritableFileFlush"; | 352 return "WritableFileFlush"; |
| 353 case kWritableFileSync: | 353 case kWritableFileSync: |
| 354 return "WritableFileSync"; | 354 return "WritableFileSync"; |
| 355 case kNewSequentialFile: | 355 case kNewSequentialFile: |
| 356 return "NewSequentialFile"; | 356 return "NewSequentialFile"; |
| 357 case kNewRandomAccessFile: | 357 case kNewRandomAccessFile: |
| 358 return "NewRandomAccessFile"; | 358 return "NewRandomAccessFile"; |
| 359 case kNewWritableFile: | 359 case kNewWritableFile: |
| 360 return "NewWritableFile"; | 360 return "NewWritableFile"; |
| 361 case kNewAppendableFile: | |
| 362 return "NewAppendableFile"; | |
| 361 case kDeleteFile: | 363 case kDeleteFile: |
| 362 return "DeleteFile"; | 364 return "DeleteFile"; |
| 363 case kCreateDir: | 365 case kCreateDir: |
| 364 return "CreateDir"; | 366 return "CreateDir"; |
| 365 case kDeleteDir: | 367 case kDeleteDir: |
| 366 return "DeleteDir"; | 368 return "DeleteDir"; |
| 367 case kGetFileSize: | 369 case kGetFileSize: |
| 368 return "GetFileSize"; | 370 return "GetFileSize"; |
| 369 case kRenameFile: | 371 case kRenameFile: |
| 370 return "RenameFile"; | 372 return "RenameFile"; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 RecordErrorAt(kNewWritableFile); | 895 RecordErrorAt(kNewWritableFile); |
| 894 return MakeIOError(fname, "Unable to create writable file", | 896 return MakeIOError(fname, "Unable to create writable file", |
| 895 kNewWritableFile, f->error_details()); | 897 kNewWritableFile, f->error_details()); |
| 896 } else { | 898 } else { |
| 897 *result = | 899 *result = |
| 898 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); | 900 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); |
| 899 return Status::OK(); | 901 return Status::OK(); |
| 900 } | 902 } |
| 901 } | 903 } |
| 902 | 904 |
| 905 Status ChromiumEnv::NewAppendableFile(const std::string& fname, | |
| 906 leveldb::WritableFile** result) { | |
| 907 *result = NULL; | |
| 908 FilePath path = FilePath::FromUTF8Unsafe(fname); | |
| 909 scoped_ptr<base::File> f(new base::File( | |
| 910 path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND)); | |
| 911 if (!f->IsValid()) { | |
| 912 RecordErrorAt(kNewAppendableFile); | |
| 913 return MakeIOError(fname, "Unable to create appendable file", | |
| 914 kNewAppendableFile, f->error_details()); | |
| 915 } else { | |
|
jsbell
2014/12/15 17:41:23
No need for else block, since previous returns.
(
cmumford
2014/12/15 18:08:36
Done.
| |
| 916 *result = | |
| 917 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); | |
| 918 return Status::OK(); | |
| 919 } | |
| 920 } | |
| 921 | |
| 903 uint64_t ChromiumEnv::NowMicros() { | 922 uint64_t ChromiumEnv::NowMicros() { |
| 904 return base::TimeTicks::Now().ToInternalValue(); | 923 return base::TimeTicks::Now().ToInternalValue(); |
| 905 } | 924 } |
| 906 | 925 |
| 907 void ChromiumEnv::SleepForMicroseconds(int micros) { | 926 void ChromiumEnv::SleepForMicroseconds(int micros) { |
| 908 // Round up to the next millisecond. | 927 // Round up to the next millisecond. |
| 909 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); | 928 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); |
| 910 } | 929 } |
| 911 | 930 |
| 912 void ChromiumEnv::RecordErrorAt(MethodID method) const { | 931 void ChromiumEnv::RecordErrorAt(MethodID method) const { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 | 1105 |
| 1087 Env* IDBEnv() { | 1106 Env* IDBEnv() { |
| 1088 return leveldb_env::idb_env.Pointer(); | 1107 return leveldb_env::idb_env.Pointer(); |
| 1089 } | 1108 } |
| 1090 | 1109 |
| 1091 Env* Env::Default() { | 1110 Env* Env::Default() { |
| 1092 return leveldb_env::default_env.Pointer(); | 1111 return leveldb_env::default_env.Pointer(); |
| 1093 } | 1112 } |
| 1094 | 1113 |
| 1095 } // namespace leveldb | 1114 } // namespace leveldb |
| OLD | NEW |