blob: 4488673dcdb93920ba08f833eae9b5627dbebba3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/indexed_db_key.h"
#include "base/logging.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
using WebKit::WebIDBKey;
IndexedDBKey::IndexedDBKey()
: type_(WebIDBKey::InvalidType),
number_(0) {
}
IndexedDBKey::IndexedDBKey(const WebIDBKey& key) {
Set(key);
}
IndexedDBKey::~IndexedDBKey() {
}
void IndexedDBKey::SetNull() {
type_ = WebIDBKey::NullType;
}
void IndexedDBKey::SetInvalid() {
type_ = WebIDBKey::InvalidType;
}
void IndexedDBKey::Set(const string16& string) {
type_ = WebIDBKey::StringType;
string_ = string;
}
void IndexedDBKey::Set(double number) {
type_ = WebIDBKey::NumberType;
number_ = number;
}
void IndexedDBKey::Set(const WebIDBKey& key) {
type_ = key.type();
string_ = key.type() == WebIDBKey::StringType ?
static_cast<string16>(key.string()) : string16();
number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0;
}
IndexedDBKey::operator WebIDBKey() const {
switch (type_) {
case WebIDBKey::NullType:
return WebIDBKey::createNull();
case WebIDBKey::StringType:
return WebIDBKey(string_);
case WebIDBKey::NumberType:
return WebIDBKey(number_);
case WebIDBKey::InvalidType:
return WebIDBKey::createInvalid();
}
NOTREACHED();
return WebIDBKey::createInvalid();
}
|