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_callbacks.h" | 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
6 | 6 |
7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
8 #include "webkit/quota/quota_manager.h" | 8 #include "webkit/quota/quota_manager.h" |
9 | 9 |
10 IndexedDBCallbacksBase::IndexedDBCallbacksBase( | 10 IndexedDBCallbacksBase::IndexedDBCallbacksBase( |
11 IndexedDBDispatcherHost* dispatcher_host, | 11 IndexedDBDispatcherHost* dispatcher_host, |
| 12 int32 thread_id, |
12 int32 response_id) | 13 int32 response_id) |
13 : dispatcher_host_(dispatcher_host), | 14 : dispatcher_host_(dispatcher_host), |
14 response_id_(response_id) { | 15 response_id_(response_id), |
| 16 thread_id_(thread_id) { |
15 } | 17 } |
16 | 18 |
17 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} | 19 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} |
18 | 20 |
19 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) { | 21 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) { |
20 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( | 22 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( |
21 response_id_, error.code(), error.message())); | 23 thread_id_, response_id_, error.code(), error.message())); |
22 } | 24 } |
23 | 25 |
24 void IndexedDBCallbacksBase::onBlocked() { | 26 void IndexedDBCallbacksBase::onBlocked() { |
25 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(response_id_)); | 27 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(thread_id_, |
| 28 response_id_)); |
26 } | 29 } |
27 | 30 |
28 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 31 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
29 WebKit::WebIDBCursor* idb_object) { | 32 WebKit::WebIDBCursor* idb_object) { |
30 int32 object_id = dispatcher_host()->Add(idb_object); | 33 int32 object_id = dispatcher_host()->Add(idb_object); |
31 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor( | 34 IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; |
32 response_id(), object_id, IndexedDBKey(idb_object->key()), | 35 params.thread_id = thread_id(); |
33 IndexedDBKey(idb_object->primaryKey()), | 36 params.response_id = response_id(); |
34 content::SerializedScriptValue(idb_object->value()))); | 37 params.cursor_id = object_id; |
| 38 params.key = IndexedDBKey(idb_object->key()); |
| 39 params.primary_key = IndexedDBKey(idb_object->primaryKey()); |
| 40 params.serialized_value = content::SerializedScriptValue(idb_object->value()); |
| 41 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); |
35 } | 42 } |
36 | 43 |
37 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( | 44 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( |
38 const WebKit::WebSerializedScriptValue& value) { | 45 const WebKit::WebSerializedScriptValue& value) { |
39 dispatcher_host()->Send( | 46 dispatcher_host()->Send( |
40 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 47 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
41 response_id(), content::SerializedScriptValue(value))); | 48 thread_id(), response_id(), content::SerializedScriptValue(value))); |
42 } | 49 } |
43 | 50 |
44 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { | 51 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { |
45 DCHECK(cursor_id_ != -1); | 52 DCHECK(cursor_id_ != -1); |
46 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( | 53 WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( |
47 cursor_id_); | 54 cursor_id_); |
48 | 55 |
49 DCHECK(idb_cursor); | 56 DCHECK(idb_cursor); |
50 if (!idb_cursor) | 57 if (!idb_cursor) |
51 return; | 58 return; |
| 59 IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; |
| 60 params.thread_id = thread_id(); |
| 61 params.response_id = response_id(); |
| 62 params.cursor_id = cursor_id_; |
| 63 params.key = IndexedDBKey(idb_cursor->key()); |
| 64 params.primary_key = IndexedDBKey(idb_cursor->primaryKey()); |
| 65 params.serialized_value = content::SerializedScriptValue(idb_cursor->value()); |
52 | 66 |
53 dispatcher_host()->Send( | 67 dispatcher_host()->Send( |
54 new IndexedDBMsg_CallbacksSuccessCursorContinue( | 68 new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); |
55 response_id(), | |
56 cursor_id_, | |
57 IndexedDBKey(idb_cursor->key()), | |
58 IndexedDBKey(idb_cursor->primaryKey()), | |
59 content::SerializedScriptValue(idb_cursor->value()))); | |
60 } | 69 } |
61 | 70 |
62 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( | 71 void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithPrefetch( |
63 const WebKit::WebVector<WebKit::WebIDBKey>& keys, | 72 const WebKit::WebVector<WebKit::WebIDBKey>& keys, |
64 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, | 73 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, |
65 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { | 74 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values) { |
66 DCHECK(cursor_id_ != -1); | 75 DCHECK(cursor_id_ != -1); |
67 | 76 |
68 std::vector<IndexedDBKey> msgKeys; | 77 std::vector<IndexedDBKey> msgKeys; |
69 std::vector<IndexedDBKey> msgPrimaryKeys; | 78 std::vector<IndexedDBKey> msgPrimaryKeys; |
70 std::vector<content::SerializedScriptValue> msgValues; | 79 std::vector<content::SerializedScriptValue> msgValues; |
71 | 80 |
72 for (size_t i = 0; i < keys.size(); ++i) { | 81 for (size_t i = 0; i < keys.size(); ++i) { |
73 msgKeys.push_back(IndexedDBKey(keys[i])); | 82 msgKeys.push_back(IndexedDBKey(keys[i])); |
74 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); | 83 msgPrimaryKeys.push_back(IndexedDBKey(primaryKeys[i])); |
75 msgValues.push_back(content::SerializedScriptValue(values[i])); | 84 msgValues.push_back(content::SerializedScriptValue(values[i])); |
76 } | 85 } |
77 | 86 |
| 87 IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; |
| 88 params.thread_id = thread_id(); |
| 89 params.response_id = response_id(); |
| 90 params.cursor_id = cursor_id_; |
| 91 params.keys = msgKeys; |
| 92 params.primary_keys = msgPrimaryKeys; |
| 93 params.values = msgValues; |
78 dispatcher_host()->Send( | 94 dispatcher_host()->Send( |
79 new IndexedDBMsg_CallbacksSuccessCursorPrefetch( | 95 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(params)); |
80 response_id(), | |
81 cursor_id_, | |
82 msgKeys, | |
83 msgPrimaryKeys, | |
84 msgValues)); | |
85 } | 96 } |
86 | 97 |
87 void IndexedDBCallbacks<WebKit::WebIDBKey>::onSuccess( | 98 void IndexedDBCallbacks<WebKit::WebIDBKey>::onSuccess( |
88 const WebKit::WebIDBKey& value) { | 99 const WebKit::WebIDBKey& value) { |
89 dispatcher_host()->Send( | 100 dispatcher_host()->Send( |
90 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( | 101 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( |
91 response_id(), IndexedDBKey(value))); | 102 thread_id(), response_id(), IndexedDBKey(value))); |
92 } | 103 } |
93 | 104 |
94 void IndexedDBCallbacks<WebKit::WebDOMStringList>::onSuccess( | 105 void IndexedDBCallbacks<WebKit::WebDOMStringList>::onSuccess( |
95 const WebKit::WebDOMStringList& value) { | 106 const WebKit::WebDOMStringList& value) { |
96 | 107 |
97 std::vector<string16> list; | 108 std::vector<string16> list; |
98 for (unsigned i = 0; i < value.length(); ++i) | 109 for (unsigned i = 0; i < value.length(); ++i) |
99 list.push_back(value.item(i)); | 110 list.push_back(value.item(i)); |
100 | 111 |
101 dispatcher_host()->Send( | 112 dispatcher_host()->Send( |
102 new IndexedDBMsg_CallbacksSuccessStringList( | 113 new IndexedDBMsg_CallbacksSuccessStringList( |
103 response_id(), list)); | 114 thread_id(), response_id(), list)); |
104 } | 115 } |
105 | 116 |
106 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 117 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( |
107 const WebKit::WebSerializedScriptValue& value) { | 118 const WebKit::WebSerializedScriptValue& value) { |
108 dispatcher_host()->Send( | 119 dispatcher_host()->Send( |
109 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | 120 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
110 response_id(), content::SerializedScriptValue(value))); | 121 thread_id(), response_id(), content::SerializedScriptValue(value))); |
111 } | 122 } |
OLD | NEW |