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_callbacks.h" | 5 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
13 #include "content/browser/fileapi/fileapi_message_filter.h" | 13 #include "content/browser/fileapi/fileapi_message_filter.h" |
14 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 14 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
15 #include "content/browser/indexed_db/indexed_db_connection.h" | 15 #include "content/browser/indexed_db/indexed_db_connection.h" |
16 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 16 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
17 #include "content/browser/indexed_db/indexed_db_cursor.h" | 17 #include "content/browser/indexed_db/indexed_db_cursor.h" |
18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
19 #include "content/browser/indexed_db/indexed_db_database_error.h" | 19 #include "content/browser/indexed_db/indexed_db_database_error.h" |
20 #include "content/browser/indexed_db/indexed_db_metadata.h" | 20 #include "content/browser/indexed_db/indexed_db_metadata.h" |
21 #include "content/browser/indexed_db/indexed_db_value.h" | 21 #include "content/browser/indexed_db/indexed_db_value.h" |
22 #include "content/common/indexed_db/indexed_db_constants.h" | 22 #include "content/common/indexed_db/indexed_db_constants.h" |
23 #include "content/common/indexed_db/indexed_db_messages.h" | 23 #include "content/common/indexed_db/indexed_db_messages.h" |
24 #include "webkit/browser/blob/blob_storage_context.h" | 24 #include "storage/browser/blob/blob_storage_context.h" |
25 #include "webkit/browser/quota/quota_manager.h" | 25 #include "storage/browser/quota/quota_manager.h" |
26 #include "webkit/common/blob/blob_data.h" | 26 #include "storage/common/blob/blob_data.h" |
27 #include "webkit/common/blob/shareable_file_reference.h" | 27 #include "storage/common/blob/shareable_file_reference.h" |
28 | 28 |
29 using webkit_blob::ShareableFileReference; | 29 using storage::ShareableFileReference; |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 namespace { | 33 namespace { |
34 const int32 kNoCursor = -1; | 34 const int32 kNoCursor = -1; |
35 const int32 kNoDatabaseCallbacks = -1; | 35 const int32 kNoDatabaseCallbacks = -1; |
36 const int64 kNoTransaction = -1; | 36 const int64 kNoTransaction = -1; |
37 } | 37 } |
38 | 38 |
39 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 39 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ipc_callbacks_id_, | 187 ipc_callbacks_id_, |
188 ipc_database_callbacks_id_, | 188 ipc_database_callbacks_id_, |
189 ipc_object_id, | 189 ipc_object_id, |
190 IndexedDBDispatcherHost::ConvertMetadata(metadata))); | 190 IndexedDBDispatcherHost::ConvertMetadata(metadata))); |
191 dispatcher_host_ = NULL; | 191 dispatcher_host_ = NULL; |
192 } | 192 } |
193 | 193 |
194 static std::string CreateBlobData( | 194 static std::string CreateBlobData( |
195 const IndexedDBBlobInfo& blob_info, | 195 const IndexedDBBlobInfo& blob_info, |
196 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, | 196 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, |
197 webkit_blob::BlobStorageContext* blob_storage_context, | 197 storage::BlobStorageContext* blob_storage_context, |
198 base::TaskRunner* task_runner) { | 198 base::TaskRunner* task_runner) { |
199 std::string uuid = blob_info.uuid(); | 199 std::string uuid = blob_info.uuid(); |
200 if (!uuid.empty()) { | 200 if (!uuid.empty()) { |
201 // We're sending back a live blob, not a reference into our backing store. | 201 // We're sending back a live blob, not a reference into our backing store. |
202 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle( | 202 scoped_ptr<storage::BlobDataHandle> blob_data_handle( |
203 blob_storage_context->GetBlobDataFromUUID(uuid)); | 203 blob_storage_context->GetBlobDataFromUUID(uuid)); |
204 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); | 204 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); |
205 return uuid; | 205 return uuid; |
206 } | 206 } |
207 scoped_refptr<ShareableFileReference> shareable_file = | 207 scoped_refptr<ShareableFileReference> shareable_file = |
208 ShareableFileReference::Get(blob_info.file_path()); | 208 ShareableFileReference::Get(blob_info.file_path()); |
209 if (!shareable_file.get()) { | 209 if (!shareable_file.get()) { |
210 shareable_file = ShareableFileReference::GetOrCreate( | 210 shareable_file = ShareableFileReference::GetOrCreate( |
211 blob_info.file_path(), | 211 blob_info.file_path(), |
212 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, | 212 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, |
213 task_runner); | 213 task_runner); |
214 if (!blob_info.release_callback().is_null()) | 214 if (!blob_info.release_callback().is_null()) |
215 shareable_file->AddFinalReleaseCallback(blob_info.release_callback()); | 215 shareable_file->AddFinalReleaseCallback(blob_info.release_callback()); |
216 } | 216 } |
217 | 217 |
218 uuid = base::GenerateGUID(); | 218 uuid = base::GenerateGUID(); |
219 scoped_refptr<webkit_blob::BlobData> blob_data = | 219 scoped_refptr<storage::BlobData> blob_data = new storage::BlobData(uuid); |
220 new webkit_blob::BlobData(uuid); | |
221 blob_data->AppendFile( | 220 blob_data->AppendFile( |
222 blob_info.file_path(), 0, blob_info.size(), blob_info.last_modified()); | 221 blob_info.file_path(), 0, blob_info.size(), blob_info.last_modified()); |
223 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle( | 222 scoped_ptr<storage::BlobDataHandle> blob_data_handle( |
224 blob_storage_context->AddFinishedBlob(blob_data.get())); | 223 blob_storage_context->AddFinishedBlob(blob_data.get())); |
225 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); | 224 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); |
226 | 225 |
227 return uuid; | 226 return uuid; |
228 } | 227 } |
229 | 228 |
230 static bool CreateAllBlobs( | 229 static bool CreateAllBlobs( |
231 const std::vector<IndexedDBBlobInfo>& blob_info, | 230 const std::vector<IndexedDBBlobInfo>& blob_info, |
232 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info, | 231 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info, |
233 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) { | 232 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 DCHECK_EQ(kNoDatabase, ipc_database_id_); | 572 DCHECK_EQ(kNoDatabase, ipc_database_id_); |
574 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); | 573 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); |
575 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); | 574 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); |
576 | 575 |
577 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined( | 576 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined( |
578 ipc_thread_id_, ipc_callbacks_id_)); | 577 ipc_thread_id_, ipc_callbacks_id_)); |
579 dispatcher_host_ = NULL; | 578 dispatcher_host_ = NULL; |
580 } | 579 } |
581 | 580 |
582 } // namespace content | 581 } // namespace content |
OLD | NEW |