Index: content/browser/indexed_db/indexed_db_dispatcher_host.cc |
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
index e926a9073d76b09b377dc92372357a5105b7e3b9..96d531574134aa24a2f9c5c3a273f672fa26cd19 100644 |
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
@@ -15,6 +15,7 @@ |
#include "content/browser/indexed_db/indexed_db_cursor.h" |
#include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
#include "content/browser/indexed_db/indexed_db_metadata.h" |
+#include "content/browser/indexed_db/indexed_db_value.h" |
#include "content/browser/renderer_host/render_message_filter.h" |
#include "content/common/indexed_db/indexed_db_messages.h" |
#include "content/public/browser/browser_thread.h" |
@@ -33,8 +34,27 @@ namespace content { |
IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
int ipc_process_id, |
- IndexedDBContextImpl* indexed_db_context) |
- : indexed_db_context_(indexed_db_context), |
+ net::URLRequestContextGetter* request_context_getter, |
+ IndexedDBContextImpl* indexed_db_context, |
+ FileAPIMessageFilter* file_api_message_filter) |
+ : request_context_getter_(request_context_getter), |
+ request_context_(NULL), |
+ indexed_db_context_(indexed_db_context), |
+ file_api_message_filter_(file_api_message_filter), |
+ database_dispatcher_host_(new DatabaseDispatcherHost(this)), |
+ cursor_dispatcher_host_(new CursorDispatcherHost(this)), |
+ ipc_process_id_(ipc_process_id) { |
+ DCHECK(indexed_db_context_); |
+} |
+ |
+IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
+ int ipc_process_id, |
+ net::URLRequestContext* request_context, |
+ IndexedDBContextImpl* indexed_db_context, |
+ FileAPIMessageFilter* file_api_message_filter) |
+ : request_context_(request_context), |
+ indexed_db_context_(indexed_db_context), |
+ file_api_message_filter_(file_api_message_filter), |
database_dispatcher_host_(new DatabaseDispatcherHost(this)), |
cursor_dispatcher_host_(new CursorDispatcherHost(this)), |
ipc_process_id_(ipc_process_id) { |
@@ -43,6 +63,17 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {} |
+void IndexedDBDispatcherHost::OnChannelConnected(int32 peer_pid) { |
+ BrowserMessageFilter::OnChannelConnected(peer_pid); |
+ |
+ if (request_context_getter_.get()) { |
+ DCHECK(!request_context_); |
+ request_context_ = request_context_getter_->GetURLRequestContext(); |
+ request_context_getter_ = NULL; |
+ DCHECK(request_context_); |
+ } |
+} |
+ |
void IndexedDBDispatcherHost::OnChannelClosing() { |
BrowserMessageFilter::OnChannelClosing(); |
@@ -214,7 +245,8 @@ void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
new IndexedDBCallbacks( |
this, params.ipc_thread_id, params.ipc_callbacks_id), |
params.database_identifier, |
- indexed_db_path); |
+ indexed_db_path, |
+ Context()->TaskRunner()); |
} |
void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
@@ -241,11 +273,14 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
this, params.ipc_thread_id, params.ipc_database_callbacks_id); |
Context()->GetIDBFactory()->Open(params.name, |
params.version, |
+ request_context_, |
host_transaction_id, |
callbacks, |
database_callbacks, |
params.database_identifier, |
- indexed_db_path); |
+ indexed_db_path, |
+ ipc_process_id_, |
+ Context()->TaskRunner()); |
} |
void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
@@ -254,10 +289,12 @@ void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
Context()->GetIDBFactory()->DeleteDatabase( |
params.name, |
+ request_context_, |
new IndexedDBCallbacks( |
this, params.ipc_thread_id, params.ipc_callbacks_id), |
params.database_identifier, |
- indexed_db_path); |
+ indexed_db_path, |
+ Context()->TaskRunner()); |
} |
void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, |
@@ -525,12 +562,26 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
+ |
+ std::vector<IndexedDBBlobInfo> blob_info(params.blob_or_file_info.size()); |
+ |
+ for (size_t i=0; i < params.blob_or_file_info.size(); ++i) { |
+ const IndexedDBMsg_BlobOrFileInfo& info = params.blob_or_file_info[i]; |
+ if (info.is_file) |
+ blob_info[i] = |
+ IndexedDBBlobInfo(base::FilePath::FromUTF16Unsafe(info.file_path), |
+ info.file_name, info.mime_type); |
+ else |
+ blob_info[i] = IndexedDBBlobInfo(info.url, info.mime_type, info.size); |
+ } |
// TODO(alecflett): Avoid a copy here. |
- std::string value_copy(params.value); |
+ IndexedDBValue value; |
+ value.bits = params.value; |
+ value.blob_info.swap(blob_info); |
connection->database()->Put( |
host_transaction_id, |
params.object_store_id, |
- &value_copy, |
+ &value, |
make_scoped_ptr(new IndexedDBKey(params.key)), |
static_cast<IndexedDBDatabase::PutMode>(params.put_mode), |
callbacks, |