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

Unified Diff: content/common/indexed_db/indexed_db_key.cc

Issue 19752007: Use builders to convert between WebKit and content IDB types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/indexed_db/indexed_db_key.h ('k') | content/common/indexed_db/indexed_db_key_path.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/indexed_db/indexed_db_key.cc
diff --git a/content/common/indexed_db/indexed_db_key.cc b/content/common/indexed_db/indexed_db_key.cc
index 2fefb398f65b39955258347d35a27fe08ba2dc1d..e84d3781ef7532c99febceaab3fa535f3ee519d4 100644
--- a/content/common/indexed_db/indexed_db_key.cc
+++ b/content/common/indexed_db/indexed_db_key.cc
@@ -6,9 +6,6 @@
#include <string>
#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebIDBKey.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebVector.h"
namespace content {
@@ -21,7 +18,6 @@ using WebKit::WebIDBKeyTypeMin;
using WebKit::WebIDBKeyTypeNull;
using WebKit::WebIDBKeyTypeNumber;
using WebKit::WebIDBKeyTypeString;
-using WebKit::WebVector;
namespace {
@@ -35,30 +31,6 @@ static size_t CalculateArraySize(const IndexedDBKey::KeyArray& keys) {
return size;
}
-static size_t CalculateKeySize(const WebIDBKey& key) {
- switch (key.keyType()) {
- case WebIDBKeyTypeArray: {
- const WebVector<WebIDBKey>& array = key.array();
- size_t total = 0;
- for (size_t i = 0; i < array.size(); ++i)
- total += CalculateKeySize(array[i]);
- return kOverheadSize + total;
- }
- case WebIDBKeyTypeString:
- return kOverheadSize +
- (key.string().length() * sizeof(string16::value_type));
-
- case WebIDBKeyTypeDate:
- case WebIDBKeyTypeNumber:
- return kOverheadSize + sizeof(double);
-
- default:
- return kOverheadSize;
- }
- NOTREACHED();
- return 0;
-}
-
template <typename T>
static IndexedDBKey::KeyArray CopyKeyArray(const T& array) {
IndexedDBKey::KeyArray result;
@@ -69,13 +41,6 @@ static IndexedDBKey::KeyArray CopyKeyArray(const T& array) {
return result;
}
-static IndexedDBKey::KeyArray CopyKeyArray(const WebIDBKey& other) {
- IndexedDBKey::KeyArray result;
- if (other.keyType() == WebIDBKeyTypeArray) {
- result = CopyKeyArray(other.array());
- }
- return result;
-}
} // namespace
IndexedDBKey::IndexedDBKey()
@@ -110,16 +75,6 @@ IndexedDBKey::IndexedDBKey(const string16& key)
size_estimate_(kOverheadSize +
(key.length() * sizeof(string16::value_type))) {}
-IndexedDBKey::IndexedDBKey(const WebIDBKey& key)
- : type_(key.keyType()),
- array_(CopyKeyArray(key)),
- string_(key.keyType() == WebIDBKeyTypeString
- ? static_cast<string16>(key.string())
- : string16()),
- date_(key.keyType() == WebIDBKeyTypeDate ? key.date() : 0),
- number_(key.keyType() == WebIDBKeyTypeNumber ? key.number() : 0),
- size_estimate_(CalculateKeySize(key)) {}
-
IndexedDBKey::~IndexedDBKey() {}
int IndexedDBKey::Compare(const IndexedDBKey& other) const {
@@ -177,26 +132,4 @@ bool IndexedDBKey::IsValid() const {
return true;
}
-IndexedDBKey::operator WebIDBKey() const {
- switch (type_) {
- case WebIDBKeyTypeArray:
- return WebIDBKey::createArray(array_);
- case WebIDBKeyTypeString:
- return WebIDBKey::createString(string_);
- case WebIDBKeyTypeDate:
- return WebIDBKey::createDate(date_);
- case WebIDBKeyTypeNumber:
- return WebIDBKey::createNumber(number_);
- case WebIDBKeyTypeInvalid:
- return WebIDBKey::createInvalid();
- case WebIDBKeyTypeNull:
- return WebIDBKey::createNull();
- case WebIDBKeyTypeMin:
- NOTREACHED();
- return WebIDBKey::createInvalid();
- }
- NOTREACHED();
- return WebIDBKey::createInvalid();
-}
-
} // namespace content
« no previous file with comments | « content/common/indexed_db/indexed_db_key.h ('k') | content/common/indexed_db/indexed_db_key_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698