diff options
author | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 11:20:57 +0000 |
---|---|---|
committer | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 11:20:57 +0000 |
commit | 0d7734242df28c3a31eec154be017802b0499879 (patch) | |
tree | 396502db0e040e7476df53296a0efee1021277bb | |
parent | d356d7e1e4cba3c8a1e358d912921c65dbb0942a (diff) | |
download | chromium_src-0d7734242df28c3a31eec154be017802b0499879.zip chromium_src-0d7734242df28c3a31eec154be017802b0499879.tar.gz chromium_src-0d7734242df28c3a31eec154be017802b0499879.tar.bz2 |
Move chromium-specific files from leveldb's repository to chromium, stage 2.
Stages:
1. Remove chromium files from leveldb repo. [Done]
2. Put chromium leveldb files in third_party/leveldatabase and leveldb in third_party/leveldatabase/src. Update leveldb references in chrome to use third_party/leveldatabase/src instead of third_party/leveldb. Leave third_party/leveldb so it can be referred to by WebCore.gyp.
3. Change third_party/WebKit/Source/WebCore/WebCore.gyp/WebCore.gyp to use third_party/leveldatabase.
4. Delete third_party/leveldb
Eventually: 5. Rename third_party/leveldatabase back to third_party/leveldb
We can't avoid the leveldb-checkout duplication by just changing third_party/leveldb from an unversioned to a versioned directory. Doing so would break everyone's gclient sync update.
BUG=89378
TEST=indexeddb layout and browser tests
Review URL: http://codereview.chromium.org/7522008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96915 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | DEPS | 3 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 | ||||
-rw-r--r-- | third_party/leveldatabase/README.chromium | 15 | ||||
-rw-r--r-- | third_party/leveldatabase/env_chromium.cc | 543 | ||||
-rw-r--r-- | third_party/leveldatabase/leveldatabase.gyp | 153 | ||||
-rw-r--r-- | third_party/leveldatabase/port/port_chromium.cc | 84 | ||||
-rw-r--r-- | third_party/leveldatabase/port/port_chromium.h | 98 | ||||
-rw-r--r-- | webkit/fileapi/file_system_directory_database.cc | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_directory_database.h | 2 | ||||
-rw-r--r-- | webkit/fileapi/file_system_origin_database.cc | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_origin_database.h | 2 | ||||
-rw-r--r-- | webkit/fileapi/webkit_fileapi.gypi | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gypi | 2 |
14 files changed, 906 insertions, 9 deletions
@@ -101,6 +101,7 @@ v8.log /third_party/hunspell /third_party/hunspell_dictionaries /third_party/icu +/third_party/leveldatabase/src /third_party/leveldb /third_party/libjingle/source /third_party/libjpeg_turbo @@ -79,8 +79,11 @@ deps = { (Var("googlecode_url") % "google-cache-invalidation-api") + "/trunk/src/google@135", + # TODO(dgrogan): Remove third_party/leveldb after WebCore.gyp is updated. "src/third_party/leveldb": (Var("googlecode_url") % "leveldb") + "/trunk@36", + "src/third_party/leveldatabase/src": + (Var("googlecode_url") % "leveldb") + "/trunk@47", "src/third_party/snappy/src": (Var("googlecode_url") % "snappy") + "/trunk@37", diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 28263c3..fdf5075 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -14,7 +14,7 @@ '../skia/skia.gyp:skia', '../third_party/flac/flac.gyp:libflac', # TODO(ericu): remove leveldb ref after crbug.com/6955013 is fixed. - '../third_party/leveldb/leveldb.gyp:leveldb', + '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../third_party/speex/speex.gyp:libspeex', '../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', '../third_party/zlib/zlib.gyp:zlib', diff --git a/third_party/leveldatabase/README.chromium b/third_party/leveldatabase/README.chromium new file mode 100644 index 0000000..a6ce147 --- /dev/null +++ b/third_party/leveldatabase/README.chromium @@ -0,0 +1,15 @@ +Name: LevelDB: A Fast Persistent Key-Value Store +Short Name: leveldb +URL: http://code.google.com/p/leveldb/ +Version: unknown +License: New BSD +Security Critical: yes + +Description: +Alternative to SQLite used as the backend for IndexedDB and internally by the +FileSystem API implementation. + +Local Modifications: +* gyp file for building in chromium +* port/port_chromium.{h,cc} and env_chromium.cc provide chromium implementations + of primitives used by leveldb. E.g. threading, file handling, etc. diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc new file mode 100644 index 0000000..905c0df --- /dev/null +++ b/third_party/leveldatabase/env_chromium.cc @@ -0,0 +1,543 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include <deque> +#include <errno.h> +#include <stdio.h> +#include "base/at_exit.h" +#include "base/file_path.h" +#include "base/file_util.h" +#include "base/lazy_instance.h" +#include "base/memory/ref_counted.h" +#include "base/message_loop.h" +#include "base/platform_file.h" +#include "base/process_util.h" +#include "base/stringprintf.h" +#include "base/synchronization/lock.h" +#include "base/sys_info.h" +#include "base/task.h" +#include "base/threading/platform_thread.h" +#include "base/threading/thread.h" +#include "base/utf_string_conversions.h" +#include "leveldb/env.h" +#include "leveldb/slice.h" +#include "port/port.h" +#include "util/logging.h" + +#if defined(OS_WIN) +#include <io.h> +#include "base/win/win_util.h" +#endif + +#if defined(OS_MACOSX) || defined(OS_WIN) +// The following are glibc-specific +namespace { + +size_t fread_unlocked(void *ptr, size_t size, size_t n, FILE *file) { + return fread(ptr, size, n, file); +} + +size_t fwrite_unlocked(const void *ptr, size_t size, size_t n, FILE *file) { + return fwrite(ptr, size, n, file); +} + +int fflush_unlocked(FILE *file) { + return fflush(file); +} + +int fdatasync(int fildes) { +#if defined(OS_WIN) + return _commit(fildes); +#else + return fsync(fildes); +#endif +} + +} +#endif + +namespace leveldb { + +namespace { + +class Thread; + +static const ::FilePath::CharType kLevelDBTestDirectoryPrefix[] + = FILE_PATH_LITERAL("leveldb-test-"); + +::FilePath CreateFilePath(const std::string& file_path) { +#if defined(OS_WIN) + return FilePath(UTF8ToUTF16(file_path)); +#else + return FilePath(file_path); +#endif +} + +std::string FilePathToString(const ::FilePath& file_path) { +#if defined(OS_WIN) + return UTF16ToUTF8(file_path.value()); +#else + return file_path.value(); +#endif +} + +// TODO(jorlow): This should be moved into Chromium's base. +const char* PlatformFileErrorString(const ::base::PlatformFileError& error) { + switch (error) { + case ::base::PLATFORM_FILE_ERROR_FAILED: + return "Opening file failed."; + case ::base::PLATFORM_FILE_ERROR_IN_USE: + return "File currently in use."; + case ::base::PLATFORM_FILE_ERROR_EXISTS: + return "File already exists."; + case ::base::PLATFORM_FILE_ERROR_NOT_FOUND: + return "File not found."; + case ::base::PLATFORM_FILE_ERROR_ACCESS_DENIED: + return "Access denied."; + case ::base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED: + return "Too many files open."; + case ::base::PLATFORM_FILE_ERROR_NO_MEMORY: + return "Out of memory."; + case ::base::PLATFORM_FILE_ERROR_NO_SPACE: + return "No space left on drive."; + case ::base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: + return "Not a directory."; + case ::base::PLATFORM_FILE_ERROR_INVALID_OPERATION: + return "Invalid operation."; + case ::base::PLATFORM_FILE_ERROR_SECURITY: + return "Security error."; + case ::base::PLATFORM_FILE_ERROR_ABORT: + return "File operation aborted."; + case ::base::PLATFORM_FILE_ERROR_NOT_A_FILE: + return "The supplied path was not a file."; + case ::base::PLATFORM_FILE_ERROR_NOT_EMPTY: + return "The file was not empty."; + case ::base::PLATFORM_FILE_ERROR_INVALID_URL: + return "Invalid URL."; + case ::base::PLATFORM_FILE_OK: + return "OK."; + } + NOTIMPLEMENTED(); + return "Unknown error."; +} + +class ChromiumSequentialFile: public SequentialFile { + private: + std::string filename_; + FILE* file_; + + public: + ChromiumSequentialFile(const std::string& fname, FILE* f) + : filename_(fname), file_(f) { } + virtual ~ChromiumSequentialFile() { fclose(file_); } + + virtual Status Read(size_t n, Slice* result, char* scratch) { + Status s; + size_t r = fread_unlocked(scratch, 1, n, file_); + *result = Slice(scratch, r); + if (r < n) { + if (feof(file_)) { + // We leave status as ok if we hit the end of the file + } else { + // A partial read with an error: return a non-ok status + s = Status::IOError(filename_, strerror(errno)); + } + } + return s; + } + + virtual Status Skip(uint64_t n) { + if (fseek(file_, n, SEEK_CUR)) { + return Status::IOError(filename_, strerror(errno)); + } + return Status::OK(); + } +}; + +class ChromiumRandomAccessFile: public RandomAccessFile { + private: + std::string filename_; + ::base::PlatformFile file_; + + public: + ChromiumRandomAccessFile(const std::string& fname, ::base::PlatformFile file) + : filename_(fname), file_(file) { } + virtual ~ChromiumRandomAccessFile() { ::base::ClosePlatformFile(file_); } + + virtual Status Read(uint64_t offset, size_t n, Slice* result, + char* scratch) const { + Status s; + int r = ::base::ReadPlatformFile(file_, offset, scratch, n); + *result = Slice(scratch, (r < 0) ? 0 : r); + if (r < 0) { + // An error: return a non-ok status + s = Status::IOError(filename_, "Could not preform read"); + } + return s; + } +}; + +class ChromiumWritableFile : public WritableFile { + private: + std::string filename_; + FILE* file_; + + public: + ChromiumWritableFile(const std::string& fname, FILE* f) + : filename_(fname), file_(f) { } + + ~ChromiumWritableFile() { + if (file_ != NULL) { + // Ignoring any potential errors + fclose(file_); + } + } + + virtual Status Append(const Slice& data) { + size_t r = fwrite_unlocked(data.data(), 1, data.size(), file_); + Status result; + if (r != data.size()) { + result = Status::IOError(filename_, strerror(errno)); + } + return result; + } + + virtual Status Close() { + Status result; + if (fclose(file_) != 0) { + result = Status::IOError(filename_, strerror(errno)); + } + file_ = NULL; + return result; + } + + virtual Status Flush() { + Status result; + if (fflush_unlocked(file_) != 0) { + result = Status::IOError(filename_, strerror(errno)); + } + return result; + } + + virtual Status Sync() { + Status result; + if ((fflush_unlocked(file_) != 0) || + (fdatasync(fileno(file_)) != 0)) { + result = Status::IOError(filename_, strerror(errno)); + } + return result; + } +}; + +class ChromiumFileLock : public FileLock { + public: + ::base::PlatformFile file_; +}; + +class ChromiumEnv : public Env { + public: + ChromiumEnv(); + virtual ~ChromiumEnv() { + fprintf(stderr, "Destroying Env::Default()\n"); + exit(1); + } + + virtual Status NewSequentialFile(const std::string& fname, + SequentialFile** result) { + FILE* f = fopen(fname.c_str(), "rb"); + if (f == NULL) { + *result = NULL; + return Status::IOError(fname, strerror(errno)); + } else { + *result = new ChromiumSequentialFile(fname, f); + return Status::OK(); + } + } + + virtual Status NewRandomAccessFile(const std::string& fname, + RandomAccessFile** result) { + int flags = ::base::PLATFORM_FILE_READ | ::base::PLATFORM_FILE_OPEN; + bool created; + ::base::PlatformFileError error_code; + ::base::PlatformFile file = ::base::CreatePlatformFile( + CreateFilePath(fname), flags, &created, &error_code); + if (error_code != ::base::PLATFORM_FILE_OK) { + *result = NULL; + return Status::IOError(fname, PlatformFileErrorString(error_code)); + } + *result = new ChromiumRandomAccessFile(fname, file); + return Status::OK(); + } + + virtual Status NewWritableFile(const std::string& fname, + WritableFile** result) { + *result = NULL; + FILE* f = fopen(fname.c_str(), "wb"); + if (f == NULL) { + return Status::IOError(fname, strerror(errno)); + } else { + *result = new ChromiumWritableFile(fname, f); + return Status::OK(); + } + } + + virtual bool FileExists(const std::string& fname) { + return ::file_util::PathExists(CreateFilePath(fname)); + } + + virtual Status GetChildren(const std::string& dir, + std::vector<std::string>* result) { + result->clear(); + ::file_util::FileEnumerator iter( + CreateFilePath(dir), false, ::file_util::FileEnumerator::FILES); + ::FilePath current = iter.Next(); + while (!current.empty()) { + result->push_back(FilePathToString(current.BaseName())); + current = iter.Next(); + } + // TODO(jorlow): Unfortunately, the FileEnumerator swallows errors, so + // we'll always return OK. Maybe manually check for error + // conditions like the file not existing? + return Status::OK(); + } + + virtual Status DeleteFile(const std::string& fname) { + Status result; + // TODO(jorlow): Should we assert this is a file? + if (!::file_util::Delete(CreateFilePath(fname), false)) { + result = Status::IOError(fname, "Could not delete file."); + } + return result; + }; + + virtual Status CreateDir(const std::string& name) { + Status result; + if (!::file_util::CreateDirectory(CreateFilePath(name))) { + result = Status::IOError(name, "Could not create directory."); + } + return result; + }; + + virtual Status DeleteDir(const std::string& name) { + Status result; + // TODO(jorlow): Should we assert this is a directory? + if (!::file_util::Delete(CreateFilePath(name), false)) { + result = Status::IOError(name, "Could not delete directory."); + } + return result; + }; + + virtual Status GetFileSize(const std::string& fname, uint64_t* size) { + Status s; + int64_t signed_size; + if (!::file_util::GetFileSize(CreateFilePath(fname), &signed_size)) { + *size = 0; + s = Status::IOError(fname, "Could not determine file size."); + } else { + *size = static_cast<uint64_t>(signed_size); + } + return s; + } + + virtual Status RenameFile(const std::string& src, const std::string& dst) { + Status result; + if (!::file_util::ReplaceFile(CreateFilePath(src), CreateFilePath(dst))) { + result = Status::IOError(src, "Could not rename file."); + } + return result; + } + + virtual Status LockFile(const std::string& fname, FileLock** lock) { + *lock = NULL; + Status result; + int flags = ::base::PLATFORM_FILE_OPEN_ALWAYS | + ::base::PLATFORM_FILE_READ | + ::base::PLATFORM_FILE_WRITE | + ::base::PLATFORM_FILE_EXCLUSIVE_READ | + ::base::PLATFORM_FILE_EXCLUSIVE_WRITE; + bool created; + ::base::PlatformFileError error_code; + ::base::PlatformFile file = ::base::CreatePlatformFile( + CreateFilePath(fname), flags, &created, &error_code); + if (error_code != ::base::PLATFORM_FILE_OK) { + result = Status::IOError(fname, PlatformFileErrorString(error_code)); + } else { + ChromiumFileLock* my_lock = new ChromiumFileLock; + my_lock->file_ = file; + *lock = my_lock; + } + return result; + } + + virtual Status UnlockFile(FileLock* lock) { + ChromiumFileLock* my_lock = reinterpret_cast<ChromiumFileLock*>(lock); + Status result; + if (!::base::ClosePlatformFile(my_lock->file_)) { + result = Status::IOError("Could not close lock file."); + } + delete my_lock; + return result; + } + + virtual void Schedule(void (*function)(void*), void* arg); + + virtual void StartThread(void (*function)(void* arg), void* arg); + + virtual std::string UserIdentifier() { +#if defined(OS_WIN) + std::wstring user_sid; + bool ret = ::base::win::GetUserSidString(&user_sid); + DCHECK(ret); + return UTF16ToUTF8(user_sid); +#else + char buf[100]; + snprintf(buf, sizeof(buf), "%d", int(geteuid())); + return buf; +#endif + } + + virtual Status GetTestDirectory(std::string* path) { + mu_.Acquire(); + if (test_directory_.empty()) { + if (!::file_util::CreateNewTempDirectory(kLevelDBTestDirectoryPrefix, + &test_directory_)) { + mu_.Release(); + return Status::IOError("Could not create temp directory."); + } + } + *path = FilePathToString(test_directory_); + mu_.Release(); + return Status::OK(); + } + + class ChromiumLogger : public Logger { + public: + ChromiumLogger(const std::string& filename) : filename_(filename) { + } + + virtual void Logv(const char* format, va_list ap) { + VLOG(5) << "LevelDB: " << filename_ << " " << StringPrintf(format, ap); + } + + private: + std::string filename_; + }; + + virtual Status NewLogger(const std::string& fname, Logger** result) { + *result = new ChromiumLogger(fname); + return Status::OK(); + } + + virtual uint64_t NowMicros() { + return ::base::TimeTicks::HighResNow().ToInternalValue(); + } + + virtual void SleepForMicroseconds(int micros) { + // Round up to the next millisecond. + ::base::PlatformThread::Sleep((micros + 999) / 1000); + } + + private: + // BGThread() is the body of the background thread + void BGThread(); + static void BGThreadWrapper(void* arg) { + reinterpret_cast<ChromiumEnv*>(arg)->BGThread(); + } + + FilePath test_directory_; + + size_t page_size_; + ::base::Lock mu_; + ::base::ConditionVariable bgsignal_; + bool started_bgthread_; + + // Entry per Schedule() call + struct BGItem { void* arg; void (*function)(void*); }; + typedef std::deque<BGItem> BGQueue; + BGQueue queue_; +}; + +ChromiumEnv::ChromiumEnv() + : page_size_(::base::SysInfo::VMAllocationGranularity()), + bgsignal_(&mu_), + started_bgthread_(false) { +#if defined(OS_MACOSX) + ::base::EnableTerminationOnHeapCorruption(); + ::base::EnableTerminationOnOutOfMemory(); +#endif // OS_MACOSX +} + +class Thread : public ::base::PlatformThread::Delegate { + public: + Thread(void (*function)(void* arg), void* arg) + : function_(function), arg_(arg) { + ::base::PlatformThreadHandle handle; + bool success = ::base::PlatformThread::Create(0, this, &handle); + DCHECK(success); + } + virtual ~Thread() {} + virtual void ThreadMain() { + (*function_)(arg_); + delete this; + } + + private: + void (*function_)(void* arg); + void* arg_; +}; + +void ChromiumEnv::Schedule(void (*function)(void*), void* arg) { + mu_.Acquire(); + + // Start background thread if necessary + if (!started_bgthread_) { + started_bgthread_ = true; + StartThread(&ChromiumEnv::BGThreadWrapper, this); + } + + // If the queue is currently empty, the background thread may currently be + // waiting. + if (queue_.empty()) { + bgsignal_.Signal(); + } + + // Add to priority queue + queue_.push_back(BGItem()); + queue_.back().function = function; + queue_.back().arg = arg; + + mu_.Release(); +} + +void ChromiumEnv::BGThread() { + while (true) { + // Wait until there is an item that is ready to run + mu_.Acquire(); + while (queue_.empty()) { + bgsignal_.Wait(); + } + + void (*function)(void*) = queue_.front().function; + void* arg = queue_.front().arg; + queue_.pop_front(); + + mu_.Release(); + (*function)(arg); + } +} + +void ChromiumEnv::StartThread(void (*function)(void* arg), void* arg) { + new Thread(function, arg); // Will self-delete. +} + +::base::LazyInstance<ChromiumEnv, ::base::LeakyLazyInstanceTraits<ChromiumEnv> > + default_env(::base::LINKER_INITIALIZED); + +} + +Env* Env::Default() { + return default_env.Pointer(); +} + +} diff --git a/third_party/leveldatabase/leveldatabase.gyp b/third_party/leveldatabase/leveldatabase.gyp new file mode 100644 index 0000000..71297dd --- /dev/null +++ b/third_party/leveldatabase/leveldatabase.gyp @@ -0,0 +1,153 @@ +# Copyright (c) 2011 The LevelDB Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. See the AUTHORS file for names of contributors. + +{ + 'variables': { + 'use_snappy%': 0, + }, + 'target_defaults': { + 'defines': [ + 'LEVELDB_PLATFORM_CHROMIUM=1', + ], + 'include_dirs': [ + '.', + 'src/', + 'src/include/', + ], + 'conditions': [ + ['OS == "win"', { + 'include_dirs': [ + 'src/port/win', + ], + }], + ['use_snappy', { + 'defines': [ + 'USE_SNAPPY=1', + ], + }], + ], + }, + 'targets': [ + { + 'target_name': 'leveldatabase', + 'type': '<(library)', + 'dependencies': [ + '../../base/base.gyp:base', + # base::LazyInstance is a template that pulls in dynamic_annotations so + # we need to explictly link in the code for dynamic_annotations. + '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + ], + 'conditions': [ + ['use_snappy', { + 'dependencies': [ + '../../third_party/snappy/snappy.gyp:snappy', + ], + }], + ], + 'direct_dependent_settings': { + 'include_dirs': [ + 'src/include/', + ], + 'conditions': [ + ['OS == "win"', { + 'include_dirs': [ + 'src/port/win', + ], + }], + ], + }, + 'sources': [ + # Include and then exclude so that all files show up in IDEs, even if + # they don't build. + 'env_chromium.cc', + 'port/port_chromium.cc', + 'port/port_chromium.h', + 'src/db/builder.cc', + 'src/db/builder.h', + 'src/db/db_impl.cc', + 'src/db/db_impl.h', + 'src/db/db_iter.cc', + 'src/db/db_iter.h', + 'src/db/filename.cc', + 'src/db/filename.h', + 'src/db/dbformat.cc', + 'src/db/dbformat.h', + 'src/db/log_format.h', + 'src/db/log_reader.cc', + 'src/db/log_reader.h', + 'src/db/log_writer.cc', + 'src/db/log_writer.h', + 'src/db/memtable.cc', + 'src/db/memtable.h', + 'src/db/repair.cc', + 'src/db/skiplist.h', + 'src/db/snapshot.h', + 'src/db/table_cache.cc', + 'src/db/table_cache.h', + 'src/db/version_edit.cc', + 'src/db/version_edit.h', + 'src/db/version_set.cc', + 'src/db/version_set.h', + 'src/db/write_batch.cc', + 'src/db/write_batch_internal.h', + 'src/include/leveldb/cache.h', + 'src/include/leveldb/comparator.h', + 'src/include/leveldb/db.h', + 'src/include/leveldb/env.h', + 'src/include/leveldb/iterator.h', + 'src/include/leveldb/options.h', + 'src/include/leveldb/slice.h', + 'src/include/leveldb/status.h', + 'src/include/leveldb/table.h', + 'src/include/leveldb/table_builder.h', + 'src/include/leveldb/write_batch.h', + 'src/port/port.h', + 'src/port/port_example.h', + 'src/port/port_posix.cc', + 'src/port/port_posix.h', + 'src/table/block.cc', + 'src/table/block.h', + 'src/table/block_builder.cc', + 'src/table/block_builder.h', + 'src/table/format.cc', + 'src/table/format.h', + 'src/table/iterator.cc', + 'src/table/iterator_wrapper.h', + 'src/table/merger.cc', + 'src/table/merger.h', + 'src/table/table.cc', + 'src/table/table_builder.cc', + 'src/table/two_level_iterator.cc', + 'src/table/two_level_iterator.h', + 'src/util/arena.cc', + 'src/util/arena.h', + 'src/util/cache.cc', + 'src/util/coding.cc', + 'src/util/coding.h', + 'src/util/comparator.cc', + 'src/util/crc32c.cc', + 'src/util/crc32c.h', + 'src/util/env.cc', + 'src/util/hash.cc', + 'src/util/hash.h', + 'src/util/logging.cc', + 'src/util/logging.h', + 'src/util/mutexlock.h', + 'src/util/options.cc', + 'src/util/random.h', + 'src/util/status.cc', + ], + 'sources/': [ + ['exclude', '_(android|example|portable|posix)\\.cc$'], + ], + }, + # TODO(dgrogan): Replace the test targets once third_party/leveldb is gone. + ], +} + +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/third_party/leveldatabase/port/port_chromium.cc b/third_party/leveldatabase/port/port_chromium.cc new file mode 100644 index 0000000..7f6de92 --- /dev/null +++ b/third_party/leveldatabase/port/port_chromium.cc @@ -0,0 +1,84 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include "port/port_chromium.h" + +#include "util/logging.h" + +#if defined(USE_SNAPPY) +# include "third_party/snappy/src/snappy.h" +#endif + +namespace leveldb { +namespace port { + +Mutex::Mutex() { +} + +Mutex::~Mutex() { +} + +void Mutex::Lock() { + mu_.Acquire(); +} + +void Mutex::Unlock() { + mu_.Release(); +} + +void Mutex::AssertHeld() { + mu_.AssertAcquired(); +} + +CondVar::CondVar(Mutex* mu) + : cv_(&mu->mu_) { +} + +CondVar::~CondVar() { } + +void CondVar::Wait() { + cv_.Wait(); +} + +void CondVar::Signal(){ + cv_.Signal(); +} + +void CondVar::SignalAll() { + cv_.Broadcast(); +} + +bool Snappy_Compress(const char* input, size_t input_length, + std::string* output) { +#if defined(USE_SNAPPY) + output->resize(snappy::MaxCompressedLength(input_length)); + size_t outlen; + snappy::RawCompress(input, input_length, &(*output)[0], &outlen); + output->resize(outlen); + return true; +#else + return false; +#endif +} + +bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result) { +#if defined(USE_SNAPPY) + return snappy::GetUncompressedLength(input_data, input_length, result); +#else + return false; +#endif +} + +bool Snappy_Uncompress(const char* input_data, size_t input_length, + char* output) { +#if defined(USE_SNAPPY) + return snappy::RawUncompress(input_data, input_length, output); +#else + return false; +#endif +} + +} +} diff --git a/third_party/leveldatabase/port/port_chromium.h b/third_party/leveldatabase/port/port_chromium.h new file mode 100644 index 0000000..4239a64 --- /dev/null +++ b/third_party/leveldatabase/port/port_chromium.h @@ -0,0 +1,98 @@ +// Copyright (c) 2011 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. +// +// See port_example.h for documentation for the following types/functions. + +#ifndef STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ +#define STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ + +#include <stdint.h> +#include <string> +#include <cstring> +#include "base/atomicops.h" +#include "base/basictypes.h" +#include "base/synchronization/condition_variable.h" +#include "base/synchronization/lock.h" + +// Linux's ThreadIdentifier() needs this. +#if defined(OS_LINUX) +# include <linux/unistd.h> +#endif + +#if defined(OS_WIN) +#define snprintf _snprintf +#define va_copy(a, b) do { (a) = (b); } while (0) +#endif + +namespace leveldb { +namespace port { + +// Chromium only supports little endian. +static const bool kLittleEndian = true; + +class Mutex { + public: + Mutex(); + ~Mutex(); + void Lock(); + void Unlock(); + void AssertHeld(); + + private: + base::Lock mu_; + + friend class CondVar; + DISALLOW_COPY_AND_ASSIGN(Mutex); +}; + +class CondVar { + public: + explicit CondVar(Mutex* mu); + ~CondVar(); + void Wait(); + void Signal(); + void SignalAll(); + + private: + base::ConditionVariable cv_; + + DISALLOW_COPY_AND_ASSIGN(CondVar); +}; + +class AtomicPointer { + private: + typedef base::subtle::AtomicWord Rep; + Rep rep_; + public: + AtomicPointer() { } + explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {} + inline void* Acquire_Load() const { + return reinterpret_cast<void*>(::base::subtle::Acquire_Load(&rep_)); + } + inline void Release_Store(void* v) { + ::base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v)); + } + inline void* NoBarrier_Load() const { + return reinterpret_cast<void*>(::base::subtle::NoBarrier_Load(&rep_)); + } + inline void NoBarrier_Store(void* v) { + ::base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v)); + } +}; + +bool Snappy_Compress(const char* input, size_t input_length, + std::string* output); +bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result); +bool Snappy_Uncompress(const char* input_data, size_t input_length, + char* output); + +inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { + return false; +} + +} +} + +#endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ diff --git a/webkit/fileapi/file_system_directory_database.cc b/webkit/fileapi/file_system_directory_database.cc index 7c5d8de..c7e5b37 100644 --- a/webkit/fileapi/file_system_directory_database.cc +++ b/webkit/fileapi/file_system_directory_database.cc @@ -10,8 +10,8 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" -#include "third_party/leveldb/include/leveldb/iterator.h" -#include "third_party/leveldb/include/leveldb/write_batch.h" +#include "third_party/leveldatabase/src/include/leveldb/iterator.h" +#include "third_party/leveldatabase/src/include/leveldb/write_batch.h" namespace { diff --git a/webkit/fileapi/file_system_directory_database.h b/webkit/fileapi/file_system_directory_database.h index d363499..78cae7d 100644 --- a/webkit/fileapi/file_system_directory_database.h +++ b/webkit/fileapi/file_system_directory_database.h @@ -11,7 +11,7 @@ #include "base/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/time.h" -#include "third_party/leveldb/include/leveldb/db.h" +#include "third_party/leveldatabase/src/include/leveldb/db.h" namespace leveldb { class WriteBatch; diff --git a/webkit/fileapi/file_system_origin_database.cc b/webkit/fileapi/file_system_origin_database.cc index ca267e8..5762ee9 100644 --- a/webkit/fileapi/file_system_origin_database.cc +++ b/webkit/fileapi/file_system_origin_database.cc @@ -10,8 +10,8 @@ #include "base/stringprintf.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" -#include "third_party/leveldb/include/leveldb/iterator.h" -#include "third_party/leveldb/include/leveldb/write_batch.h" +#include "third_party/leveldatabase/src/include/leveldb/iterator.h" +#include "third_party/leveldatabase/src/include/leveldb/write_batch.h" namespace { diff --git a/webkit/fileapi/file_system_origin_database.h b/webkit/fileapi/file_system_origin_database.h index 63a4b815..0501ff6 100644 --- a/webkit/fileapi/file_system_origin_database.h +++ b/webkit/fileapi/file_system_origin_database.h @@ -11,7 +11,7 @@ #include "base/file_path.h" #include "base/memory/scoped_ptr.h" -#include "third_party/leveldb/include/leveldb/db.h" +#include "third_party/leveldatabase/src/include/leveldb/db.h" namespace fileapi { diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi index ab1ad84..e8708c1 100644 --- a/webkit/fileapi/webkit_fileapi.gypi +++ b/webkit/fileapi/webkit_fileapi.gypi @@ -10,7 +10,7 @@ 'dependencies': [ '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/net/net.gyp:net', - '<(DEPTH)/third_party/leveldb/leveldb.gyp:leveldb', + '<(DEPTH)/third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '<(DEPTH)/webkit/support/webkit_support.gyp:quota', ], 'sources': [ diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 993d489..2d457db 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -357,7 +357,7 @@ '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/testing/gmock.gyp:gmock', '<(DEPTH)/testing/gtest.gyp:gtest', - '<(DEPTH)/third_party/leveldb/leveldb.gyp:leveldb', + '<(DEPTH)/third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', ], 'sources': [ |