Chromium Code Reviews| 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.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_tracing.h" | 13 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 13 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" | 14 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" |
| 14 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 15 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
| 15 #include "webkit/common/database/database_identifier.h" | 16 #include "webkit/common/database/database_identifier.h" |
| 16 | 17 |
| 17 using base::ASCIIToUTF16; | 18 using base::ASCIIToUTF16; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 const int64 kBackingStoreGracePeriodMs = 2000; | 22 const int64 kBackingStoreGracePeriodMs = 2000; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 228 } |
| 228 | 229 |
| 229 void IndexedDBFactory::HandleBackingStoreFailure(const GURL& origin_url) { | 230 void IndexedDBFactory::HandleBackingStoreFailure(const GURL& origin_url) { |
| 230 // NULL after ContextDestroyed() called, and in some unit tests. | 231 // NULL after ContextDestroyed() called, and in some unit tests. |
| 231 if (!context_) | 232 if (!context_) |
| 232 return; | 233 return; |
| 233 context_->ForceClose(origin_url, | 234 context_->ForceClose(origin_url, |
| 234 IndexedDBContextImpl::FORCE_CLOSE_BACKING_STORE_FAILURE); | 235 IndexedDBContextImpl::FORCE_CLOSE_BACKING_STORE_FAILURE); |
| 235 } | 236 } |
| 236 | 237 |
| 238 void IndexedDBFactory::HandleBackingStoreCorruption( | |
| 239 const GURL& origin_url, | |
| 240 const IndexedDBDatabaseError& error) { | |
| 241 // Make a copy of origin_url as this is likely a reference to a member of a | |
| 242 // backing store which this function will be deleting. | |
| 243 GURL saved_origin_url(origin_url); | |
| 244 DCHECK(context_); | |
| 245 base::FilePath path_base = context_->data_path(); | |
| 246 IndexedDBBackingStore::RecordCorruptionInfo( | |
|
jsbell
2014/03/26 18:16:58
Doesn't this write the file into the directory...
| |
| 247 path_base, saved_origin_url, error); | |
| 248 HandleBackingStoreFailure(saved_origin_url); | |
| 249 if (!IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin_url) | |
|
jsbell
2014/03/26 18:16:58
... which this deletes?
cmumford
2014/03/26 21:40:36
No, see second reply in this review.
jsbell
2014/03/26 22:49:00
Got it, thanks.
Maybe add a comment here that the
| |
| 250 .ok()) | |
| 251 DLOG(ERROR) << "Unable to delete backing store"; | |
| 252 } | |
| 253 | |
| 237 bool IndexedDBFactory::IsDatabaseOpen(const GURL& origin_url, | 254 bool IndexedDBFactory::IsDatabaseOpen(const GURL& origin_url, |
| 238 const base::string16& name) const { | 255 const base::string16& name) const { |
| 239 | 256 |
| 240 return !!database_map_.count(IndexedDBDatabase::Identifier(origin_url, name)); | 257 return !!database_map_.count(IndexedDBDatabase::Identifier(origin_url, name)); |
| 241 } | 258 } |
| 242 | 259 |
| 243 bool IndexedDBFactory::IsBackingStoreOpen(const GURL& origin_url) const { | 260 bool IndexedDBFactory::IsBackingStoreOpen(const GURL& origin_url) const { |
| 244 return backing_store_map_.find(origin_url) != backing_store_map_.end(); | 261 return backing_store_map_.find(origin_url) != backing_store_map_.end(); |
| 245 } | 262 } |
| 246 | 263 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 | 382 |
| 366 std::pair<OriginDBMapIterator, OriginDBMapIterator> range = | 383 std::pair<OriginDBMapIterator, OriginDBMapIterator> range = |
| 367 GetOpenDatabasesForOrigin(origin_url); | 384 GetOpenDatabasesForOrigin(origin_url); |
| 368 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 385 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
| 369 count += it->second->ConnectionCount(); | 386 count += it->second->ConnectionCount(); |
| 370 | 387 |
| 371 return count; | 388 return count; |
| 372 } | 389 } |
| 373 | 390 |
| 374 } // namespace content | 391 } // namespace content |
| OLD | NEW |