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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 // static | 216 // static |
217 uint32 IndexedDBDispatcherHost::TransactionIdToProcessId( | 217 uint32 IndexedDBDispatcherHost::TransactionIdToProcessId( |
218 int64 host_transaction_id) { | 218 int64 host_transaction_id) { |
219 return (host_transaction_id >> 32) & 0xffffffff; | 219 return (host_transaction_id >> 32) & 0xffffffff; |
220 } | 220 } |
221 | 221 |
222 std::string IndexedDBDispatcherHost::HoldBlobData( | 222 std::string IndexedDBDispatcherHost::HoldBlobData( |
223 const IndexedDBBlobInfo& blob_info) { | 223 const IndexedDBBlobInfo& blob_info) { |
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 224 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
225 std::string uuid = blob_info.uuid(); | 225 std::string uuid = blob_info.uuid(); |
226 storage::BlobStorageContext* context = blob_storage_context_->context(); | 226 storage::BlobStorageContext* context = blob_storage_context_->context(); |
227 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 227 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
228 if (uuid.empty()) { | 228 if (uuid.empty()) { |
229 uuid = base::GenerateGUID(); | 229 uuid = base::GenerateGUID(); |
230 storage::BlobDataBuilder blob_data_builder(uuid); | 230 storage::BlobDataBuilder blob_data_builder(uuid); |
231 blob_data_builder.set_content_type(base::UTF16ToUTF8(blob_info.type())); | 231 blob_data_builder.set_content_type(base::UTF16ToUTF8(blob_info.type())); |
232 blob_data_builder.AppendFile(blob_info.file_path(), 0, blob_info.size(), | 232 blob_data_builder.AppendFile(blob_info.file_path(), 0, blob_info.size(), |
233 blob_info.last_modified()); | 233 blob_info.last_modified()); |
234 blob_data_handle = context->AddFinishedBlob(&blob_data_builder); | 234 blob_data_handle = context->AddFinishedBlob(&blob_data_builder); |
235 } else { | 235 } else { |
236 auto iter = blob_data_handle_map_.find(uuid); | 236 auto iter = blob_data_handle_map_.find(uuid); |
237 if (iter != blob_data_handle_map_.end()) { | 237 if (iter != blob_data_handle_map_.end()) { |
238 iter->second.second += 1; | 238 iter->second.second += 1; |
239 return uuid; | 239 return uuid; |
240 } | 240 } |
241 blob_data_handle = context->GetBlobDataFromUUID(uuid); | 241 blob_data_handle = context->GetBlobDataFromUUID(uuid); |
242 } | 242 } |
243 | 243 |
244 DCHECK(!ContainsKey(blob_data_handle_map_, uuid)); | 244 DCHECK(!ContainsKey(blob_data_handle_map_, uuid)); |
245 blob_data_handle_map_[uuid] = std::make_pair(blob_data_handle.release(), 1); | 245 blob_data_handle_map_[uuid] = std::make_pair(blob_data_handle.release(), 1); |
246 return uuid; | 246 return uuid; |
247 } | 247 } |
248 | 248 |
249 void IndexedDBDispatcherHost::DropBlobData(const std::string& uuid) { | 249 void IndexedDBDispatcherHost::DropBlobData(const std::string& uuid) { |
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 250 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
251 BlobDataHandleMap::iterator iter = blob_data_handle_map_.find(uuid); | 251 BlobDataHandleMap::iterator iter = blob_data_handle_map_.find(uuid); |
252 if (iter != blob_data_handle_map_.end()) { | 252 if (iter != blob_data_handle_map_.end()) { |
253 DCHECK_GE(iter->second.second, 1); | 253 DCHECK_GE(iter->second.second, 1); |
254 if (iter->second.second == 1) { | 254 if (iter->second.second == 1) { |
255 delete iter->second.first; | 255 delete iter->second.first; |
256 blob_data_handle_map_.erase(iter); | 256 blob_data_handle_map_.erase(iter); |
257 } else { | 257 } else { |
258 iter->second.second -= 1; | 258 iter->second.second -= 1; |
259 } | 259 } |
260 } else { | 260 } else { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // OnPutHelper exists only to allow us to hop threads while holding a reference | 371 // OnPutHelper exists only to allow us to hop threads while holding a reference |
372 // to the IndexedDBDispatcherHost. | 372 // to the IndexedDBDispatcherHost. |
373 void IndexedDBDispatcherHost::OnPutHelper( | 373 void IndexedDBDispatcherHost::OnPutHelper( |
374 const IndexedDBHostMsg_DatabasePut_Params& params, | 374 const IndexedDBHostMsg_DatabasePut_Params& params, |
375 std::vector<storage::BlobDataHandle*> handles) { | 375 std::vector<storage::BlobDataHandle*> handles) { |
376 database_dispatcher_host_->OnPut(params, handles); | 376 database_dispatcher_host_->OnPut(params, handles); |
377 } | 377 } |
378 | 378 |
379 void IndexedDBDispatcherHost::OnAckReceivedBlobs( | 379 void IndexedDBDispatcherHost::OnAckReceivedBlobs( |
380 const std::vector<std::string>& uuids) { | 380 const std::vector<std::string>& uuids) { |
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 381 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
382 for (const auto& uuid : uuids) | 382 for (const auto& uuid : uuids) |
383 DropBlobData(uuid); | 383 DropBlobData(uuid); |
384 } | 384 } |
385 | 385 |
386 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, | 386 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, |
387 bool committed) { | 387 bool committed) { |
388 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 388 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
389 if (!database_dispatcher_host_) | 389 if (!database_dispatcher_host_) |
390 return; | 390 return; |
391 TransactionIDToURLMap& transaction_url_map = | 391 TransactionIDToURLMap& transaction_url_map = |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 } | 1025 } |
1026 | 1026 |
1027 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1027 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1028 int32 ipc_object_id) { | 1028 int32 ipc_object_id) { |
1029 DCHECK( | 1029 DCHECK( |
1030 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1030 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
1031 parent_->DestroyObject(&map_, ipc_object_id); | 1031 parent_->DestroyObject(&map_, ipc_object_id); |
1032 } | 1032 } |
1033 | 1033 |
1034 } // namespace content | 1034 } // namespace content |
OLD | NEW |