OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_callbacks.h" | 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
6 | 6 |
7 #include "content/common/indexed_db/indexed_db_messages.h" | 7 #include "content/common/indexed_db/indexed_db_messages.h" |
8 #include "webkit/quota/quota_manager.h" | 8 #include "webkit/quota/quota_manager.h" |
9 | 9 |
10 using content::IndexedDBKey; | 10 using content::IndexedDBKey; |
11 using content::IndexedDBKeyPath; | 11 using content::IndexedDBKeyPath; |
12 using content::SerializedScriptValue; | 12 using content::SerializedScriptValue; |
13 | 13 |
14 IndexedDBCallbacksBase::IndexedDBCallbacksBase( | 14 IndexedDBCallbacksBase::IndexedDBCallbacksBase( |
15 IndexedDBDispatcherHost* dispatcher_host, | 15 IndexedDBDispatcherHost* dispatcher_host, |
16 int32 thread_id, | 16 int32 thread_id, |
17 int32 response_id) | 17 int32 response_id) |
18 : dispatcher_host_(dispatcher_host), | 18 : dispatcher_host_(dispatcher_host), |
19 response_id_(response_id), | 19 response_id_(response_id), |
20 thread_id_(thread_id) { | 20 thread_id_(thread_id) { |
21 } | 21 } |
22 | 22 |
23 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} | 23 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} |
24 | 24 |
25 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) { | 25 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) { |
26 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( | 26 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( |
27 thread_id_, response_id_, error.code(), error.message())); | 27 thread_id_, response_id_, error.code(), error.message())); |
28 } | 28 } |
29 | 29 |
| 30 void IndexedDBCallbacksBase::onBlocked(long long old_version) { |
| 31 dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked( |
| 32 thread_id_, response_id_, old_version)); |
| 33 } |
| 34 |
30 void IndexedDBCallbacksBase::onBlocked() { | 35 void IndexedDBCallbacksBase::onBlocked() { |
31 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(thread_id_, | 36 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(thread_id_, |
32 response_id_)); | 37 response_id_)); |
33 } | 38 } |
34 | 39 |
| 40 template<> |
| 41 void IndexedDBCallbacks<WebKit::WebIDBDatabase>::onUpgradeNeeded( |
| 42 long long old_version, |
| 43 WebKit::WebIDBTransaction* transaction, |
| 44 WebKit::WebIDBDatabase* database) { |
| 45 int32 transaction_id = dispatcher_host()->Add(transaction, thread_id(), |
| 46 origin_url_); |
| 47 int32 database_id = dispatcher_host()->Add(database, thread_id(), |
| 48 origin_url_); |
| 49 database_id_ = database_id; |
| 50 dispatcher_host()->Send( |
| 51 new IndexedDBMsg_CallbacksUpgradeNeeded( |
| 52 thread_id(), response_id(), transaction_id, database_id, |
| 53 old_version)); |
| 54 } |
| 55 |
35 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 56 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
36 WebKit::WebIDBCursor* idb_object) { | 57 WebKit::WebIDBCursor* idb_object) { |
37 int32 object_id = dispatcher_host()->Add(idb_object); | 58 int32 object_id = dispatcher_host()->Add(idb_object); |
38 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; | 59 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; |
39 params.thread_id = thread_id(); | 60 params.thread_id = thread_id(); |
40 params.response_id = response_id(); | 61 params.response_id = response_id(); |
41 params.cursor_id = object_id; | 62 params.cursor_id = object_id; |
42 params.key = IndexedDBKey(idb_object->key()); | 63 params.key = IndexedDBKey(idb_object->key()); |
43 params.primary_key = IndexedDBKey(idb_object->primaryKey()); | 64 params.primary_key = IndexedDBKey(idb_object->primaryKey()); |
44 params.serialized_value = SerializedScriptValue(idb_object->value()); | 65 params.serialized_value = SerializedScriptValue(idb_object->value()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 148 |
128 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 149 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( |
129 const WebKit::WebSerializedScriptValue& value, | 150 const WebKit::WebSerializedScriptValue& value, |
130 const WebKit::WebIDBKey& primaryKey, | 151 const WebKit::WebIDBKey& primaryKey, |
131 const WebKit::WebIDBKeyPath& keyPath) { | 152 const WebKit::WebIDBKeyPath& keyPath) { |
132 dispatcher_host()->Send( | 153 dispatcher_host()->Send( |
133 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey( | 154 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey( |
134 thread_id(), response_id(), SerializedScriptValue(value), | 155 thread_id(), response_id(), SerializedScriptValue(value), |
135 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); | 156 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); |
136 } | 157 } |
OLD | NEW |