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

Side by Side Diff: third_party/leveldatabase/port/port_chromium.h

Issue 7522008: Move chromium-specific files from leveldb to chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile error, roll leveldb Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
4 //
5 // See port_example.h for documentation for the following types/functions.
6
7 #ifndef STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
8 #define STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
9
10 #include <stdint.h>
11 #include <string>
12 #include <cstring>
13 #include "base/atomicops.h"
14 #include "base/basictypes.h"
15 #include "base/logging.h"
16 #include "base/synchronization/condition_variable.h"
17 #include "base/synchronization/lock.h"
18
19 // Linux's ThreadIdentifier() needs this.
20 #if defined(OS_LINUX)
21 # include <linux/unistd.h>
22 #endif
23
24 #if defined(OS_WIN)
25 #define snprintf _snprintf
26 #define va_copy(a, b) do { (a) = (b); } while (0)
27 #endif
28
29 namespace leveldb {
30 namespace port {
31
32 // Chromium only supports little endian.
33 static const bool kLittleEndian = true;
34
35 class Mutex {
36 public:
37 Mutex();
38 ~Mutex();
39 void Lock();
40 void Unlock();
41 void AssertHeld();
42
43 private:
44 base::Lock mu_;
45
46 friend class CondVar;
47 DISALLOW_COPY_AND_ASSIGN(Mutex);
48 };
49
50 class CondVar {
51 public:
52 explicit CondVar(Mutex* mu);
53 ~CondVar();
54 void Wait();
55 void Signal();
56 void SignalAll();
57
58 private:
59 base::ConditionVariable cv_;
60
61 DISALLOW_COPY_AND_ASSIGN(CondVar);
62 };
63
64 class AtomicPointer {
65 private:
66 typedef base::subtle::AtomicWord Rep;
67 Rep rep_;
68 public:
69 AtomicPointer() { }
70 explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {}
71 inline void* Acquire_Load() const {
72 return reinterpret_cast<void*>(::base::subtle::Acquire_Load(&rep_));
73 }
74 inline void Release_Store(void* v) {
75 ::base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v));
76 }
77 inline void* NoBarrier_Load() const {
78 return reinterpret_cast<void*>(::base::subtle::NoBarrier_Load(&rep_));
79 }
80 inline void NoBarrier_Store(void* v) {
81 ::base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v));
82 }
83 };
84
85 bool Snappy_Compress(const char* input, size_t input_length,
86 std::string* output);
87 bool Snappy_GetUncompressedLength(const char* input, size_t length,
88 size_t* result);
89 bool Snappy_Uncompress(const char* input_data, size_t input_length,
90 char* output);
91
92 inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
93 return false;
94 }
95
96 }
97 }
98
99 #endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698