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

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

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: Post dmurph review 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_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
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
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 ::IndexedDBObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges(
324 std::unique_ptr<content::IndexedDBObserverChanges> changes) {
325 ::IndexedDBObserverChanges idb_changes;
326 // TODO(palakj): Move the map instead of copying?
327 idb_changes.observation_index = changes->observation_index();
dmurph 2016/07/08 23:51:40 Since you grab a unique_ptr, you can safely do an
palakj1 2016/07/11 05:33:26 Done.
328 for (auto& iter : changes->observations()) {
329 idb_changes.observations.push_back(ConvertObservation(std::move(iter)));
330 }
331 return idb_changes;
332 }
333
334 ::IndexedDBObservation IndexedDBDispatcherHost::ConvertObservation(
335 std::unique_ptr<content::IndexedDBObservation> observation) {
336 // TODO(palakj): Modify function for different observation constructors.
337 ::IndexedDBObservation idb_observation;
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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 DLOG(ERROR) << "Unable to reset prefetch"; 1092 DLOG(ERROR) << "Unable to reset prefetch";
1070 } 1093 }
1071 1094
1072 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1095 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1073 int32_t ipc_object_id) { 1096 int32_t ipc_object_id) {
1074 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1097 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1075 parent_->DestroyObject(&map_, ipc_object_id); 1098 parent_->DestroyObject(&map_, ipc_object_id);
1076 } 1099 }
1077 1100
1078 } // namespace content 1101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698