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

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

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed copyright Created 5 years, 11 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 "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"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/process/process.h" 12 #include "base/process/process.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/child_process_security_policy_impl.h" 15 #include "content/browser/child_process_security_policy_impl.h"
16 #include "content/browser/indexed_db/indexed_db_callbacks.h" 16 #include "content/browser/indexed_db/indexed_db_callbacks.h"
17 #include "content/browser/indexed_db/indexed_db_connection.h" 17 #include "content/browser/indexed_db/indexed_db_connection.h"
18 #include "content/browser/indexed_db/indexed_db_context_impl.h" 18 #include "content/browser/indexed_db/indexed_db_context_impl.h"
19 #include "content/browser/indexed_db/indexed_db_cursor.h" 19 #include "content/browser/indexed_db/indexed_db_cursor.h"
20 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 20 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
21 #include "content/browser/indexed_db/indexed_db_metadata.h" 21 #include "content/browser/indexed_db/indexed_db_metadata.h"
22 #include "content/browser/indexed_db/indexed_db_pending_connection.h" 22 #include "content/browser/indexed_db/indexed_db_pending_connection.h"
23 #include "content/browser/indexed_db/indexed_db_value.h" 23 #include "content/browser/indexed_db/indexed_db_value.h"
24 #include "content/browser/renderer_host/render_message_filter.h" 24 #include "content/browser/renderer_host/render_message_filter.h"
25 #include "content/common/indexed_db/indexed_db_messages.h" 25 #include "content/common/indexed_db/indexed_db_messages.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
28 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
29 #include "content/public/common/result_codes.h" 29 #include "content/public/common/result_codes.h"
30 #include "storage/browser/blob/blob_data_builder.h"
30 #include "storage/browser/blob/blob_storage_context.h" 31 #include "storage/browser/blob/blob_storage_context.h"
31 #include "storage/browser/database/database_util.h" 32 #include "storage/browser/database/database_util.h"
32 #include "storage/common/database/database_identifier.h" 33 #include "storage/common/database/database_identifier.h"
33 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 34 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
34 #include "url/gurl.h" 35 #include "url/gurl.h"
35 36
36 using storage::DatabaseUtil; 37 using storage::DatabaseUtil;
37 using blink::WebIDBKey; 38 using blink::WebIDBKey;
38 39
39 namespace content { 40 namespace content {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 221
221 std::string IndexedDBDispatcherHost::HoldBlobData( 222 std::string IndexedDBDispatcherHost::HoldBlobData(
222 const IndexedDBBlobInfo& blob_info) { 223 const IndexedDBBlobInfo& blob_info) {
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
224 std::string uuid = blob_info.uuid(); 225 std::string uuid = blob_info.uuid();
225 storage::BlobStorageContext* context = blob_storage_context_->context(); 226 storage::BlobStorageContext* context = blob_storage_context_->context();
226 scoped_ptr<storage::BlobDataHandle> blob_data_handle; 227 scoped_ptr<storage::BlobDataHandle> blob_data_handle;
227 if (uuid.empty()) { 228 if (uuid.empty()) {
228 uuid = base::GenerateGUID(); 229 uuid = base::GenerateGUID();
229 scoped_refptr<storage::BlobData> blob_data = new storage::BlobData(uuid); 230 storage::BlobDataBuilder blob_data_builder(uuid);
230 blob_data->set_content_type(base::UTF16ToUTF8(blob_info.type())); 231 blob_data_builder.set_content_type(base::UTF16ToUTF8(blob_info.type()));
231 blob_data->AppendFile(blob_info.file_path(), 0, blob_info.size(), 232 blob_data_builder.AppendFile(blob_info.file_path(), 0, blob_info.size(),
232 blob_info.last_modified()); 233 blob_info.last_modified());
233 blob_data_handle = context->AddFinishedBlob(blob_data.get()); 234 blob_data_handle = context->AddFinishedBlob(blob_data_builder);
234 } else { 235 } else {
235 auto iter = blob_data_handle_map_.find(uuid); 236 auto iter = blob_data_handle_map_.find(uuid);
236 if (iter != blob_data_handle_map_.end()) { 237 if (iter != blob_data_handle_map_.end()) {
237 iter->second.second += 1; 238 iter->second.second += 1;
238 return uuid; 239 return uuid;
239 } 240 }
240 blob_data_handle = context->GetBlobDataFromUUID(uuid); 241 blob_data_handle = context->GetBlobDataFromUUID(uuid);
241 } 242 }
242 243
243 DCHECK(!ContainsKey(blob_data_handle_map_, uuid)); 244 DCHECK(!ContainsKey(blob_data_handle_map_, uuid));
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 } 1022 }
1022 1023
1023 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1024 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1024 int32 ipc_object_id) { 1025 int32 ipc_object_id) {
1025 DCHECK( 1026 DCHECK(
1026 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 1027 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
1027 parent_->DestroyObject(&map_, ipc_object_id); 1028 parent_->DestroyObject(&map_, ipc_object_id);
1028 } 1029 }
1029 1030
1030 } // namespace content 1031 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698