| Index: content/browser/indexed_db/indexed_db_callbacks.cc
|
| diff --git a/content/browser/indexed_db/indexed_db_callbacks.cc b/content/browser/indexed_db/indexed_db_callbacks.cc
|
| index 49995fbc5dd294146654c7abcd25d423fe3bd402..f7268195d8bc7cb6a66a80bb53277bd16644327c 100644
|
| --- a/content/browser/indexed_db/indexed_db_callbacks.cc
|
| +++ b/content/browser/indexed_db/indexed_db_callbacks.cc
|
| @@ -17,7 +17,6 @@
|
| #include "content/browser/fileapi/fileapi_message_filter.h"
|
| #include "content/browser/indexed_db/cursor_impl.h"
|
| #include "content/browser/indexed_db/database_impl.h"
|
| -#include "content/browser/indexed_db/indexed_db_blob_info.h"
|
| #include "content/browser/indexed_db/indexed_db_connection.h"
|
| #include "content/browser/indexed_db/indexed_db_context_impl.h"
|
| #include "content/browser/indexed_db/indexed_db_cursor.h"
|
| @@ -132,6 +131,7 @@ class IndexedDBCallbacks::IOThreadHelper {
|
| bool CreateAllBlobs(
|
| const std::vector<IndexedDBBlobInfo>& blob_info,
|
| std::vector<::indexed_db::mojom::BlobInfoPtr>* blob_or_file_info);
|
| + void OnConnectionError();
|
|
|
| private:
|
| scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
|
| @@ -256,9 +256,10 @@ void IndexedDBCallbacks::OnSuccess(
|
| // Only send a new Database if the connection was not previously sent in
|
| // OnUpgradeNeeded.
|
| std::unique_ptr<DatabaseImpl> database;
|
| - if (!database_sent_)
|
| + if (!database_sent_) {
|
| database.reset(
|
| new DatabaseImpl(std::move(connection), origin_, dispatcher_host_));
|
| + }
|
|
|
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| base::Bind(&IOThreadHelper::SendSuccessDatabase,
|
| @@ -431,12 +432,6 @@ void IndexedDBCallbacks::OnSuccess() {
|
| dispatcher_host_ = nullptr;
|
| }
|
|
|
| -bool IndexedDBCallbacks::IsValid() const {
|
| - DCHECK(dispatcher_host_.get());
|
| -
|
| - return dispatcher_host_->IsOpen();
|
| -}
|
| -
|
| void IndexedDBCallbacks::SetConnectionOpenStartTime(
|
| const base::TimeTicks& start_time) {
|
| connection_open_start_time_ = start_time;
|
| @@ -447,23 +442,30 @@ IndexedDBCallbacks::IOThreadHelper::IOThreadHelper(
|
| scoped_refptr<IndexedDBDispatcherHost> dispatcher_host)
|
| : dispatcher_host_(std::move(dispatcher_host)) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| - callbacks_.Bind(std::move(callbacks_info));
|
| + if (callbacks_info.is_valid()) {
|
| + callbacks_.Bind(std::move(callbacks_info));
|
| + callbacks_.set_connection_error_handler(
|
| + base::Bind(&IOThreadHelper::OnConnectionError, base::Unretained(this)));
|
| + }
|
| }
|
|
|
| IndexedDBCallbacks::IOThreadHelper::~IOThreadHelper() {}
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendError(
|
| const IndexedDBDatabaseError& error) {
|
| - callbacks_->Error(error.code(), error.message());
|
| + if (callbacks_)
|
| + callbacks_->Error(error.code(), error.message());
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessStringList(
|
| const std::vector<base::string16>& value) {
|
| - callbacks_->SuccessStringList(value);
|
| + if (callbacks_)
|
| + callbacks_->SuccessStringList(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendBlocked(int64_t existing_version) {
|
| - callbacks_->Blocked(existing_version);
|
| + if (callbacks_)
|
| + callbacks_->Blocked(existing_version);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendUpgradeNeeded(
|
| @@ -472,6 +474,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendUpgradeNeeded(
|
| blink::WebIDBDataLoss data_loss,
|
| const std::string& data_loss_message,
|
| const content::IndexedDBDatabaseMetadata& metadata) {
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| ::indexed_db::mojom::DatabaseAssociatedPtrInfo ptr_info;
|
| ::indexed_db::mojom::DatabaseAssociatedRequest request;
|
| callbacks_.associated_group()->CreateAssociatedInterface(
|
| @@ -484,6 +489,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendUpgradeNeeded(
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessDatabase(
|
| std::unique_ptr<DatabaseImpl> database,
|
| const content::IndexedDBDatabaseMetadata& metadata) {
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| ::indexed_db::mojom::DatabaseAssociatedPtrInfo ptr_info;
|
| if (database) {
|
| ::indexed_db::mojom::DatabaseAssociatedRequest request;
|
| @@ -500,6 +508,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursor(
|
| const IndexedDBKey& primary_key,
|
| ::indexed_db::mojom::ValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| if (value && !CreateAllBlobs(blob_info, &value->blob_or_file_info))
|
| return;
|
|
|
| @@ -515,6 +526,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursor(
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessValue(
|
| ::indexed_db::mojom::ReturnValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| if (!value || CreateAllBlobs(blob_info, &value->value->blob_or_file_info))
|
| callbacks_->SuccessValue(std::move(value));
|
| }
|
| @@ -524,6 +538,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessArray(
|
| const std::vector<IndexedDBReturnValue>& values) {
|
| DCHECK_EQ(mojo_values.size(), values.size());
|
|
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| for (size_t i = 0; i < mojo_values.size(); ++i) {
|
| if (!CreateAllBlobs(values[i].blob_info,
|
| &mojo_values[i]->value->blob_or_file_info))
|
| @@ -537,6 +554,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorContinue(
|
| const IndexedDBKey& primary_key,
|
| ::indexed_db::mojom::ValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| if (!value || CreateAllBlobs(blob_info, &value->blob_or_file_info))
|
| callbacks_->SuccessCursorContinue(key, primary_key, std::move(value));
|
| }
|
| @@ -548,6 +568,9 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorPrefetch(
|
| const std::vector<IndexedDBValue>& values) {
|
| DCHECK_EQ(mojo_values.size(), values.size());
|
|
|
| + if (!callbacks_)
|
| + return;
|
| +
|
| for (size_t i = 0; i < mojo_values.size(); ++i) {
|
| if (!CreateAllBlobs(values[i].blob_info,
|
| &mojo_values[i]->blob_or_file_info)) {
|
| @@ -560,15 +583,18 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorPrefetch(
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessKey(
|
| const IndexedDBKey& value) {
|
| - callbacks_->SuccessKey(value);
|
| + if (callbacks_)
|
| + callbacks_->SuccessKey(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessInteger(int64_t value) {
|
| - callbacks_->SuccessInteger(value);
|
| + if (callbacks_)
|
| + callbacks_->SuccessInteger(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccess() {
|
| - callbacks_->Success();
|
| + if (callbacks_)
|
| + callbacks_->Success();
|
| }
|
|
|
| std::string IndexedDBCallbacks::IOThreadHelper::CreateBlobData(
|
| @@ -602,4 +628,9 @@ bool IndexedDBCallbacks::IOThreadHelper::CreateAllBlobs(
|
| return true;
|
| }
|
|
|
| +void IndexedDBCallbacks::IOThreadHelper::OnConnectionError() {
|
| + callbacks_.reset();
|
| + dispatcher_host_ = nullptr;
|
| +}
|
| +
|
| } // namespace content
|
|
|