1 // Copyright (c) 2012 The Chromium 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.
5 #include "content/common/indexed_db/indexed_db_key_path.h"
7 #include "base/logging.h"
11 using blink::WebIDBKeyPathTypeArray
;
12 using blink::WebIDBKeyPathTypeNull
;
13 using blink::WebIDBKeyPathTypeString
;
15 IndexedDBKeyPath::IndexedDBKeyPath() : type_(WebIDBKeyPathTypeNull
) {}
17 IndexedDBKeyPath::IndexedDBKeyPath(const base::string16
& string
)
18 : type_(WebIDBKeyPathTypeString
), string_(string
) {}
20 IndexedDBKeyPath::IndexedDBKeyPath(const std::vector
<base::string16
>& array
)
21 : type_(WebIDBKeyPathTypeArray
), array_(array
) {}
23 IndexedDBKeyPath::~IndexedDBKeyPath() {}
25 const std::vector
<base::string16
>& IndexedDBKeyPath::array() const {
26 DCHECK(type_
== blink::WebIDBKeyPathTypeArray
);
30 const base::string16
& IndexedDBKeyPath::string() const {
31 DCHECK(type_
== blink::WebIDBKeyPathTypeString
);
35 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath
& other
) const {
36 if (type_
!= other
.type_
)
40 case WebIDBKeyPathTypeNull
:
42 case WebIDBKeyPathTypeString
:
43 return string_
== other
.string_
;
44 case WebIDBKeyPathTypeArray
:
45 return array_
== other
.array_
;
51 } // namespace content