OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/indexed_db/indexed_db_factory_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ASCIIToUTF16( | 250 ASCIIToUTF16( |
251 "Internal error opening backing store " | 251 "Internal error opening backing store " |
252 "for indexedDB.deleteDatabase.")); | 252 "for indexedDB.deleteDatabase.")); |
253 callbacks->OnError(error); | 253 callbacks->OnError(error); |
254 if (s.IsCorruption()) { | 254 if (s.IsCorruption()) { |
255 HandleBackingStoreCorruption(origin_url, error); | 255 HandleBackingStoreCorruption(origin_url, error); |
256 } | 256 } |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 std::vector<base::string16> names = backing_store->GetDatabaseNames(&s); | |
261 if (!s.ok()) { | |
262 DLOG(ERROR) << "Internal error getting database names"; | |
263 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | |
264 "Internal error opening backing store for " | |
265 "indexedDB.deleteDatabase."); | |
266 callbacks->OnError(error); | |
267 backing_store = NULL; | |
268 if (s.IsCorruption()) | |
269 HandleBackingStoreCorruption(origin_url, error); | |
270 return; | |
271 } | |
272 if (!ContainsValue(names, name)) { | |
273 const int64 version = 0; | |
274 callbacks->OnSuccess(version); | |
275 backing_store = NULL; | |
276 ReleaseBackingStore(origin_url, false /* immediate */); | |
277 return; | |
278 } | |
279 | |
280 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( | 260 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( |
281 name, backing_store.get(), this, unique_identifier, &s); | 261 name, backing_store.get(), this, unique_identifier, &s); |
282 if (!database.get()) { | 262 if (!database.get()) { |
283 IndexedDBDatabaseError error( | 263 IndexedDBDatabaseError error( |
284 blink::WebIDBDatabaseExceptionUnknownError, | 264 blink::WebIDBDatabaseExceptionUnknownError, |
285 ASCIIToUTF16( | 265 ASCIIToUTF16( |
286 "Internal error creating database backend for " | 266 "Internal error creating database backend for " |
287 "indexedDB.deleteDatabase.")); | 267 "indexedDB.deleteDatabase.")); |
288 callbacks->OnError(error); | 268 callbacks->OnError(error); |
289 if (s.IsCorruption()) { | 269 if (s.IsCorruption()) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 size_t count(0); | 494 size_t count(0); |
515 | 495 |
516 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); | 496 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); |
517 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 497 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
518 count += it->second->ConnectionCount(); | 498 count += it->second->ConnectionCount(); |
519 | 499 |
520 return count; | 500 return count; |
521 } | 501 } |
522 | 502 |
523 } // namespace content | 503 } // namespace content |
OLD | NEW |