Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: content/browser/indexed_db/indexed_db_dispatcher_host.cc

Issue 2160163002: [IndexedDB] Propogating Changes to Observer : Browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expected tests updated Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_observation.h"
28 #include "content/browser/indexed_db/indexed_db_observer_changes.h"
26 #include "content/browser/indexed_db/indexed_db_pending_connection.h" 29 #include "content/browser/indexed_db/indexed_db_pending_connection.h"
27 #include "content/browser/indexed_db/indexed_db_value.h" 30 #include "content/browser/indexed_db/indexed_db_value.h"
28 #include "content/browser/renderer_host/render_message_filter.h" 31 #include "content/browser/renderer_host/render_message_filter.h"
29 #include "content/common/indexed_db/indexed_db_messages.h" 32 #include "content/common/indexed_db/indexed_db_messages.h"
30 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
32 #include "content/public/common/content_switches.h" 35 #include "content/public/common/content_switches.h"
33 #include "content/public/common/result_codes.h" 36 #include "content/public/common/result_codes.h"
34 #include "storage/browser/blob/blob_data_builder.h" 37 #include "storage/browser/blob/blob_data_builder.h"
35 #include "storage/browser/blob/blob_storage_context.h" 38 #include "storage/browser/blob/blob_storage_context.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 184
182 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, 185 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection,
183 int32_t ipc_thread_id, 186 int32_t ipc_thread_id,
184 const url::Origin& origin) { 187 const url::Origin& origin) {
185 if (!database_dispatcher_host_) { 188 if (!database_dispatcher_host_) {
186 connection->Close(); 189 connection->Close();
187 delete connection; 190 delete connection;
188 return -1; 191 return -1;
189 } 192 }
190 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); 193 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection);
194 connection->set_id(ipc_database_id);
191 context()->ConnectionOpened(origin, connection); 195 context()->ConnectionOpened(origin, connection);
192 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin; 196 database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin;
193 return ipc_database_id; 197 return ipc_database_id;
194 } 198 }
195 199
196 void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id, 200 void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id,
197 const url::Origin& origin) { 201 const url::Origin& origin) {
198 if (!database_dispatcher_host_) 202 if (!database_dispatcher_host_)
199 return; 203 return;
200 database_dispatcher_host_->transaction_size_map_[host_transaction_id] = 0; 204 database_dispatcher_host_->transaction_size_map_[host_transaction_id] = 0;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 idb_index_metadata.key_path = web_index_metadata.key_path; 314 idb_index_metadata.key_path = web_index_metadata.key_path;
311 idb_index_metadata.unique = web_index_metadata.unique; 315 idb_index_metadata.unique = web_index_metadata.unique;
312 idb_index_metadata.multi_entry = web_index_metadata.multi_entry; 316 idb_index_metadata.multi_entry = web_index_metadata.multi_entry;
313 idb_store_metadata.indexes.push_back(idb_index_metadata); 317 idb_store_metadata.indexes.push_back(idb_index_metadata);
314 } 318 }
315 metadata.object_stores.push_back(idb_store_metadata); 319 metadata.object_stores.push_back(idb_store_metadata);
316 } 320 }
317 return metadata; 321 return metadata;
318 } 322 }
319 323
324 IndexedDBMsg_ObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges(
325 std::unique_ptr<IndexedDBObserverChanges> changes) {
326 IndexedDBMsg_ObserverChanges idb_changes;
327 idb_changes.observation_index = changes->release_observation_indices_map();
328 for (const auto& observation : changes->release_observations())
329 idb_changes.observations.push_back(ConvertObservation(observation.get()));
330 return idb_changes;
331 }
332
333 IndexedDBMsg_Observation IndexedDBDispatcherHost::ConvertObservation(
334 const IndexedDBObservation* observation) {
335 // TODO(palakj): Modify function for indexed_db_value. Issue crbug.com/609934.
336 IndexedDBMsg_Observation idb_observation;
337 idb_observation.object_store_id = observation->object_store_id();
338 idb_observation.type = observation->type();
339 idb_observation.key_range = observation->key_range();
340 return idb_observation;
341 }
342
320 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 343 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
321 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 344 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
322 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 345 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
323 346
324 if (!IsValidOrigin(params.origin)) { 347 if (!IsValidOrigin(params.origin)) {
325 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); 348 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
326 return; 349 return;
327 } 350 }
328 351
329 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 352 base::FilePath indexed_db_path = indexed_db_context_->data_path();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return; 648 return;
626 if (connection->IsConnected()) 649 if (connection->IsConnected())
627 connection->Close(); 650 connection->Close();
628 parent_->context()->ConnectionClosed(database_origin_map_[ipc_object_id], 651 parent_->context()->ConnectionClosed(database_origin_map_[ipc_object_id],
629 connection); 652 connection);
630 database_origin_map_.erase(ipc_object_id); 653 database_origin_map_.erase(ipc_object_id);
631 parent_->DestroyObject(&map_, ipc_object_id); 654 parent_->DestroyObject(&map_, ipc_object_id);
632 } 655 }
633 656
634 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve( 657 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve(
635 int32_t ipc_database_id, 658 const IndexedDBHostMsg_DatabaseObserve_Params& params) {
636 int64_t transaction_id,
637 int32_t observer_id) {
638 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 659 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
639 IndexedDBConnection* connection = 660 IndexedDBConnection* connection =
640 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 661 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
641 if (!connection || !connection->IsConnected()) 662 if (!connection || !connection->IsConnected())
642 return; 663 return;
664 IndexedDBObserver::Options options(params.include_transaction,
665 params.no_records, params.values,
666 params.operation_types);
643 connection->database()->AddPendingObserver( 667 connection->database()->AddPendingObserver(
644 parent_->HostTransactionId(transaction_id), observer_id); 668 parent_->HostTransactionId(params.transaction_id), params.observer_id,
669 options);
645 } 670 }
646 671
647 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve( 672 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve(
648 int32_t ipc_database_id, 673 int32_t ipc_database_id,
649 const std::vector<int32_t>& observer_ids_to_remove) { 674 const std::vector<int32_t>& observer_ids_to_remove) {
650 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 675 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
651 DCHECK(!observer_ids_to_remove.empty()); 676 DCHECK(!observer_ids_to_remove.empty());
652 IndexedDBConnection* connection = 677 IndexedDBConnection* connection =
653 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 678 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
654 if (!connection || !connection->IsConnected()) 679 if (!connection || !connection->IsConnected())
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 DLOG(ERROR) << "Unable to reset prefetch"; 1094 DLOG(ERROR) << "Unable to reset prefetch";
1070 } 1095 }
1071 1096
1072 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1097 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1073 int32_t ipc_object_id) { 1098 int32_t ipc_object_id) {
1074 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1099 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1075 parent_->DestroyObject(&map_, ipc_object_id); 1100 parent_->DestroyObject(&map_, ipc_object_id);
1076 } 1101 }
1077 1102
1078 } // namespace content 1103 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.h ('k') | content/browser/indexed_db/indexed_db_observation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698