| 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 ab1329379cd841a919a15825db28ddf45fd40355..66a504e3c99ac7363dd36727d1d50428df2a6182 100644
|
| --- a/content/browser/indexed_db/indexed_db_callbacks.cc
|
| +++ b/content/browser/indexed_db/indexed_db_callbacks.cc
|
| @@ -81,7 +81,7 @@ void ConvertBlobInfo(
|
| class IndexedDBCallbacks::IOThreadHelper {
|
| public:
|
| IOThreadHelper(CallbacksAssociatedPtrInfo callbacks_info,
|
| - scoped_refptr<IndexedDBDispatcherHost> dispatcher_host);
|
| + IndexedDBDispatcherHost* dispatcher_host);
|
| ~IOThreadHelper();
|
|
|
| void SendError(const IndexedDBDatabaseError& error);
|
| @@ -125,7 +125,7 @@ class IndexedDBCallbacks::IOThreadHelper {
|
| void OnConnectionError();
|
|
|
| private:
|
| - scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
|
| + base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host_;
|
| ::indexed_db::mojom::CallbacksAssociatedPtr callbacks_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(IOThreadHelper);
|
| @@ -142,10 +142,10 @@ class IndexedDBCallbacks::IOThreadHelper {
|
| }
|
|
|
| IndexedDBCallbacks::IndexedDBCallbacks(
|
| - scoped_refptr<IndexedDBDispatcherHost> dispatcher_host,
|
| + IndexedDBDispatcherHost* dispatcher_host,
|
| const url::Origin& origin,
|
| ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info)
|
| - : dispatcher_host_(std::move(dispatcher_host)),
|
| + : dispatcher_host_(dispatcher_host),
|
| origin_(origin),
|
| data_loss_(blink::WebIDBDataLossNone),
|
| sent_blocked_(false),
|
| @@ -440,8 +440,8 @@ void IndexedDBCallbacks::SetConnectionOpenStartTime(
|
|
|
| IndexedDBCallbacks::IOThreadHelper::IOThreadHelper(
|
| CallbacksAssociatedPtrInfo callbacks_info,
|
| - scoped_refptr<IndexedDBDispatcherHost> dispatcher_host)
|
| - : dispatcher_host_(std::move(dispatcher_host)) {
|
| + IndexedDBDispatcherHost* dispatcher_host)
|
| + : dispatcher_host_(dispatcher_host->AsWeakPtr()) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| if (callbacks_info.is_valid()) {
|
| callbacks_.Bind(std::move(callbacks_info));
|
| @@ -454,17 +454,29 @@ IndexedDBCallbacks::IOThreadHelper::~IOThreadHelper() {}
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendError(
|
| const IndexedDBDatabaseError& error) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->Error(error.code(), error.message());
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessStringList(
|
| const std::vector<base::string16>& value) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->SuccessStringList(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendBlocked(int64_t existing_version) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->Blocked(existing_version);
|
| }
|
| @@ -475,12 +487,17 @@ void IndexedDBCallbacks::IOThreadHelper::SendUpgradeNeeded(
|
| blink::WebIDBDataLoss data_loss,
|
| const std::string& data_loss_message,
|
| const content::IndexedDBDatabaseMetadata& metadata) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| ::indexed_db::mojom::DatabaseAssociatedPtrInfo ptr_info;
|
| auto request = mojo::MakeRequest(&ptr_info);
|
| - mojo::MakeStrongAssociatedBinding(std::move(database), std::move(request));
|
| +
|
| + dispatcher_host_->AddDatabaseBinding(std::move(database), std::move(request));
|
| callbacks_->UpgradeNeeded(std::move(ptr_info), old_version, data_loss,
|
| data_loss_message, metadata);
|
| }
|
| @@ -488,13 +505,18 @@ void IndexedDBCallbacks::IOThreadHelper::SendUpgradeNeeded(
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessDatabase(
|
| std::unique_ptr<DatabaseImpl> database,
|
| const content::IndexedDBDatabaseMetadata& metadata) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| ::indexed_db::mojom::DatabaseAssociatedPtrInfo ptr_info;
|
| if (database) {
|
| auto request = mojo::MakeRequest(&ptr_info);
|
| - mojo::MakeStrongAssociatedBinding(std::move(database), std::move(request));
|
| + dispatcher_host_->AddDatabaseBinding(std::move(database),
|
| + std::move(request));
|
| }
|
| callbacks_->SuccessDatabase(std::move(ptr_info), metadata);
|
| }
|
| @@ -505,6 +527,10 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursor(
|
| const IndexedDBKey& primary_key,
|
| ::indexed_db::mojom::ValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| @@ -513,7 +539,7 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursor(
|
|
|
| ::indexed_db::mojom::CursorAssociatedPtrInfo ptr_info;
|
| auto request = mojo::MakeRequest(&ptr_info);
|
| - mojo::MakeStrongAssociatedBinding(std::move(cursor), std::move(request));
|
| + dispatcher_host_->AddCursorBinding(std::move(cursor), std::move(request));
|
| callbacks_->SuccessCursor(std::move(ptr_info), key, primary_key,
|
| std::move(value));
|
| }
|
| @@ -521,6 +547,10 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursor(
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessValue(
|
| ::indexed_db::mojom::ReturnValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| @@ -533,6 +563,10 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessArray(
|
| const std::vector<IndexedDBReturnValue>& values) {
|
| DCHECK_EQ(mojo_values.size(), values.size());
|
|
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| @@ -549,6 +583,10 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorContinue(
|
| const IndexedDBKey& primary_key,
|
| ::indexed_db::mojom::ValuePtr value,
|
| const std::vector<IndexedDBBlobInfo>& blob_info) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| @@ -563,6 +601,10 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorPrefetch(
|
| const std::vector<IndexedDBValue>& values) {
|
| DCHECK_EQ(mojo_values.size(), values.size());
|
|
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (!callbacks_)
|
| return;
|
|
|
| @@ -578,16 +620,28 @@ void IndexedDBCallbacks::IOThreadHelper::SendSuccessCursorPrefetch(
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessKey(
|
| const IndexedDBKey& value) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->SuccessKey(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccessInteger(int64_t value) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->SuccessInteger(value);
|
| }
|
|
|
| void IndexedDBCallbacks::IOThreadHelper::SendSuccess() {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return;
|
| + }
|
| if (callbacks_)
|
| callbacks_->Success();
|
| }
|
| @@ -614,6 +668,10 @@ std::string IndexedDBCallbacks::IOThreadHelper::CreateBlobData(
|
| bool IndexedDBCallbacks::IOThreadHelper::CreateAllBlobs(
|
| const std::vector<IndexedDBBlobInfo>& blob_info,
|
| std::vector<::indexed_db::mojom::BlobInfoPtr>* blob_or_file_info) {
|
| + if (!dispatcher_host_) {
|
| + OnConnectionError();
|
| + return false;
|
| + }
|
| IDB_TRACE("IndexedDBCallbacks::CreateAllBlobs");
|
| DCHECK_EQ(blob_info.size(), blob_or_file_info->size());
|
| if (!dispatcher_host_->blob_storage_context())
|
|
|