| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/indexed_db/indexed_db_key_path.h" | 5 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 using blink::WebIDBKeyPathTypeArray; | 11 using blink::WebIDBKeyPathTypeArray; |
| 12 using blink::WebIDBKeyPathTypeNull; | 12 using blink::WebIDBKeyPathTypeNull; |
| 13 using blink::WebIDBKeyPathTypeString; | 13 using blink::WebIDBKeyPathTypeString; |
| 14 | 14 |
| 15 IndexedDBKeyPath::IndexedDBKeyPath() : type_(WebIDBKeyPathTypeNull) {} | 15 IndexedDBKeyPath::IndexedDBKeyPath() : type_(WebIDBKeyPathTypeNull) {} |
| 16 | 16 |
| 17 IndexedDBKeyPath::IndexedDBKeyPath(const base::string16& string) | 17 IndexedDBKeyPath::IndexedDBKeyPath(const base::string16& string) |
| 18 : type_(WebIDBKeyPathTypeString), string_(string) {} | 18 : type_(WebIDBKeyPathTypeString), string_(string) {} |
| 19 | 19 |
| 20 IndexedDBKeyPath::IndexedDBKeyPath(const std::vector<base::string16>& array) | 20 IndexedDBKeyPath::IndexedDBKeyPath(const std::vector<base::string16>& array) |
| 21 : type_(WebIDBKeyPathTypeArray), array_(array) {} | 21 : type_(WebIDBKeyPathTypeArray), array_(array) {} |
| 22 | 22 |
| 23 IndexedDBKeyPath::~IndexedDBKeyPath() {} | 23 IndexedDBKeyPath::IndexedDBKeyPath(const IndexedDBKeyPath& other) = default; |
| 24 IndexedDBKeyPath::~IndexedDBKeyPath() = default; |
| 25 IndexedDBKeyPath& IndexedDBKeyPath::operator=(const IndexedDBKeyPath& other) = |
| 26 default; |
| 24 | 27 |
| 25 const std::vector<base::string16>& IndexedDBKeyPath::array() const { | 28 const std::vector<base::string16>& IndexedDBKeyPath::array() const { |
| 26 DCHECK(type_ == blink::WebIDBKeyPathTypeArray); | 29 DCHECK(type_ == blink::WebIDBKeyPathTypeArray); |
| 27 return array_; | 30 return array_; |
| 28 } | 31 } |
| 29 | 32 |
| 30 const base::string16& IndexedDBKeyPath::string() const { | 33 const base::string16& IndexedDBKeyPath::string() const { |
| 31 DCHECK(type_ == blink::WebIDBKeyPathTypeString); | 34 DCHECK(type_ == blink::WebIDBKeyPathTypeString); |
| 32 return string_; | 35 return string_; |
| 33 } | 36 } |
| 34 | 37 |
| 35 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath& other) const { | 38 bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath& other) const { |
| 36 if (type_ != other.type_) | 39 if (type_ != other.type_) |
| 37 return false; | 40 return false; |
| 38 | 41 |
| 39 switch (type_) { | 42 switch (type_) { |
| 40 case WebIDBKeyPathTypeNull: | 43 case WebIDBKeyPathTypeNull: |
| 41 return true; | 44 return true; |
| 42 case WebIDBKeyPathTypeString: | 45 case WebIDBKeyPathTypeString: |
| 43 return string_ == other.string_; | 46 return string_ == other.string_; |
| 44 case WebIDBKeyPathTypeArray: | 47 case WebIDBKeyPathTypeArray: |
| 45 return array_ == other.array_; | 48 return array_ == other.array_; |
| 46 } | 49 } |
| 47 NOTREACHED(); | 50 NOTREACHED(); |
| 48 return false; | 51 return false; |
| 49 } | 52 } |
| 50 | 53 |
| 51 } // namespace content | 54 } // namespace content |
| OLD | NEW |