diff options
author | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 16:53:14 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 16:53:14 +0000 |
commit | d29efa8261b6b0472ea262dadc48a2808f7fdf39 (patch) | |
tree | 3d06064bff19e17d9f4252b806f1d01cee49a1a0 /content/common/indexed_db/indexed_db_key.cc | |
parent | 0c701d2a8fca816305153c108401c367d59506a4 (diff) | |
download | chromium_src-d29efa8261b6b0472ea262dadc48a2808f7fdf39.zip chromium_src-d29efa8261b6b0472ea262dadc48a2808f7fdf39.tar.gz chromium_src-d29efa8261b6b0472ea262dadc48a2808f7fdf39.tar.bz2 |
Migrate the IndexedDB backend from Blink to Chromium
To get the IDB backend off the (deprecated) WebKit thread, remove
intermediate proxying, and let us take advantage of base utilities,
we're moving the code from Blink to Chromium.
This patch is basically a glorified copy/paste of the Blink IDB
backend code, with Chromium coding style applied, WTF dependencies
replaced with STL and base/, redundant classes removed, etc. It
introduces some new temporary proxy classes
(content/browser/webidb*_impl.*) to allow us build both the old and
new backends.
The new backend is currently disabled by default. It can be enabled
using a new (and temporary) command line switch: --new-indexeddb Once
we've done some further cleanup and are confident that the new backend
is stable, and the bots have moved from DumpRenderTree to
content_shell, we'll switch to the new backend by default. Once that
has survived through a dev channel release, we'll delete the Blink
code and eliminate unnecessary proxy classes.
BUG=234278
R=alecflett@chromium.org, dgrogan@chromium.org, piman@chromium.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=202215
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=202604
Review URL: https://codereview.chromium.org/15564008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/indexed_db/indexed_db_key.cc')
-rw-r--r-- | content/common/indexed_db/indexed_db_key.cc | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/content/common/indexed_db/indexed_db_key.cc b/content/common/indexed_db/indexed_db_key.cc index 4083fd3..3d24ade 100644 --- a/content/common/indexed_db/indexed_db_key.cc +++ b/content/common/indexed_db/indexed_db_key.cc @@ -4,6 +4,7 @@ #include "content/common/indexed_db/indexed_db_key.h" +#include <string> #include "base/logging.h" #include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebVector.h" @@ -60,7 +61,7 @@ static IndexedDBKey::KeyArray CopyKeyArray(const WebIDBKey& other) { } return result; } -} // namespace +} // namespace IndexedDBKey::IndexedDBKey() : type_(WebIDBKey::NullType), @@ -104,6 +105,8 @@ IndexedDBKey::IndexedDBKey(const string16& key) IndexedDBKey::~IndexedDBKey() {} int IndexedDBKey::Compare(const IndexedDBKey& other) const { + DCHECK(IsValid()); + DCHECK(other.IsValid()); if (type_ != other.type_) return type_ > other.type_ ? -1 : 1; @@ -121,15 +124,17 @@ int IndexedDBKey::Compare(const IndexedDBKey& other) const { case WebIDBKey::StringType: return -other.string_.compare(string_); case WebIDBKey::DateType: + return (date_ < other.date_) ? -1 : (date_ > other.date_) ? 1 : 0; case WebIDBKey::NumberType: return (number_ < other.number_) ? -1 : (number_ > other.number_) ? 1 : 0; case WebIDBKey::InvalidType: case WebIDBKey::NullType: - default: - // This is a placeholder for WebKit::WebIDBKey::MinType + case WebIDBKey::MinType: NOTREACHED(); return 0; } + NOTREACHED(); + return 0; } bool IndexedDBKey::IsLessThan(const IndexedDBKey& other) const { @@ -140,6 +145,20 @@ bool IndexedDBKey::IsEqual(const IndexedDBKey& other) const { return !Compare(other); } +bool IndexedDBKey::IsValid() const { + if (type_ == WebIDBKey::InvalidType || type_ == WebIDBKey::NullType) + return false; + + if (type_ == WebIDBKey::ArrayType) { + for (size_t i = 0; i < array_.size(); i++) { + if (!array_[i].IsValid()) + return false; + } + } + + return true; +} + IndexedDBKey::operator WebIDBKey() const { switch (type_) { case WebIDBKey::ArrayType: @@ -154,11 +173,12 @@ IndexedDBKey::operator WebIDBKey() const { return WebIDBKey::createInvalid(); case WebIDBKey::NullType: return WebIDBKey::createNull(); - default: - // This is a placeholder for WebKit::WebIDBKey::MinType + case WebIDBKey::MinType: NOTREACHED(); return WebIDBKey::createInvalid(); } + NOTREACHED(); + return WebIDBKey::createInvalid(); } } // namespace content |