OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "chrome/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 "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/host_content_settings_map.h" | 10 #include "chrome/browser/host_content_settings_map.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 using WebKit::WebIDBKey; | 41 using WebKit::WebIDBKey; |
42 using WebKit::WebIDBKeyRange; | 42 using WebKit::WebIDBKeyRange; |
43 using WebKit::WebIDBObjectStore; | 43 using WebKit::WebIDBObjectStore; |
44 using WebKit::WebIDBTransaction; | 44 using WebKit::WebIDBTransaction; |
45 using WebKit::WebSecurityOrigin; | 45 using WebKit::WebSecurityOrigin; |
46 using WebKit::WebSerializedScriptValue; | 46 using WebKit::WebSerializedScriptValue; |
47 using WebKit::WebVector; | 47 using WebKit::WebVector; |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
| 51 // FIXME: Replace this magic constant once we have a more sophisticated quota |
| 52 // system. |
| 53 static const uint64 kDatabaseQuota = 5 * 1024 * 1024; |
| 54 |
51 template <class T> | 55 template <class T> |
52 void DeleteOnWebKitThread(T* obj) { | 56 void DeleteOnWebKitThread(T* obj) { |
53 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) | 57 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) |
54 delete obj; | 58 delete obj; |
55 } | 59 } |
56 | 60 |
57 } | 61 } |
58 | 62 |
59 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 63 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
60 IPC::Message::Sender* sender, Profile* profile) | 64 IPC::Message::Sender* sender, Profile* profile) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // TODO(jorlow): Change this to the proper error code once we figure out | 282 // TODO(jorlow): Change this to the proper error code once we figure out |
279 // one. | 283 // one. |
280 int error_code = 0; // Defined by the IndexedDB spec. | 284 int error_code = 0; // Defined by the IndexedDB spec. |
281 static string16 error_message = ASCIIToUTF16( | 285 static string16 error_message = ASCIIToUTF16( |
282 "The user denied permission to open the database."); | 286 "The user denied permission to open the database."); |
283 Send(new ViewMsg_IDBCallbacksError(params.response_id_, error_code, | 287 Send(new ViewMsg_IDBCallbacksError(params.response_id_, error_code, |
284 error_message)); | 288 error_message)); |
285 return; | 289 return; |
286 } | 290 } |
287 | 291 |
| 292 DCHECK(kDatabaseQuota == params.maximum_size_); |
288 Context()->GetIDBFactory()->open( | 293 Context()->GetIDBFactory()->open( |
289 params.name_, params.description_, | 294 params.name_, params.description_, |
290 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id_), | 295 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id_), |
291 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL, | 296 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL, |
292 webkit_glue::FilePathToWebString(indexed_db_path)); | 297 webkit_glue::FilePathToWebString(indexed_db_path), kDatabaseQuota); |
293 } | 298 } |
294 | 299 |
295 ////////////////////////////////////////////////////////////////////// | 300 ////////////////////////////////////////////////////////////////////// |
296 // Helper templates. | 301 // Helper templates. |
297 // | 302 // |
298 | 303 |
299 template <typename ObjectType> | 304 template <typename ObjectType> |
300 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 305 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
301 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, | 306 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, |
302 IPC::Message* reply_msg, uint32 message_type) { | 307 IPC::Message* reply_msg, uint32 message_type) { |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 return; | 1087 return; |
1083 | 1088 |
1084 idb_transaction->didCompleteTaskEvents(); | 1089 idb_transaction->didCompleteTaskEvents(); |
1085 } | 1090 } |
1086 | 1091 |
1087 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1092 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1088 int32 object_id) { | 1093 int32 object_id) { |
1089 parent_->DestroyObject( | 1094 parent_->DestroyObject( |
1090 &map_, object_id, ViewHostMsg_IDBTransactionDestroyed::ID); | 1095 &map_, object_id, ViewHostMsg_IDBTransactionDestroyed::ID); |
1091 } | 1096 } |
OLD | NEW |