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/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/process/process.h" | 15 #include "base/process/process.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "content/browser/bad_message.h" | 18 #include "content/browser/bad_message.h" |
19 #include "content/browser/child_process_security_policy_impl.h" | 19 #include "content/browser/child_process_security_policy_impl.h" |
20 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 20 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
21 #include "content/browser/indexed_db/indexed_db_connection.h" | 21 #include "content/browser/indexed_db/indexed_db_connection.h" |
22 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 22 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
23 #include "content/browser/indexed_db/indexed_db_cursor.h" | 23 #include "content/browser/indexed_db/indexed_db_cursor.h" |
24 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 24 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
25 #include "content/browser/indexed_db/indexed_db_metadata.h" | 25 #include "content/browser/indexed_db/indexed_db_metadata.h" |
26 #include "content/browser/indexed_db/indexed_db_observation.h" | |
27 #include "content/browser/indexed_db/indexed_db_observer_changes.h" | |
26 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 28 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
27 #include "content/browser/indexed_db/indexed_db_value.h" | 29 #include "content/browser/indexed_db/indexed_db_value.h" |
28 #include "content/browser/renderer_host/render_message_filter.h" | 30 #include "content/browser/renderer_host/render_message_filter.h" |
29 #include "content/common/indexed_db/indexed_db_messages.h" | 31 #include "content/common/indexed_db/indexed_db_messages.h" |
30 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
32 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
33 #include "content/public/common/result_codes.h" | 35 #include "content/public/common/result_codes.h" |
34 #include "storage/browser/blob/blob_data_builder.h" | 36 #include "storage/browser/blob/blob_data_builder.h" |
35 #include "storage/browser/blob/blob_storage_context.h" | 37 #include "storage/browser/blob/blob_storage_context.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 | 183 |
182 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, | 184 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, |
183 int32_t ipc_thread_id, | 185 int32_t ipc_thread_id, |
184 const url::Origin& origin) { | 186 const url::Origin& origin) { |
185 if (!database_dispatcher_host_) { | 187 if (!database_dispatcher_host_) { |
186 connection->Close(); | 188 connection->Close(); |
187 delete connection; | 189 delete connection; |
188 return -1; | 190 return -1; |
189 } | 191 } |
190 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); | 192 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); |
193 connection->setId(ipc_database_id); | |
191 context()->ConnectionOpened(origin, connection); | 194 context()->ConnectionOpened(origin, connection); |
192 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; | 195 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; |
193 return ipc_database_id; | 196 return ipc_database_id; |
194 } | 197 } |
195 | 198 |
196 void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id, | 199 void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id, |
197 const url::Origin& origin) { | 200 const url::Origin& origin) { |
198 if (!database_dispatcher_host_) | 201 if (!database_dispatcher_host_) |
199 return; | 202 return; |
200 database_dispatcher_host_->transaction_size_map_[host_transaction_id] = 0; | 203 database_dispatcher_host_->transaction_size_map_[host_transaction_id] = 0; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 idb_index_metadata.key_path = web_index_metadata.key_path; | 313 idb_index_metadata.key_path = web_index_metadata.key_path; |
311 idb_index_metadata.unique = web_index_metadata.unique; | 314 idb_index_metadata.unique = web_index_metadata.unique; |
312 idb_index_metadata.multi_entry = web_index_metadata.multi_entry; | 315 idb_index_metadata.multi_entry = web_index_metadata.multi_entry; |
313 idb_store_metadata.indexes.push_back(idb_index_metadata); | 316 idb_store_metadata.indexes.push_back(idb_index_metadata); |
314 } | 317 } |
315 metadata.object_stores.push_back(idb_store_metadata); | 318 metadata.object_stores.push_back(idb_store_metadata); |
316 } | 319 } |
317 return metadata; | 320 return metadata; |
318 } | 321 } |
319 | 322 |
323 ::IndexedDBMsg_ObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges( | |
jsbell
2016/07/11 18:25:33
Is the leading :: needed here? Its only used in Co
palakj1
2016/07/11 22:25:40
Done.
| |
324 std::unique_ptr<content::IndexedDBObserverChanges> changes) { | |
jsbell
2016/07/11 18:25:33
Similarly, I don't think you need content:: here
palakj1
2016/07/11 22:25:40
Done.
| |
325 ::IndexedDBMsg_ObserverChanges idb_changes; | |
326 idb_changes.observation_index = changes->observation_index(); | |
327 for (auto& observation : changes->observations()) { | |
328 idb_changes.observations.push_back( | |
329 ConvertObservation(std::move(observation))); | |
jsbell
2016/07/11 18:25:33
It's subtle that this is freeing the observations
palakj1
2016/07/11 22:25:40
done.
| |
330 } | |
331 return idb_changes; | |
332 } | |
333 | |
334 ::IndexedDBMsg_Observation IndexedDBDispatcherHost::ConvertObservation( | |
335 std::unique_ptr<content::IndexedDBObservation> observation) { | |
jsbell
2016/07/11 18:25:33
Since this is not transferring ownership, can this
palakj1
2016/07/11 22:25:40
Done.
| |
336 // TODO(palakj): Modify function for indexed_db_value. | |
337 ::IndexedDBMsg_Observation idb_observation; | |
338 idb_observation.object_store_id = observation->object_store_id(); | |
339 idb_observation.type = observation->type(); | |
340 idb_observation.key_range = observation->key_range(); | |
341 return idb_observation; | |
342 } | |
343 | |
320 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 344 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
321 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 345 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { |
322 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 346 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
323 | 347 |
324 if (!IsValidOrigin(params.origin)) { | 348 if (!IsValidOrigin(params.origin)) { |
325 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); | 349 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); |
326 return; | 350 return; |
327 } | 351 } |
328 | 352 |
329 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 353 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 DLOG(ERROR) << "Unable to reset prefetch"; | 1093 DLOG(ERROR) << "Unable to reset prefetch"; |
1070 } | 1094 } |
1071 | 1095 |
1072 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1096 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1073 int32_t ipc_object_id) { | 1097 int32_t ipc_object_id) { |
1074 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 1098 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
1075 parent_->DestroyObject(&map_, ipc_object_id); | 1099 parent_->DestroyObject(&map_, ipc_object_id); |
1076 } | 1100 } |
1077 | 1101 |
1078 } // namespace content | 1102 } // namespace content |
OLD | NEW |