Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBKeyPath.cpp

Issue 2801893008: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in modules/indexeddb (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!IsIdentifier(elements[i])) { 93 if (!IsIdentifier(elements[i])) {
94 error = kIDBKeyPathParseErrorIdentifier; 94 error = kIDBKeyPathParseErrorIdentifier;
95 return; 95 return;
96 } 96 }
97 } 97 }
98 error = kIDBKeyPathParseErrorNone; 98 error = kIDBKeyPathParseErrorNone;
99 } 99 }
100 100
101 IDBKeyPath::IDBKeyPath(const String& string) 101 IDBKeyPath::IDBKeyPath(const String& string)
102 : type_(kStringType), string_(string) { 102 : type_(kStringType), string_(string) {
103 ASSERT(!string_.IsNull()); 103 DCHECK(!string_.IsNull());
104 } 104 }
105 105
106 IDBKeyPath::IDBKeyPath(const Vector<String>& array) 106 IDBKeyPath::IDBKeyPath(const Vector<String>& array)
107 : type_(kArrayType), array_(array) { 107 : type_(kArrayType), array_(array) {
108 #if DCHECK_IS_ON() 108 #if DCHECK_IS_ON()
109 for (size_t i = 0; i < array_.size(); ++i) 109 for (size_t i = 0; i < array_.size(); ++i)
110 ASSERT(!array_[i].IsNull()); 110 DCHECK(!array_[i].IsNull());
111 #endif 111 #endif
112 } 112 }
113 113
114 IDBKeyPath::IDBKeyPath(const StringOrStringSequence& key_path) { 114 IDBKeyPath::IDBKeyPath(const StringOrStringSequence& key_path) {
115 if (key_path.isNull()) { 115 if (key_path.isNull()) {
116 type_ = kNullType; 116 type_ = kNullType;
117 } else if (key_path.isString()) { 117 } else if (key_path.isString()) {
118 type_ = kStringType; 118 type_ = kStringType;
119 string_ = key_path.getAsString(); 119 string_ = key_path.getAsString();
120 ASSERT(!string_.IsNull()); 120 DCHECK(!string_.IsNull());
121 } else { 121 } else {
122 ASSERT(key_path.isStringSequence()); 122 DCHECK(key_path.isStringSequence());
123 type_ = kArrayType; 123 type_ = kArrayType;
124 array_ = key_path.getAsStringSequence(); 124 array_ = key_path.getAsStringSequence();
125 #if DCHECK_IS_ON() 125 #if DCHECK_IS_ON()
126 for (size_t i = 0; i < array_.size(); ++i) 126 for (size_t i = 0; i < array_.size(); ++i)
127 ASSERT(!array_[i].IsNull()); 127 DCHECK(!array_[i].IsNull());
128 #endif 128 #endif
129 } 129 }
130 } 130 }
131 131
132 IDBKeyPath::IDBKeyPath(const WebIDBKeyPath& key_path) { 132 IDBKeyPath::IDBKeyPath(const WebIDBKeyPath& key_path) {
133 switch (key_path.KeyPathType()) { 133 switch (key_path.KeyPathType()) {
134 case kWebIDBKeyPathTypeNull: 134 case kWebIDBKeyPathTypeNull:
135 type_ = kNullType; 135 type_ = kNullType;
136 return; 136 return;
137 137
138 case kWebIDBKeyPathTypeString: 138 case kWebIDBKeyPathTypeString:
139 type_ = kStringType; 139 type_ = kStringType;
140 string_ = key_path.GetString(); 140 string_ = key_path.GetString();
141 return; 141 return;
142 142
143 case kWebIDBKeyPathTypeArray: 143 case kWebIDBKeyPathTypeArray:
144 type_ = kArrayType; 144 type_ = kArrayType;
145 for (size_t i = 0, size = key_path.Array().size(); i < size; ++i) 145 for (size_t i = 0, size = key_path.Array().size(); i < size; ++i)
146 array_.push_back(key_path.Array()[i]); 146 array_.push_back(key_path.Array()[i]);
147 return; 147 return;
148 } 148 }
149 ASSERT_NOT_REACHED(); 149 NOTREACHED();
150 } 150 }
151 151
152 IDBKeyPath::operator WebIDBKeyPath() const { 152 IDBKeyPath::operator WebIDBKeyPath() const {
153 switch (type_) { 153 switch (type_) {
154 case kNullType: 154 case kNullType:
155 return WebIDBKeyPath(); 155 return WebIDBKeyPath();
156 case kStringType: 156 case kStringType:
157 return WebIDBKeyPath(WebString(string_)); 157 return WebIDBKeyPath(WebString(string_));
158 case kArrayType: 158 case kArrayType:
159 return WebIDBKeyPath(array_); 159 return WebIDBKeyPath(array_);
160 } 160 }
161 ASSERT_NOT_REACHED(); 161 NOTREACHED();
162 return WebIDBKeyPath(); 162 return WebIDBKeyPath();
163 } 163 }
164 164
165 bool IDBKeyPath::IsValid() const { 165 bool IDBKeyPath::IsValid() const {
166 switch (type_) { 166 switch (type_) {
167 case kNullType: 167 case kNullType:
168 return false; 168 return false;
169 169
170 case kStringType: 170 case kStringType:
171 return IDBIsValidKeyPath(string_); 171 return IDBIsValidKeyPath(string_);
172 172
173 case kArrayType: 173 case kArrayType:
174 if (array_.IsEmpty()) 174 if (array_.IsEmpty())
175 return false; 175 return false;
176 for (size_t i = 0; i < array_.size(); ++i) { 176 for (size_t i = 0; i < array_.size(); ++i) {
177 if (!IDBIsValidKeyPath(array_[i])) 177 if (!IDBIsValidKeyPath(array_[i]))
178 return false; 178 return false;
179 } 179 }
180 return true; 180 return true;
181 } 181 }
182 ASSERT_NOT_REACHED(); 182 NOTREACHED();
183 return false; 183 return false;
184 } 184 }
185 185
186 bool IDBKeyPath::operator==(const IDBKeyPath& other) const { 186 bool IDBKeyPath::operator==(const IDBKeyPath& other) const {
187 if (type_ != other.type_) 187 if (type_ != other.type_)
188 return false; 188 return false;
189 189
190 switch (type_) { 190 switch (type_) {
191 case kNullType: 191 case kNullType:
192 return true; 192 return true;
193 case kStringType: 193 case kStringType:
194 return string_ == other.string_; 194 return string_ == other.string_;
195 case kArrayType: 195 case kArrayType:
196 return array_ == other.array_; 196 return array_ == other.array_;
197 } 197 }
198 ASSERT_NOT_REACHED(); 198 NOTREACHED();
199 return false; 199 return false;
200 } 200 }
201 201
202 } // namespace blink 202 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/IDBKeyPath.h ('k') | third_party/WebKit/Source/modules/indexeddb/IDBRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698