| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 backing_stores_with_active_blobs_.find(origin_url); | 167 backing_stores_with_active_blobs_.find(origin_url); |
| 168 if (it != backing_stores_with_active_blobs_.end()) { | 168 if (it != backing_stores_with_active_blobs_.end()) { |
| 169 backing_stores_with_active_blobs_.erase(it); | 169 backing_stores_with_active_blobs_.erase(it); |
| 170 ReleaseBackingStore(origin_url, false /* immediate */); | 170 ReleaseBackingStore(origin_url, false /* immediate */); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 void IndexedDBFactoryImpl::GetDatabaseNames( | 175 void IndexedDBFactoryImpl::GetDatabaseNames( |
| 176 scoped_refptr<IndexedDBCallbacks> callbacks, | 176 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 177 const GURL& origin_url, | 177 const url::Origin& origin, |
| 178 const base::FilePath& data_directory, | 178 const base::FilePath& data_directory, |
| 179 net::URLRequestContext* request_context) { | 179 net::URLRequestContext* request_context) { |
| 180 IDB_TRACE("IndexedDBFactoryImpl::GetDatabaseNames"); | 180 IDB_TRACE("IndexedDBFactoryImpl::GetDatabaseNames"); |
| 181 // TODO(dgrogan): Plumb data_loss back to script eventually? | 181 // TODO(dgrogan): Plumb data_loss back to script eventually? |
| 182 blink::WebIDBDataLoss data_loss; | 182 blink::WebIDBDataLoss data_loss; |
| 183 std::string data_loss_message; | 183 std::string data_loss_message; |
| 184 bool disk_full; | 184 bool disk_full; |
| 185 GURL origin_url(origin.Serialize()); |
| 185 leveldb::Status s; | 186 leveldb::Status s; |
| 186 // TODO(cmumford): Handle this error | 187 // TODO(cmumford): Handle this error |
| 187 scoped_refptr<IndexedDBBackingStore> backing_store = | 188 scoped_refptr<IndexedDBBackingStore> backing_store = |
| 188 OpenBackingStore(origin_url, | 189 OpenBackingStore(origin_url, |
| 189 data_directory, | 190 data_directory, |
| 190 request_context, | 191 request_context, |
| 191 &data_loss, | 192 &data_loss, |
| 192 &data_loss_message, | 193 &data_loss_message, |
| 193 &disk_full, | 194 &disk_full, |
| 194 &s); | 195 &s); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 214 } | 215 } |
| 215 callbacks->OnSuccess(names); | 216 callbacks->OnSuccess(names); |
| 216 backing_store = NULL; | 217 backing_store = NULL; |
| 217 ReleaseBackingStore(origin_url, false /* immediate */); | 218 ReleaseBackingStore(origin_url, false /* immediate */); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void IndexedDBFactoryImpl::DeleteDatabase( | 221 void IndexedDBFactoryImpl::DeleteDatabase( |
| 221 const base::string16& name, | 222 const base::string16& name, |
| 222 net::URLRequestContext* request_context, | 223 net::URLRequestContext* request_context, |
| 223 scoped_refptr<IndexedDBCallbacks> callbacks, | 224 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 224 const GURL& origin_url, | 225 const url::Origin& origin, |
| 225 const base::FilePath& data_directory) { | 226 const base::FilePath& data_directory) { |
| 226 IDB_TRACE("IndexedDBFactoryImpl::DeleteDatabase"); | 227 IDB_TRACE("IndexedDBFactoryImpl::DeleteDatabase"); |
| 228 GURL origin_url(origin.Serialize()); |
| 227 IndexedDBDatabase::Identifier unique_identifier(origin_url, name); | 229 IndexedDBDatabase::Identifier unique_identifier(origin_url, name); |
| 228 IndexedDBDatabaseMap::iterator it = database_map_.find(unique_identifier); | 230 IndexedDBDatabaseMap::iterator it = database_map_.find(unique_identifier); |
| 229 if (it != database_map_.end()) { | 231 if (it != database_map_.end()) { |
| 230 // If there are any connections to the database, directly delete the | 232 // If there are any connections to the database, directly delete the |
| 231 // database. | 233 // database. |
| 232 it->second->DeleteDatabase(callbacks); | 234 it->second->DeleteDatabase(callbacks); |
| 233 return; | 235 return; |
| 234 } | 236 } |
| 235 | 237 |
| 236 // TODO(dgrogan): Plumb data_loss back to script eventually? | 238 // TODO(dgrogan): Plumb data_loss back to script eventually? |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 428 |
| 427 return backing_store; | 429 return backing_store; |
| 428 } | 430 } |
| 429 | 431 |
| 430 return 0; | 432 return 0; |
| 431 } | 433 } |
| 432 | 434 |
| 433 void IndexedDBFactoryImpl::Open(const base::string16& name, | 435 void IndexedDBFactoryImpl::Open(const base::string16& name, |
| 434 const IndexedDBPendingConnection& connection, | 436 const IndexedDBPendingConnection& connection, |
| 435 net::URLRequestContext* request_context, | 437 net::URLRequestContext* request_context, |
| 436 const GURL& origin_url, | 438 const url::Origin& origin, |
| 437 const base::FilePath& data_directory) { | 439 const base::FilePath& data_directory) { |
| 438 IDB_TRACE("IndexedDBFactoryImpl::Open"); | 440 IDB_TRACE("IndexedDBFactoryImpl::Open"); |
| 439 scoped_refptr<IndexedDBDatabase> database; | 441 scoped_refptr<IndexedDBDatabase> database; |
| 442 GURL origin_url(origin.Serialize()); |
| 440 IndexedDBDatabase::Identifier unique_identifier(origin_url, name); | 443 IndexedDBDatabase::Identifier unique_identifier(origin_url, name); |
| 441 IndexedDBDatabaseMap::iterator it = database_map_.find(unique_identifier); | 444 IndexedDBDatabaseMap::iterator it = database_map_.find(unique_identifier); |
| 442 blink::WebIDBDataLoss data_loss = | 445 blink::WebIDBDataLoss data_loss = |
| 443 blink::WebIDBDataLossNone; | 446 blink::WebIDBDataLossNone; |
| 444 std::string data_loss_message; | 447 std::string data_loss_message; |
| 445 bool disk_full = false; | 448 bool disk_full = false; |
| 446 bool was_open = (it != database_map_.end()); | 449 bool was_open = (it != database_map_.end()); |
| 447 if (!was_open) { | 450 if (!was_open) { |
| 448 leveldb::Status s; | 451 leveldb::Status s; |
| 449 scoped_refptr<IndexedDBBackingStore> backing_store = | 452 scoped_refptr<IndexedDBBackingStore> backing_store = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 size_t count(0); | 518 size_t count(0); |
| 516 | 519 |
| 517 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); | 520 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); |
| 518 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 521 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
| 519 count += it->second->ConnectionCount(); | 522 count += it->second->ConnectionCount(); |
| 520 | 523 |
| 521 return count; | 524 return count; |
| 522 } | 525 } |
| 523 | 526 |
| 524 } // namespace content | 527 } // namespace content |
| OLD | NEW |