Commit 27019c14 authored by Daniel Murphy's avatar Daniel Murphy Committed by Commit Bot

[SessionStorage] Fixed async BadMessage reporting

R=mek@chromium.org

Bug: 868578
Change-Id: I1c90f993f3e71d543b414c37a1b92bae5948b766
Reviewed-on: https://chromium-review.googlesource.com/1155483
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580214}
parent 989f7a70
......@@ -396,6 +396,7 @@ void DOMStorageContextWrapper::OpenLocalStorage(
void DOMStorageContextWrapper::OpenSessionStorage(
int process_id,
const std::string& namespace_id,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::SessionStorageNamespaceRequest request) {
if (!mojo_session_state_)
return;
......@@ -404,9 +405,11 @@ void DOMStorageContextWrapper::OpenSessionStorage(
// as soon as that task is posted, mojo_state_ is set to null, preventing
// further tasks from being queued.
mojo_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&SessionStorageContextMojo::OpenSessionStorage,
base::Unretained(mojo_session_state_),
process_id, namespace_id, std::move(request)));
FROM_HERE,
base::BindOnce(&SessionStorageContextMojo::OpenSessionStorage,
base::Unretained(mojo_session_state_), process_id,
namespace_id, std::move(bad_message_callback),
std::move(request)));
}
void DOMStorageContextWrapper::SetLocalStorageDatabaseForTesting(
......
......@@ -18,6 +18,7 @@
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/common/content_export.h"
#include "content/public/browser/dom_storage_context.h"
#include "mojo/public/cpp/bindings/message.h"
#include "third_party/blink/public/mojom/dom_storage/session_storage_namespace.mojom.h"
#include "third_party/blink/public/mojom/dom_storage/storage_area.mojom.h"
#include "url/origin.h"
......@@ -83,6 +84,7 @@ class CONTENT_EXPORT DOMStorageContextWrapper
blink::mojom::StorageAreaRequest request);
void OpenSessionStorage(int process_id,
const std::string& namespace_id,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::SessionStorageNamespaceRequest request);
void SetLocalStorageDatabaseForTesting(
......
......@@ -121,17 +121,18 @@ SessionStorageContextMojo::~SessionStorageContextMojo() {
void SessionStorageContextMojo::OpenSessionStorage(
int process_id,
const std::string& namespace_id,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::SessionStorageNamespaceRequest request) {
if (connection_state_ != CONNECTION_FINISHED) {
RunWhenConnected(
base::BindOnce(&SessionStorageContextMojo::OpenSessionStorage,
weak_ptr_factory_.GetWeakPtr(), process_id, namespace_id,
std::move(request)));
std::move(bad_message_callback), std::move(request)));
return;
}
auto found = namespaces_.find(namespace_id);
if (found == namespaces_.end()) {
mojo::ReportBadMessage("Namespace not found: " + namespace_id);
std::move(bad_message_callback).Run("Namespace not found: " + namespace_id);
return;
}
......@@ -533,6 +534,7 @@ void SessionStorageContextMojo::RegisterShallowClonedNamespace(
if (it != namespaces_.end()) {
found = true;
if (it->second->IsPopulated()) {
// Assumes this method is called on a stack handling a mojo message.
mojo::ReportBadMessage("Cannot clone to already populated namespace");
return;
}
......
......@@ -23,6 +23,7 @@
#include "content/browser/dom_storage/session_storage_namespace_impl_mojo.h"
#include "content/common/content_export.h"
#include "content/public/browser/session_storage_usage_info.h"
#include "mojo/public/cpp/bindings/message.h"
#include "services/file/public/mojom/file_system.mojom.h"
#include "third_party/blink/public/mojom/dom_storage/session_storage_namespace.mojom.h"
#include "url/origin.h"
......@@ -83,6 +84,7 @@ class CONTENT_EXPORT SessionStorageContextMojo
void OpenSessionStorage(int process_id,
const std::string& namespace_id,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::SessionStorageNamespaceRequest request);
void CreateSessionNamespace(const std::string& namespace_id);
......
......@@ -871,6 +871,7 @@ void StoragePartitionImpl::OpenSessionStorage(
blink::mojom::SessionStorageNamespaceRequest request) {
int process_id = bindings_.dispatch_context();
dom_storage_context_->OpenSessionStorage(process_id, namespace_id,
bindings_.GetBadMessageCallback(),
std::move(request));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment