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 |
260 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( | 280 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( |
261 name, backing_store.get(), this, unique_identifier, &s); | 281 name, backing_store.get(), this, unique_identifier, &s); |
262 if (!database.get()) { | 282 if (!database.get()) { |
263 IndexedDBDatabaseError error( | 283 IndexedDBDatabaseError error( |
264 blink::WebIDBDatabaseExceptionUnknownError, | 284 blink::WebIDBDatabaseExceptionUnknownError, |
265 ASCIIToUTF16( | 285 ASCIIToUTF16( |
266 "Internal error creating database backend for " | 286 "Internal error creating database backend for " |
267 "indexedDB.deleteDatabase.")); | 287 "indexedDB.deleteDatabase.")); |
268 callbacks->OnError(error); | 288 callbacks->OnError(error); |
269 if (s.IsCorruption()) { | 289 if (s.IsCorruption()) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 size_t count(0); | 514 size_t count(0); |
495 | 515 |
496 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); | 516 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); |
497 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 517 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
498 count += it->second->ConnectionCount(); | 518 count += it->second->ConnectionCount(); |
499 | 519 |
500 return count; | 520 return count; |
501 } | 521 } |
502 | 522 |
503 } // namespace content | 523 } // namespace content |
OLD | NEW |