| 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 |
| 901 uint64_t ChromiumEnv::NowMicros() { | 917 uint64_t ChromiumEnv::NowMicros() { |
| 902 return base::TimeTicks::Now().ToInternalValue(); | 918 return base::TimeTicks::Now().ToInternalValue(); |
| 903 } | 919 } |
| 904 | 920 |
| 905 void ChromiumEnv::SleepForMicroseconds(int micros) { | 921 void ChromiumEnv::SleepForMicroseconds(int micros) { |
| 906 // Round up to the next millisecond. | 922 // Round up to the next millisecond. |
| 907 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); | 923 base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(micros)); |
| 908 } | 924 } |
| 909 | 925 |
| 910 void ChromiumEnv::RecordErrorAt(MethodID method) const { | 926 void ChromiumEnv::RecordErrorAt(MethodID method) const { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 | 1100 |
| 1085 Env* IDBEnv() { | 1101 Env* IDBEnv() { |
| 1086 return leveldb_env::idb_env.Pointer(); | 1102 return leveldb_env::idb_env.Pointer(); |
| 1087 } | 1103 } |
| 1088 | 1104 |
| 1089 Env* Env::Default() { | 1105 Env* Env::Default() { |
| 1090 return leveldb_env::default_env.Pointer(); | 1106 return leveldb_env::default_env.Pointer(); |
| 1091 } | 1107 } |
| 1092 | 1108 |
| 1093 } // namespace leveldb | 1109 } // namespace leveldb |
| OLD | NEW |