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

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: change parameter to const ref 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/synchronization/condition_variable.h"
16 #include "base/synchronization/lock.h"
17
18 // Linux's ThreadIdentifier() needs this.
19 #if defined(OS_LINUX)
20 # include <linux/unistd.h>
21 #endif
22
23 #if defined(OS_WIN)
24 #define snprintf _snprintf
25 #define va_copy(a, b) do { (a) = (b); } while (0)
26 #endif
27
28 namespace leveldb {
29 namespace port {
30
31 // Chromium only supports little endian.
32 static const bool kLittleEndian = true;
33
34 class Mutex {
35 public:
36 Mutex();
37 ~Mutex();
38 void Lock();
39 void Unlock();
40 void AssertHeld();
41
42 private:
43 base::Lock mu_;
44
45 friend class CondVar;
46 DISALLOW_COPY_AND_ASSIGN(Mutex);
47 };
48
49 class CondVar {
50 public:
51 explicit CondVar(Mutex* mu);
52 ~CondVar();
53 void Wait();
54 void Signal();
55 void SignalAll();
56
57 private:
58 base::ConditionVariable cv_;
59
60 DISALLOW_COPY_AND_ASSIGN(CondVar);
61 };
62
63 class AtomicPointer {
64 private:
65 typedef base::subtle::AtomicWord Rep;
66 Rep rep_;
67 public:
68 AtomicPointer() { }
69 explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {}
70 inline void* Acquire_Load() const {
71 return reinterpret_cast<void*>(::base::subtle::Acquire_Load(&rep_));
72 }
73 inline void Release_Store(void* v) {
74 ::base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v));
75 }
76 inline void* NoBarrier_Load() const {
77 return reinterpret_cast<void*>(::base::subtle::NoBarrier_Load(&rep_));
78 }
79 inline void NoBarrier_Store(void* v) {
80 ::base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v));
81 }
82 };
83
84 bool Snappy_Compress(const char* input, size_t input_length,
85 std::string* output);
86 bool Snappy_GetUncompressedLength(const char* input, size_t length,
87 size_t* result);
88 bool Snappy_Uncompress(const char* input_data, size_t input_length,
89 char* output);
90
91 inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
92 return false;
93 }
94
95 }
96 }
97
98 #endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
OLDNEW
« no previous file with comments | « third_party/leveldatabase/leveldatabase.gyp ('k') | third_party/leveldatabase/port/port_chromium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698