| 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 RecordErrorAt(kNewWritableFile); | 891 RecordErrorAt(kNewWritableFile); |
| 892 return MakeIOError(fname, "Unable to create writable file", | 892 return MakeIOError(fname, "Unable to create writable file", |
| 893 kNewWritableFile, f->error_details()); | 893 kNewWritableFile, f->error_details()); |
| 894 } else { | 894 } else { |
| 895 *result = | 895 *result = |
| 896 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); | 896 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); |
| 897 return Status::OK(); | 897 return Status::OK(); |
| 898 } | 898 } |
| 899 } | 899 } |
| 900 | 900 |
| 901 Status ChromiumEnv::NewAppendableFile(const std::string& fname, | |
| 902 leveldb::WritableFile** result) { | |
| 903 *result = NULL; | |
| 904 FilePath path = FilePath::FromUTF8Unsafe(fname); | |
| 905 scoped_ptr<base::File> f(new base::File( | |
| 906 path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND)); | |
| 907 if (!f->IsValid()) { | |
| 908 RecordErrorAt(kNewAppendableFile); | |
| 909 return MakeIOError(fname, "Unable to create appendable file", | |
| 910 kNewAppendableFile, f->error_details()); | |
| 911 } | |
| 912 *result = | |
| 913 new ChromiumWritableFile(fname, f.release(), this, this, make_backup_); | |
| 914 return Status::OK(); | |
| 915 } | |
| 916 | |
| 917 uint64_t ChromiumEnv::NowMicros() { | 901 uint64_t ChromiumEnv::NowMicros() { |
| 918 return base::TimeTicks::Now().ToInternalValue(); | 902 return base::TimeTicks::Now().ToInternalValue(); |
| 919 } | 903 } |
| 920 | 904 |
| 921 void ChromiumEnv::SleepForMicroseconds(int micros) { | 905 void ChromiumEnv::SleepForMicroseconds(int micros) { |
| 922 // Round up to the next millisecond. | 906 // Round up to the next millisecond. |
| 923 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); | 907 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); |
| 924 } | 908 } |
| 925 | 909 |
| 926 void ChromiumEnv::RecordErrorAt(MethodID method) const { | 910 void ChromiumEnv::RecordErrorAt(MethodID method) const { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1084 |
| 1101 Env* IDBEnv() { | 1085 Env* IDBEnv() { |
| 1102 return leveldb_env::idb_env.Pointer(); | 1086 return leveldb_env::idb_env.Pointer(); |
| 1103 } | 1087 } |
| 1104 | 1088 |
| 1105 Env* Env::Default() { | 1089 Env* Env::Default() { |
| 1106 return leveldb_env::default_env.Pointer(); | 1090 return leveldb_env::default_env.Pointer(); |
| 1107 } | 1091 } |
| 1108 | 1092 |
| 1109 } // namespace leveldb | 1093 } // namespace leveldb |
| OLD | NEW |