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" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 blob_data_handle = context->AddFinishedBlob(&blob_data_builder); | 253 blob_data_handle = context->AddFinishedBlob(&blob_data_builder); |
254 } else { | 254 } else { |
255 auto iter = blob_data_handle_map_.find(uuid); | 255 auto iter = blob_data_handle_map_.find(uuid); |
256 if (iter != blob_data_handle_map_.end()) { | 256 if (iter != blob_data_handle_map_.end()) { |
257 iter->second.second += 1; | 257 iter->second.second += 1; |
258 return uuid; | 258 return uuid; |
259 } | 259 } |
260 blob_data_handle = context->GetBlobDataFromUUID(uuid); | 260 blob_data_handle = context->GetBlobDataFromUUID(uuid); |
261 } | 261 } |
262 | 262 |
263 DCHECK(!ContainsKey(blob_data_handle_map_, uuid)); | 263 DCHECK(!base::ContainsKey(blob_data_handle_map_, uuid)); |
264 blob_data_handle_map_[uuid] = std::make_pair(blob_data_handle.release(), 1); | 264 blob_data_handle_map_[uuid] = std::make_pair(blob_data_handle.release(), 1); |
265 return uuid; | 265 return uuid; |
266 } | 266 } |
267 | 267 |
268 void IndexedDBDispatcherHost::DropBlobData(const std::string& uuid) { | 268 void IndexedDBDispatcherHost::DropBlobData(const std::string& uuid) { |
269 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 269 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
270 BlobDataHandleMap::iterator iter = blob_data_handle_map_.find(uuid); | 270 BlobDataHandleMap::iterator iter = blob_data_handle_map_.find(uuid); |
271 if (iter != blob_data_handle_map_.end()) { | 271 if (iter != blob_data_handle_map_.end()) { |
272 DCHECK_GE(iter->second.second, 1); | 272 DCHECK_GE(iter->second.second, 1); |
273 if (iter->second.second == 1) { | 273 if (iter->second.second == 1) { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { | 600 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { |
601 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 601 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
602 IndexedDBConnection* connection = | 602 IndexedDBConnection* connection = |
603 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 603 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
604 if (!connection || !connection->IsConnected()) | 604 if (!connection || !connection->IsConnected()) |
605 return; | 605 return; |
606 | 606 |
607 int64_t host_transaction_id = | 607 int64_t host_transaction_id = |
608 parent_->HostTransactionId(params.transaction_id); | 608 parent_->HostTransactionId(params.transaction_id); |
609 | 609 |
610 if (ContainsKey(transaction_database_map_, host_transaction_id)) { | 610 if (base::ContainsKey(transaction_database_map_, host_transaction_id)) { |
611 DLOG(ERROR) << "Duplicate host_transaction_id."; | 611 DLOG(ERROR) << "Duplicate host_transaction_id."; |
612 return; | 612 return; |
613 } | 613 } |
614 | 614 |
615 connection->database()->CreateTransaction( | 615 connection->database()->CreateTransaction( |
616 host_transaction_id, connection, params.object_store_ids, params.mode); | 616 host_transaction_id, connection, params.object_store_ids, params.mode); |
617 transaction_database_map_[host_transaction_id] = params.ipc_database_id; | 617 transaction_database_map_[host_transaction_id] = params.ipc_database_id; |
618 parent_->RegisterTransactionId(host_transaction_id, | 618 parent_->RegisterTransactionId(host_transaction_id, |
619 database_origin_map_[params.ipc_database_id]); | 619 database_origin_map_[params.ipc_database_id]); |
620 } | 620 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 int32_t ipc_database_id, | 904 int32_t ipc_database_id, |
905 int64_t transaction_id) { | 905 int64_t transaction_id) { |
906 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 906 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
907 IndexedDBConnection* connection = | 907 IndexedDBConnection* connection = |
908 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 908 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
909 if (!connection || !connection->IsConnected()) | 909 if (!connection || !connection->IsConnected()) |
910 return; | 910 return; |
911 | 911 |
912 int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); | 912 int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); |
913 // May have been aborted by back end before front-end could request commit. | 913 // May have been aborted by back end before front-end could request commit. |
914 if (!ContainsKey(transaction_size_map_, host_transaction_id)) | 914 if (!base::ContainsKey(transaction_size_map_, host_transaction_id)) |
915 return; | 915 return; |
916 int64_t transaction_size = transaction_size_map_[host_transaction_id]; | 916 int64_t transaction_size = transaction_size_map_[host_transaction_id]; |
917 | 917 |
918 // Always allow empty or delete-only transactions. | 918 // Always allow empty or delete-only transactions. |
919 if (!transaction_size) { | 919 if (!transaction_size) { |
920 connection->database()->Commit(host_transaction_id); | 920 connection->database()->Commit(host_transaction_id); |
921 return; | 921 return; |
922 } | 922 } |
923 | 923 |
924 parent_->context()->quota_manager_proxy()->GetUsageAndQuota( | 924 parent_->context()->quota_manager_proxy()->GetUsageAndQuota( |
(...skipping 11 matching lines...) Expand all Loading... |
936 storage::QuotaStatusCode status, | 936 storage::QuotaStatusCode status, |
937 int64_t usage, | 937 int64_t usage, |
938 int64_t quota) { | 938 int64_t quota) { |
939 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 939 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
940 IndexedDBConnection* connection = map_.Lookup(ipc_database_id); | 940 IndexedDBConnection* connection = map_.Lookup(ipc_database_id); |
941 // May have disconnected while quota check was pending. | 941 // May have disconnected while quota check was pending. |
942 if (!connection || !connection->IsConnected()) | 942 if (!connection || !connection->IsConnected()) |
943 return; | 943 return; |
944 int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); | 944 int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); |
945 // May have aborted while quota check was pending. | 945 // May have aborted while quota check was pending. |
946 if (!ContainsKey(transaction_size_map_, host_transaction_id)) | 946 if (!base::ContainsKey(transaction_size_map_, host_transaction_id)) |
947 return; | 947 return; |
948 int64_t transaction_size = transaction_size_map_[host_transaction_id]; | 948 int64_t transaction_size = transaction_size_map_[host_transaction_id]; |
949 | 949 |
950 if (status == storage::kQuotaStatusOk && | 950 if (status == storage::kQuotaStatusOk && |
951 usage + transaction_size <= quota) { | 951 usage + transaction_size <= quota) { |
952 connection->database()->Commit(host_transaction_id); | 952 connection->database()->Commit(host_transaction_id); |
953 } else { | 953 } else { |
954 connection->database()->Abort( | 954 connection->database()->Abort( |
955 host_transaction_id, | 955 host_transaction_id, |
956 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); | 956 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 DLOG(ERROR) << "Unable to reset prefetch"; | 1094 DLOG(ERROR) << "Unable to reset prefetch"; |
1095 } | 1095 } |
1096 | 1096 |
1097 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1097 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1098 int32_t ipc_object_id) { | 1098 int32_t ipc_object_id) { |
1099 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 1099 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
1100 parent_->DestroyObject(&map_, ipc_object_id); | 1100 parent_->DestroyObject(&map_, ipc_object_id); |
1101 } | 1101 } |
1102 | 1102 |
1103 } // namespace content | 1103 } // namespace content |
OLD | NEW |