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(const IndexedDBKeyPath
& other
) = default;
24 IndexedDBKeyPath::~IndexedDBKeyPath() = default;
25 IndexedDBKeyPath
& IndexedDBKeyPath::operator=(const IndexedDBKeyPath
& other
) =
28 const std::vector
<base::string16
>& IndexedDBKeyPath::array() const {
29 DCHECK(type_
== blink::WebIDBKeyPathTypeArray
);
33 const base::string16
& IndexedDBKeyPath::string() const {
34 DCHECK(type_
== blink::WebIDBKeyPathTypeString
);
38 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath
& other
) const {
39 if (type_
!= other
.type_
)
43 case WebIDBKeyPathTypeNull
:
45 case WebIDBKeyPathTypeString
:
46 return string_
== other
.string_
;
47 case WebIDBKeyPathTypeArray
:
48 return array_
== other
.array_
;
54 } // namespace content