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

Side by Side Diff: content/browser/indexed_db/indexed_db_factory.cc

Issue 303073002: Change instances of s.IsCorruption() to leveldb_env::IsCorruption(s) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix memory leak Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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.h" 5 #include "content/browser/indexed_db/indexed_db_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/indexed_db/indexed_db_backing_store.h" 10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
11 #include "content/browser/indexed_db/indexed_db_context_impl.h" 11 #include "content/browser/indexed_db/indexed_db_context_impl.h"
12 #include "content/browser/indexed_db/indexed_db_database_error.h" 12 #include "content/browser/indexed_db/indexed_db_database_error.h"
13 #include "content/browser/indexed_db/indexed_db_tracing.h" 13 #include "content/browser/indexed_db/indexed_db_tracing.h"
14 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 14 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
15 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 15 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
16 #include "third_party/leveldatabase/env_chromium.h"
16 #include "webkit/common/database/database_identifier.h" 17 #include "webkit/common/database/database_identifier.h"
17 18
18 using base::ASCIIToUTF16; 19 using base::ASCIIToUTF16;
19 20
20 namespace content { 21 namespace content {
21 22
22 const int64 kBackingStoreGracePeriodMs = 2000; 23 const int64 kBackingStoreGracePeriodMs = 2000;
23 24
24 IndexedDBFactory::IndexedDBFactory(IndexedDBContextImpl* context) 25 IndexedDBFactory::IndexedDBFactory(IndexedDBContextImpl* context)
25 : context_(context) {} 26 : context_(context) {}
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 leveldb::Status s; 244 leveldb::Status s;
244 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( 245 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create(
245 name, backing_store, this, unique_identifier, &s); 246 name, backing_store, this, unique_identifier, &s);
246 if (!database) { 247 if (!database) {
247 IndexedDBDatabaseError error( 248 IndexedDBDatabaseError error(
248 blink::WebIDBDatabaseExceptionUnknownError, 249 blink::WebIDBDatabaseExceptionUnknownError,
249 ASCIIToUTF16( 250 ASCIIToUTF16(
250 "Internal error creating database backend for " 251 "Internal error creating database backend for "
251 "indexedDB.deleteDatabase.")); 252 "indexedDB.deleteDatabase."));
252 callbacks->OnError(error); 253 callbacks->OnError(error);
253 if (s.IsCorruption()) 254 if (leveldb_env::IsCorruption(s))
254 HandleBackingStoreCorruption(origin_url, error); 255 HandleBackingStoreCorruption(origin_url, error);
255 return; 256 return;
256 } 257 }
257 258
258 database_map_[unique_identifier] = database; 259 database_map_[unique_identifier] = database;
259 origin_dbs_.insert(std::make_pair(origin_url, database)); 260 origin_dbs_.insert(std::make_pair(origin_url, database));
260 database->DeleteDatabase(callbacks); 261 database->DeleteDatabase(callbacks);
261 RemoveDatabaseFromMaps(unique_identifier); 262 RemoveDatabaseFromMaps(unique_identifier);
262 database = NULL; 263 database = NULL;
263 backing_store = NULL; 264 backing_store = NULL;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 database = IndexedDBDatabase::Create( 430 database = IndexedDBDatabase::Create(
430 name, backing_store, this, unique_identifier, &s); 431 name, backing_store, this, unique_identifier, &s);
431 if (!database) { 432 if (!database) {
432 DLOG(ERROR) << "Unable to create the database"; 433 DLOG(ERROR) << "Unable to create the database";
433 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, 434 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
434 ASCIIToUTF16( 435 ASCIIToUTF16(
435 "Internal error creating " 436 "Internal error creating "
436 "database backend for " 437 "database backend for "
437 "indexedDB.open.")); 438 "indexedDB.open."));
438 connection.callbacks->OnError(error); 439 connection.callbacks->OnError(error);
439 if (s.IsCorruption()) { 440 if (leveldb_env::IsCorruption(s)) {
440 backing_store = NULL; // Closes the LevelDB so that it can be deleted 441 backing_store = NULL; // Closes the LevelDB so that it can be deleted
441 HandleBackingStoreCorruption(origin_url, error); 442 HandleBackingStoreCorruption(origin_url, error);
442 } 443 }
443 return; 444 return;
444 } 445 }
445 } else { 446 } else {
446 database = it->second; 447 database = it->second;
447 } 448 }
448 449
449 if (data_loss != blink::WebIDBDataLossNone) 450 if (data_loss != blink::WebIDBDataLossNone)
(...skipping 18 matching lines...) Expand all
468 469
469 std::pair<OriginDBMapIterator, OriginDBMapIterator> range = 470 std::pair<OriginDBMapIterator, OriginDBMapIterator> range =
470 GetOpenDatabasesForOrigin(origin_url); 471 GetOpenDatabasesForOrigin(origin_url);
471 for (OriginDBMapIterator it = range.first; it != range.second; ++it) 472 for (OriginDBMapIterator it = range.first; it != range.second; ++it)
472 count += it->second->ConnectionCount(); 473 count += it->second->ConnectionCount();
473 474
474 return count; 475 return count;
475 } 476 }
476 477
477 } // namespace content 478 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_unittest.cc ('k') | content/browser/indexed_db/indexed_db_fake_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698