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

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

Issue 2506773002: [IndexedDB] Integrating failures and corruption with transaction (Closed)
Patch Set: removed extra log statements Created 4 years 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 // 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "content/browser/indexed_db/indexed_db_backing_store.h" 16 #include "content/browser/indexed_db/indexed_db_backing_store.h"
16 #include "content/browser/indexed_db/indexed_db_context_impl.h" 17 #include "content/browser/indexed_db/indexed_db_context_impl.h"
17 #include "content/browser/indexed_db/indexed_db_database_error.h" 18 #include "content/browser/indexed_db/indexed_db_database_error.h"
18 #include "content/browser/indexed_db/indexed_db_tracing.h" 19 #include "content/browser/indexed_db/indexed_db_tracing.h"
19 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 20 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
21 #include "third_party/leveldatabase/env_chromium.h" 22 #include "third_party/leveldatabase/env_chromium.h"
22 23
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 306 }
306 307
307 void IndexedDBFactoryImpl::HandleBackingStoreCorruption( 308 void IndexedDBFactoryImpl::HandleBackingStoreCorruption(
308 const Origin& origin, 309 const Origin& origin,
309 const IndexedDBDatabaseError& error) { 310 const IndexedDBDatabaseError& error) {
310 // Make a copy of origin as this is likely a reference to a member of a 311 // Make a copy of origin as this is likely a reference to a member of a
311 // backing store which this function will be deleting. 312 // backing store which this function will be deleting.
312 Origin saved_origin(origin); 313 Origin saved_origin(origin);
313 DCHECK(context_); 314 DCHECK(context_);
314 base::FilePath path_base = context_->data_path(); 315 base::FilePath path_base = context_->data_path();
315 IndexedDBBackingStore::RecordCorruptionInfo( 316
316 path_base, saved_origin, base::UTF16ToUTF8(error.message())); 317 // The message may contain the database path, which may be considered
318 // sensitive data, and those strings are passed to the extension, so strip it.
319 std::string sanitized_message = base::UTF16ToUTF8(error.message());
320 base::ReplaceSubstringsAfterOffset(&sanitized_message, 0u,
321 path_base.AsUTF8Unsafe(), "...");
322 IndexedDBBackingStore::RecordCorruptionInfo(path_base, saved_origin,
323 sanitized_message);
317 HandleBackingStoreFailure(saved_origin); 324 HandleBackingStoreFailure(saved_origin);
318 // Note: DestroyBackingStore only deletes LevelDB files, leaving all others, 325 // Note: DestroyBackingStore only deletes LevelDB files, leaving all others,
319 // so our corruption info file will remain. 326 // so our corruption info file will remain.
320 leveldb::Status s = 327 leveldb::Status s =
321 IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin); 328 IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin);
322 if (!s.ok()) 329 if (!s.ok())
323 DLOG(ERROR) << "Unable to delete backing store: " << s.ToString(); 330 DLOG(ERROR) << "Unable to delete backing store: " << s.ToString();
324 } 331 }
325 332
326 bool IndexedDBFactoryImpl::IsDatabaseOpen(const Origin& origin, 333 bool IndexedDBFactoryImpl::IsDatabaseOpen(const Origin& origin,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 size_t count(0); 484 size_t count(0);
478 485
479 OriginDBs range = GetOpenDatabasesForOrigin(origin); 486 OriginDBs range = GetOpenDatabasesForOrigin(origin);
480 for (OriginDBMapIterator it = range.first; it != range.second; ++it) 487 for (OriginDBMapIterator it = range.first; it != range.second; ++it)
481 count += it->second->ConnectionCount(); 488 count += it->second->ConnectionCount();
482 489
483 return count; 490 return count;
484 } 491 }
485 492
486 } // namespace content 493 } // 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