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" | |
10 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 11 #include "base/time/time.h" |
13 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
14 #include "content/browser/fileapi/fileapi_message_filter.h" | 13 #include "content/browser/fileapi/fileapi_message_filter.h" |
15 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 14 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
16 #include "content/browser/indexed_db/indexed_db_connection.h" | 15 #include "content/browser/indexed_db/indexed_db_connection.h" |
17 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 16 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
18 #include "content/browser/indexed_db/indexed_db_cursor.h" | 17 #include "content/browser/indexed_db/indexed_db_cursor.h" |
19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 UMA_HISTOGRAM_MEDIUM_TIMES( | 215 UMA_HISTOGRAM_MEDIUM_TIMES( |
217 "WebCore.IndexedDB.OpenTime.Success", | 216 "WebCore.IndexedDB.OpenTime.Success", |
218 base::TimeTicks::Now() - connection_open_start_time_); | 217 base::TimeTicks::Now() - connection_open_start_time_); |
219 connection_open_start_time_ = base::TimeTicks(); | 218 connection_open_start_time_ = base::TimeTicks(); |
220 } | 219 } |
221 } | 220 } |
222 | 221 |
223 static std::string CreateBlobData( | 222 static std::string CreateBlobData( |
224 const IndexedDBBlobInfo& blob_info, | 223 const IndexedDBBlobInfo& blob_info, |
225 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, | 224 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, |
226 storage::BlobStorageContext* blob_storage_context, | 225 storage::BlobStorageContext* blob_storage_context, |
dgrogan
2014/12/05 01:09:29
Looks like you can ax this parameter.
cmumford
2014/12/05 19:08:09
Done.
| |
227 base::TaskRunner* task_runner) { | 226 base::TaskRunner* task_runner) { |
228 std::string uuid = blob_info.uuid(); | 227 if (!blob_info.uuid().empty()) { |
229 if (!uuid.empty()) { | |
230 // We're sending back a live blob, not a reference into our backing store. | 228 // We're sending back a live blob, not a reference into our backing store. |
231 scoped_ptr<storage::BlobDataHandle> blob_data_handle( | 229 return dispatcher_host->HoldBlobData(blob_info); |
232 blob_storage_context->GetBlobDataFromUUID(uuid)); | |
233 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); | |
234 return uuid; | |
235 } | 230 } |
236 scoped_refptr<ShareableFileReference> shareable_file = | 231 scoped_refptr<ShareableFileReference> shareable_file = |
237 ShareableFileReference::Get(blob_info.file_path()); | 232 ShareableFileReference::Get(blob_info.file_path()); |
238 if (!shareable_file.get()) { | 233 if (!shareable_file.get()) { |
239 shareable_file = ShareableFileReference::GetOrCreate( | 234 shareable_file = ShareableFileReference::GetOrCreate( |
240 blob_info.file_path(), | 235 blob_info.file_path(), |
241 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, | 236 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, |
242 task_runner); | 237 task_runner); |
243 if (!blob_info.release_callback().is_null()) | 238 if (!blob_info.release_callback().is_null()) |
244 shareable_file->AddFinalReleaseCallback(blob_info.release_callback()); | 239 shareable_file->AddFinalReleaseCallback(blob_info.release_callback()); |
245 } | 240 } |
246 | 241 return dispatcher_host->HoldBlobData(blob_info); |
247 uuid = base::GenerateGUID(); | |
248 scoped_refptr<storage::BlobData> blob_data = new storage::BlobData(uuid); | |
249 blob_data->set_content_type(base::UTF16ToUTF8(blob_info.type())); | |
250 blob_data->AppendFile( | |
251 blob_info.file_path(), 0, blob_info.size(), blob_info.last_modified()); | |
252 scoped_ptr<storage::BlobDataHandle> blob_data_handle( | |
253 blob_storage_context->AddFinishedBlob(blob_data.get())); | |
254 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass()); | |
255 | |
256 return uuid; | |
257 } | 242 } |
258 | 243 |
259 static bool CreateAllBlobs( | 244 static bool CreateAllBlobs( |
260 const std::vector<IndexedDBBlobInfo>& blob_info, | 245 const std::vector<IndexedDBBlobInfo>& blob_info, |
261 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info, | 246 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info, |
262 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) { | 247 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) { |
263 DCHECK_EQ(blob_info.size(), blob_or_file_info->size()); | 248 DCHECK_EQ(blob_info.size(), blob_or_file_info->size()); |
264 size_t i; | 249 size_t i; |
265 if (!dispatcher_host->blob_storage_context()) | 250 if (!dispatcher_host->blob_storage_context()) |
266 return false; | 251 return false; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 ipc_thread_id_, ipc_callbacks_id_)); | 586 ipc_thread_id_, ipc_callbacks_id_)); |
602 dispatcher_host_ = NULL; | 587 dispatcher_host_ = NULL; |
603 } | 588 } |
604 | 589 |
605 void IndexedDBCallbacks::SetConnectionOpenStartTime( | 590 void IndexedDBCallbacks::SetConnectionOpenStartTime( |
606 const base::TimeTicks& start_time) { | 591 const base::TimeTicks& start_time) { |
607 connection_open_start_time_ = start_time; | 592 connection_open_start_time_ = start_time; |
608 } | 593 } |
609 | 594 |
610 } // namespace content | 595 } // namespace content |
OLD | NEW |