Chromium Code Reviews| 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 f1663a5dc6b57e552e03365b929a9f7588911214..ab3669cd4654d69a2e7147bfbc1ac19baafe605f 100644 |
| --- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc |
| @@ -95,6 +95,17 @@ void IndexedDBDispatcherHost::DropBlobData(const std::string& uuid) { |
| --iter->second.second; |
| } |
| +void IndexedDBDispatcherHost::Configure( |
| + const IndexedDBDataFormatVersion& client_data_format_version) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + |
| + // TODO(jbroman): We could take mojo::GetBadMessageCallback here to tell the |
|
jsbell
2017/04/04 19:24:33
If this is happening w/in dispatch, we should be a
|
| + // IPC system that this is a bad message, if this ever changes. Should we? |
| + indexed_db_context_->TaskRunner()->PostTask( |
| + FROM_HERE, base::Bind(&IndexedDBDispatcherHost::ConfigureOnIDBThread, |
| + this, client_data_format_version)); |
| +} |
| + |
| void IndexedDBDispatcherHost::GetDatabaseNames( |
| ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| const url::Origin& origin) { |
| @@ -159,14 +170,28 @@ void IndexedDBDispatcherHost::DeleteDatabase( |
| force_close)); |
| } |
| +void IndexedDBDispatcherHost::ConfigureOnIDBThread( |
| + const IndexedDBDataFormatVersion& client_data_format_version) { |
| + if (!client_data_format_version_) |
|
dcheng
2017/04/04 19:59:21
Since this is coming from the renderer, we do need
|
| + client_data_format_version_ = client_data_format_version; |
| + if (client_data_format_version_ != client_data_format_version) |
| + LOG(ERROR) << "IndexedDB client's supported data format version changed!"; |
|
dcheng
2017/04/04 19:59:21
Nit: DLOG instead of LOG? I don't think this will
|
| +} |
| + |
| void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread( |
| scoped_refptr<IndexedDBCallbacks> callbacks, |
| const url::Origin& origin) { |
| DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| + // TODO(jbroman): How fail here? |
| + if (!client_data_format_version_) |
| + LOG(ERROR) << "IndexedDB client failed to call Configure!"; |
| + |
| base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| context()->GetIDBFactory()->GetDatabaseNames( |
| - callbacks, origin, indexed_db_path, request_context_getter_); |
| + callbacks, origin, indexed_db_path, |
| + client_data_format_version_.value_or(IndexedDBDataFormatVersion()), |
| + request_context_getter_); |
| } |
| void IndexedDBDispatcherHost::OpenOnIDBThread( |
| @@ -181,6 +206,10 @@ void IndexedDBDispatcherHost::OpenOnIDBThread( |
| base::TimeTicks begin_time = base::TimeTicks::Now(); |
| base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| + // TODO(jbroman): How fail here? |
| + if (!client_data_format_version_) |
| + LOG(ERROR) << "IndexedDB client failed to call Configure!"; |
| + |
| // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| // created) if this origin is already over quota. |
| callbacks->SetConnectionOpenStartTime(begin_time); |
| @@ -189,9 +218,10 @@ void IndexedDBDispatcherHost::OpenOnIDBThread( |
| callbacks, database_callbacks, ipc_process_id_, transaction_id, |
| version); |
| DCHECK(request_context_getter_); |
| - context()->GetIDBFactory()->Open(name, std::move(connection), |
| - request_context_getter_, origin, |
| - indexed_db_path); |
| + context()->GetIDBFactory()->Open( |
| + name, std::move(connection), request_context_getter_, origin, |
| + indexed_db_path, |
| + client_data_format_version_.value_or(IndexedDBDataFormatVersion())); |
| } |
| void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread( |
| @@ -202,9 +232,15 @@ void IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread( |
| DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| + |
| + // TODO(jbroman): How fail here? |
| + if (!client_data_format_version_) |
| + LOG(ERROR) << "IndexedDB client failed to call Configure!"; |
| + |
| DCHECK(request_context_getter_); |
| context()->GetIDBFactory()->DeleteDatabase( |
| name, request_context_getter_, callbacks, origin, indexed_db_path, |
| + client_data_format_version_.value_or(IndexedDBDataFormatVersion()), |
| force_close); |
| } |