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.h" | 5 #include "content/common/indexed_db/indexed_db_key.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 (binary.length() * sizeof(std::string::value_type))) {} | 87 (binary.length() * sizeof(std::string::value_type))) {} |
88 | 88 |
89 IndexedDBKey::IndexedDBKey(const base::string16& string) | 89 IndexedDBKey::IndexedDBKey(const base::string16& string) |
90 : type_(WebIDBKeyTypeString), | 90 : type_(WebIDBKeyTypeString), |
91 string_(string), | 91 string_(string), |
92 size_estimate_(kOverheadSize + | 92 size_estimate_(kOverheadSize + |
93 (string.length() * sizeof(base::string16::value_type))) {} | 93 (string.length() * sizeof(base::string16::value_type))) {} |
94 | 94 |
95 IndexedDBKey::~IndexedDBKey() {} | 95 IndexedDBKey::~IndexedDBKey() {} |
96 | 96 |
97 IndexedDBKey::IndexedDBKey(const IndexedDBKey& other) | |
98 : type_(other.type_), | |
99 array_(other.array_), | |
100 binary_(other.binary_), | |
101 string_(other.string_), | |
102 date_(other.date_), | |
103 number_(other.number_), | |
104 size_estimate_(other.size_estimate_) { | |
105 DCHECK((!IsValid() && !other.IsValid()) || CompareTo(other) == 0); | |
106 } | |
107 | |
108 IndexedDBKey& IndexedDBKey::operator=(const IndexedDBKey& other) { | |
109 type_ = other.type_; | |
110 array_ = other.array_; | |
111 binary_ = other.binary_; | |
112 string_ = other.string_; | |
113 date_ = other.date_; | |
114 number_ = other.number_; | |
115 size_estimate_ = other.size_estimate_; | |
116 DCHECK((!IsValid() && !other.IsValid()) || CompareTo(other) == 0); | |
117 return *this; | |
118 } | |
119 | |
120 bool IndexedDBKey::IsValid() const { | 97 bool IndexedDBKey::IsValid() const { |
121 if (type_ == WebIDBKeyTypeInvalid || type_ == WebIDBKeyTypeNull) | 98 if (type_ == WebIDBKeyTypeInvalid || type_ == WebIDBKeyTypeNull) |
122 return false; | 99 return false; |
123 | 100 |
124 if (type_ == WebIDBKeyTypeArray) { | 101 if (type_ == WebIDBKeyTypeArray) { |
125 for (size_t i = 0; i < array_.size(); i++) { | 102 for (size_t i = 0; i < array_.size(); i++) { |
126 if (!array_[i].IsValid()) | 103 if (!array_[i].IsValid()) |
127 return false; | 104 return false; |
128 } | 105 } |
129 } | 106 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 case WebIDBKeyTypeInvalid: | 141 case WebIDBKeyTypeInvalid: |
165 case WebIDBKeyTypeNull: | 142 case WebIDBKeyTypeNull: |
166 case WebIDBKeyTypeMin: | 143 case WebIDBKeyTypeMin: |
167 default: | 144 default: |
168 NOTREACHED(); | 145 NOTREACHED(); |
169 return 0; | 146 return 0; |
170 } | 147 } |
171 } | 148 } |
172 | 149 |
173 } // namespace content | 150 } // namespace content |
OLD | NEW |