Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 using WebKit::WebIDBKey; | 39 using WebKit::WebIDBKey; |
| 40 using WebKit::WebIDBKeyRange; | 40 using WebKit::WebIDBKeyRange; |
| 41 using WebKit::WebIDBObjectStore; | 41 using WebKit::WebIDBObjectStore; |
| 42 using WebKit::WebIDBTransaction; | 42 using WebKit::WebIDBTransaction; |
| 43 using WebKit::WebSecurityOrigin; | 43 using WebKit::WebSecurityOrigin; |
| 44 using WebKit::WebSerializedScriptValue; | 44 using WebKit::WebSerializedScriptValue; |
| 45 using WebKit::WebVector; | 45 using WebKit::WebVector; |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 // FIXME: Replace this magic constant once we have a more sophisticated quota | 49 // FIXME: Delete this magic constant once we've removed sqlite. |
| 50 // system. | 50 static const uint64 kDefaultQuota = 50 * 1024 * 1024; |
|
michaeln
2011/08/25 18:23:17
I wonder about the name of this variable? It only
dgrogan
2011/08/25 23:28:58
Done.
| |
| 51 static const uint64 kDefaultQuota = 5 * 1024 * 1024; | |
| 52 | 51 |
| 53 template <class T> | 52 template <class T> |
| 54 void DeleteOnWebKitThread(T* obj) { | 53 void DeleteOnWebKitThread(T* obj) { |
| 55 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) | 54 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) |
| 56 delete obj; | 55 delete obj; |
| 57 } | 56 } |
| 58 | 57 |
| 59 } | 58 } |
| 60 | 59 |
| 61 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 60 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 } | 201 } |
| 203 | 202 |
| 204 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need | 203 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need |
| 205 // to add some toString method to WebSecurityOrigin that doesn't | 204 // to add some toString method to WebSecurityOrigin that doesn't |
| 206 // return null for them. | 205 // return null for them. |
| 207 WebSecurityOrigin origin( | 206 WebSecurityOrigin origin( |
| 208 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 207 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
| 209 GURL origin_url(origin.toString()); | 208 GURL origin_url(origin.toString()); |
| 210 | 209 |
| 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 212 DCHECK(kDefaultQuota == params.maximum_size); | |
|
michaeln
2011/08/25 18:23:17
since the params.maximum_size value isn't used, it
dgrogan
2011/08/25 23:28:58
Removed.
| |
| 213 | |
| 214 uint64 quota = kDefaultQuota; | |
| 215 if (Context()->IsUnlimitedStorageGranted(origin_url) || | |
| 216 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 217 switches::kUnlimitedQuotaForIndexedDB)) { | |
| 218 // TODO(jorlow): For the IsUnlimitedStorageGranted case, we need some | |
| 219 // way to revoke it. | |
| 220 // TODO(jorlow): Use kint64max once we think we can scale over 1GB. | |
| 221 quota = 1024 * 1024 * 1024; // 1GB. More or less "unlimited". | |
| 222 } | |
| 223 | 211 |
| 224 WebKit::WebIDBFactory::BackingStoreType backingStoreType = | 212 WebKit::WebIDBFactory::BackingStoreType backingStoreType = |
| 225 WebKit::WebIDBFactory::LevelDBBackingStore; | 213 WebKit::WebIDBFactory::LevelDBBackingStore; |
| 226 | 214 |
| 227 if (CommandLine::ForCurrentProcess()->HasSwitch( | 215 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 228 switches::kSQLiteIndexedDatabase)) { | 216 switches::kSQLiteIndexedDatabase)) { |
| 229 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore; | 217 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore; |
| 230 } | 218 } |
| 231 | 219 |
| 232 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 220 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| 233 // created) if this origin is already over quota. | 221 // created) if this origin is already over quota. |
| 234 Context()->GetIDBFactory()->open( | 222 Context()->GetIDBFactory()->open( |
| 235 params.name, | 223 params.name, |
| 236 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, | 224 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, |
| 237 origin_url), | 225 origin_url), |
| 238 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), quota, | 226 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), |
| 239 backingStoreType); | 227 kDefaultQuota, backingStoreType); |
| 240 } | 228 } |
| 241 | 229 |
| 242 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 230 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
| 243 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 231 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
| 244 FilePath base_path = webkit_context_->data_path(); | 232 FilePath base_path = webkit_context_->data_path(); |
| 245 FilePath indexed_db_path; | 233 FilePath indexed_db_path; |
| 246 if (!base_path.empty()) { | 234 if (!base_path.empty()) { |
| 247 indexed_db_path = base_path.Append( | 235 indexed_db_path = base_path.Append( |
| 248 IndexedDBContext::kIndexedDBDirectory); | 236 IndexedDBContext::kIndexedDBDirectory); |
| 249 } | 237 } |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 } | 1052 } |
| 1065 idb_transaction->didCompleteTaskEvents(); | 1053 idb_transaction->didCompleteTaskEvents(); |
| 1066 } | 1054 } |
| 1067 | 1055 |
| 1068 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1056 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1069 int32 object_id) { | 1057 int32 object_id) { |
| 1070 transaction_size_map_.erase(object_id); | 1058 transaction_size_map_.erase(object_id); |
| 1071 transaction_url_map_.erase(object_id); | 1059 transaction_url_map_.erase(object_id); |
| 1072 parent_->DestroyObject(&map_, object_id); | 1060 parent_->DestroyObject(&map_, object_id); |
| 1073 } | 1061 } |
| OLD | NEW |