Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / common / indexed_db / indexed_db_key_path.cc
blob3783d4281a8fc7090e3a9645fc99e24dc10036cc
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"
9 namespace content {
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);
27 return array_;
30 const base::string16& IndexedDBKeyPath::string() const {
31 DCHECK(type_ == blink::WebIDBKeyPathTypeString);
32 return string_;
35 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath& other) const {
36 if (type_ != other.type_)
37 return false;
39 switch (type_) {
40 case WebIDBKeyPathTypeNull:
41 return true;
42 case WebIDBKeyPathTypeString:
43 return string_ == other.string_;
44 case WebIDBKeyPathTypeArray:
45 return array_ == other.array_;
47 NOTREACHED();
48 return false;
51 } // namespace content