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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "content/common/indexed_db/indexed_db_messages.h" | 9 #include "content/common/indexed_db/indexed_db_messages.h" |
10 #include "webkit/quota/quota_manager.h" | 10 #include "webkit/quota/quota_manager.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 int32 ipc_response_id, | 42 int32 ipc_response_id, |
43 int64 host_transaction_id, | 43 int64 host_transaction_id, |
44 const GURL& origin_url) | 44 const GURL& origin_url) |
45 : IndexedDBCallbacksBase(dispatcher_host, ipc_thread_id, ipc_response_id), | 45 : IndexedDBCallbacksBase(dispatcher_host, ipc_thread_id, ipc_response_id), |
46 host_transaction_id_(host_transaction_id), | 46 host_transaction_id_(host_transaction_id), |
47 origin_url_(origin_url), | 47 origin_url_(origin_url), |
48 ipc_database_id_(kDatabaseNotAdded) { | 48 ipc_database_id_(kDatabaseNotAdded) { |
49 } | 49 } |
50 | 50 |
51 void IndexedDBCallbacksDatabase::onSuccess( | 51 void IndexedDBCallbacksDatabase::onSuccess( |
52 WebKit::WebIDBDatabase* idb_object) { | |
53 int32 ipc_object_id = ipc_database_id_; | |
54 if (ipc_object_id == kDatabaseNotAdded) { | |
55 ipc_object_id = dispatcher_host()->Add(idb_object, ipc_thread_id(), | |
56 origin_url_); | |
57 } else { | |
58 // We already have this database and don't need a new copy of it. | |
59 delete idb_object; | |
60 } | |
61 dispatcher_host()->Send( | |
62 new IndexedDBMsg_CallbacksSuccessIDBDatabaseOld(ipc_thread_id(), | |
63 ipc_response_id(), | |
64 ipc_object_id)); | |
65 } | |
66 | |
67 void IndexedDBCallbacksDatabase::onSuccess( | |
68 WebKit::WebIDBDatabase* idb_object, | 52 WebKit::WebIDBDatabase* idb_object, |
69 const WebKit::WebIDBMetadata& metadata) { | 53 const WebKit::WebIDBMetadata& metadata) { |
70 int32 ipc_object_id = ipc_database_id_; | 54 int32 ipc_object_id = ipc_database_id_; |
71 if (ipc_object_id == kDatabaseNotAdded) { | 55 if (ipc_object_id == kDatabaseNotAdded) { |
72 ipc_object_id = dispatcher_host()->Add(idb_object, ipc_thread_id(), | 56 ipc_object_id = dispatcher_host()->Add(idb_object, ipc_thread_id(), |
73 origin_url_); | 57 origin_url_); |
74 } else { | 58 } else { |
75 // We already have this database and don't need a new copy of it. | 59 // We already have this database and don't need a new copy of it. |
76 delete idb_object; | 60 delete idb_object; |
77 } | 61 } |
78 IndexedDBDatabaseMetadata idb_metadata = | 62 IndexedDBDatabaseMetadata idb_metadata = |
79 IndexedDBDispatcherHost::ConvertMetadata(metadata); | 63 IndexedDBDispatcherHost::ConvertMetadata(metadata); |
80 | 64 |
81 dispatcher_host()->Send( | 65 dispatcher_host()->Send( |
82 new IndexedDBMsg_CallbacksSuccessIDBDatabase(ipc_thread_id(), | 66 new IndexedDBMsg_CallbacksSuccessIDBDatabase(ipc_thread_id(), |
83 ipc_response_id(), | 67 ipc_response_id(), |
84 ipc_object_id, | 68 ipc_object_id, |
85 idb_metadata)); | 69 idb_metadata)); |
86 } | 70 } |
87 | 71 |
88 void IndexedDBCallbacksDatabase::onUpgradeNeeded( | 72 void IndexedDBCallbacksDatabase::onUpgradeNeeded( |
89 long long old_version, | 73 long long old_version, |
90 WebKit::WebIDBTransaction*, | |
91 WebKit::WebIDBDatabase* database) { | |
92 dispatcher_host()->RegisterTransactionId(host_transaction_id_, origin_url_); | |
93 int32 ipc_database_id = dispatcher_host()->Add(database, ipc_thread_id(), | |
94 origin_url_); | |
95 ipc_database_id_ = ipc_database_id; | |
96 dispatcher_host()->Send( | |
97 new IndexedDBMsg_CallbacksUpgradeNeededOld( | |
98 ipc_thread_id(), ipc_response_id(), | |
99 ipc_database_id, | |
100 old_version)); | |
101 } | |
102 | |
103 void IndexedDBCallbacksDatabase::onUpgradeNeeded( | |
104 long long old_version, | |
105 WebKit::WebIDBDatabase* database, | 74 WebKit::WebIDBDatabase* database, |
106 const WebKit::WebIDBMetadata& metadata) { | 75 const WebKit::WebIDBMetadata& metadata) { |
107 dispatcher_host()->RegisterTransactionId(host_transaction_id_, origin_url_); | 76 dispatcher_host()->RegisterTransactionId(host_transaction_id_, origin_url_); |
108 int32 ipc_database_id = dispatcher_host()->Add(database, ipc_thread_id(), | 77 int32 ipc_database_id = dispatcher_host()->Add(database, ipc_thread_id(), |
109 origin_url_); | 78 origin_url_); |
110 ipc_database_id_ = ipc_database_id; | 79 ipc_database_id_ = ipc_database_id; |
111 IndexedDBDatabaseMetadata idb_metadata = | 80 IndexedDBDatabaseMetadata idb_metadata = |
112 IndexedDBDispatcherHost::ConvertMetadata(metadata); | 81 IndexedDBDispatcherHost::ConvertMetadata(metadata); |
113 dispatcher_host()->Send( | 82 dispatcher_host()->Send( |
114 new IndexedDBMsg_CallbacksUpgradeNeeded( | 83 new IndexedDBMsg_CallbacksUpgradeNeeded( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 210 } |
242 | 211 |
243 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( | 212 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( |
244 const WebKit::WebIDBKey& value) { | 213 const WebKit::WebIDBKey& value) { |
245 dispatcher_host()->Send( | 214 dispatcher_host()->Send( |
246 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( | 215 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( |
247 ipc_thread_id(), ipc_response_id(), IndexedDBKey(value))); | 216 ipc_thread_id(), ipc_response_id(), IndexedDBKey(value))); |
248 } | 217 } |
249 | 218 |
250 } // namespace content | 219 } // namespace content |
OLD | NEW |