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

Side by Side Diff: third_party/leveldatabase/env_chromium_stdio.cc

Issue 416633002: Cleanup Chrome's LevelDB env to conform to C++ style guidelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 (c) 2011-2013 The LevelDB Authors. All rights reserved. 1 // Copyright (c) 2011-2013 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_stdio.h"
6
7 #if defined(OS_POSIX)
8 #include <dirent.h>
5 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h>
11 #include <sys/resource.h>
12 #include <sys/stat.h>
13 #include <sys/types.h>
14 #endif
15
16 #if defined(OS_WIN)
17 #include <io.h>
18 #endif
6 19
7 #include "base/debug/trace_event.h" 20 #include "base/debug/trace_event.h"
8 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
9 #include "base/posix/eintr_wrapper.h" 22 #include "base/posix/eintr_wrapper.h"
10 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
11 #include "chromium_logger.h" 24 #include "third_party/leveldatabase/chromium_logger.h"
12 #include "env_chromium_stdio.h"
13 25
14 #if defined(OS_WIN) 26 #if defined(OS_WIN)
15 #include <io.h>
16 #include "base/win/win_util.h" 27 #include "base/win/win_util.h"
17 #endif 28 #endif
18 29
19 #if defined(OS_POSIX) 30 using leveldb::ChromiumLogger;
20 #include <dirent.h> 31 using leveldb::Logger;
21 #include <fcntl.h> 32 using leveldb::RandomAccessFile;
22 #include <sys/resource.h> 33 using leveldb::SequentialFile;
23 #endif 34 using leveldb::Slice;
24 35 using leveldb::Status;
25 using namespace leveldb; 36 using leveldb::WritableFile;
26 37
27 namespace leveldb_env { 38 namespace leveldb_env {
28 39
29 namespace { 40 namespace {
30 41
31 #if (defined(OS_POSIX) && !defined(OS_LINUX)) || defined(OS_WIN) 42 #if (defined(OS_POSIX) && !defined(OS_LINUX)) || defined(OS_WIN)
32 // The following are glibc-specific 43 // The following are glibc-specific
33 44
34 size_t fread_unlocked(void* ptr, size_t size, size_t n, FILE* file) { 45 size_t fread_unlocked(void* ptr, size_t size, size_t n, FILE* file) {
35 return fread(ptr, size, n, file); 46 return fread(ptr, size, n, file);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 int parent_fd = HANDLE_EINTR(open(parent_dir_.c_str(), O_RDONLY)); 180 int parent_fd = HANDLE_EINTR(open(parent_dir_.c_str(), O_RDONLY));
170 if (parent_fd < 0) { 181 if (parent_fd < 0) {
171 int saved_errno = errno; 182 int saved_errno = errno;
172 return MakeIOError( 183 return MakeIOError(
173 parent_dir_, strerror(saved_errno), kSyncParent, saved_errno); 184 parent_dir_, strerror(saved_errno), kSyncParent, saved_errno);
174 } 185 }
175 if (HANDLE_EINTR(fsync(parent_fd)) != 0) { 186 if (HANDLE_EINTR(fsync(parent_fd)) != 0) {
176 int saved_errno = errno; 187 int saved_errno = errno;
177 s = MakeIOError( 188 s = MakeIOError(
178 parent_dir_, strerror(saved_errno), kSyncParent, saved_errno); 189 parent_dir_, strerror(saved_errno), kSyncParent, saved_errno);
179 }; 190 }
180 close(parent_fd); 191 close(parent_fd);
181 #endif 192 #endif
182 return s; 193 return s;
183 } 194 }
184 195
185 Status ChromiumWritableFile::Append(const Slice& data) { 196 Status ChromiumWritableFile::Append(const Slice& data) {
186 if (file_type_ == kManifest && tracker_->DoesDirNeedSync(filename_)) { 197 if (file_type_ == kManifest && tracker_->DoesDirNeedSync(filename_)) {
187 Status s = SyncParent(); 198 Status s = SyncParent();
188 if (!s.ok()) 199 if (!s.ok())
189 return s; 200 return s;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 int saved_errno = errno; 380 int saved_errno = errno;
370 RecordOSError(kNewLogger, saved_errno); 381 RecordOSError(kNewLogger, saved_errno);
371 return MakeIOError(fname, strerror(saved_errno), kNewLogger, saved_errno); 382 return MakeIOError(fname, strerror(saved_errno), kNewLogger, saved_errno);
372 } else { 383 } else {
373 *result = new ChromiumLogger(f); 384 *result = new ChromiumLogger(f);
374 return Status::OK(); 385 return Status::OK();
375 } 386 }
376 } 387 }
377 388
378 } // namespace leveldb_env 389 } // namespace leveldb_env
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698