[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / common / indexed_db / indexed_db_key_path.cc
bloba5756b5141806ced7639f65ca62146be10a46dc5
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(const IndexedDBKeyPath& other) = default;
24 IndexedDBKeyPath::~IndexedDBKeyPath() = default;
25 IndexedDBKeyPath& IndexedDBKeyPath::operator=(const IndexedDBKeyPath& other) =
26 default;
28 const std::vector<base::string16>& IndexedDBKeyPath::array() const {
29 DCHECK(type_ == blink::WebIDBKeyPathTypeArray);
30 return array_;
33 const base::string16& IndexedDBKeyPath::string() const {
34 DCHECK(type_ == blink::WebIDBKeyPathTypeString);
35 return string_;
38 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath& other) const {
39 if (type_ != other.type_)
40 return false;
42 switch (type_) {
43 case WebIDBKeyPathTypeNull:
44 return true;
45 case WebIDBKeyPathTypeString:
46 return string_ == other.string_;
47 case WebIDBKeyPathTypeArray:
48 return array_ == other.array_;
50 NOTREACHED();
51 return false;
54 } // namespace content