Commit baa43bde authored by Daniel Murphy's avatar Daniel Murphy Committed by Commit Bot

[SessionStorage] Fixed Clear Browsing Data Dialog data deletion

When using the Clear Browsing Dialog, this can call a DeleteAll in
SessionStorage backend code. There were DCHECKs around being bound to
a renderer, but this doesn't need to be the case when using the Clear
Browsing Data Dialog.

This CL removes those DCHECKs for DeleteAll.

R=mek@chromium.org

Bug: 859876
Change-Id: Iee4e3027ad1a1c396f1b7f746aec0e844a8f64b1
Reviewed-on: https://chromium-review.googlesource.com/1125023Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573494}
parent c63a8a7a
......@@ -94,8 +94,8 @@ void SessionStorageAreaImpl::Delete(
void SessionStorageAreaImpl::DeleteAll(const std::string& source,
DeleteAllCallback callback) {
DCHECK(IsBound());
DCHECK_NE(0, shared_data_map_->map_data()->ReferenceCount());
// Note: This can be called by the Clear Browsing Data flow, and thus doesn't
// have to be bound.
if (shared_data_map_->map_data()->ReferenceCount() > 1) {
CreateNewMap(NewMapType::EMPTY_FROM_DELETE_ALL, source);
std::move(callback).Run(true);
......
......@@ -360,4 +360,31 @@ TEST_F(SessionStorageAreaImplTest, DeleteAllOnShared) {
ss_leveldb_impl2 = nullptr;
}
TEST_F(SessionStorageAreaImplTest, DeleteAllWithoutBinding) {
EXPECT_CALL(listener_,
OnDataMapCreation(StdStringToUint8Vector("0"), testing::_))
.Times(1);
auto ss_leveldb_impl1 = std::make_unique<SessionStorageAreaImpl>(
metadata_.GetOrCreateNamespaceEntry(test_namespace_id1_), test_origin1_,
SessionStorageDataMap::Create(
&listener_,
metadata_.GetOrCreateNamespaceEntry(test_namespace_id1_)
->second[test_origin1_],
leveldb_database_.get()),
GetRegisterNewAreaMapCallback());
base::RunLoop loop;
EXPECT_CALL(listener_, OnCommitResult(DatabaseError::OK))
.WillOnce(base::test::RunClosure(loop.QuitClosure()));
EXPECT_TRUE(test::DeleteAllSync(ss_leveldb_impl1.get(), "source"));
ss_leveldb_impl1->data_map()->storage_area()->ScheduleImmediateCommit();
loop.Run();
EXPECT_CALL(listener_, OnDataMapDestruction(StdStringToUint8Vector("0")))
.Times(1);
ss_leveldb_impl1 = nullptr;
}
} // namespace content
......@@ -407,6 +407,29 @@ TEST_F(SessionStorageNamespaceImplMojoTest, RemoveOriginData) {
namespaces_.clear();
}
TEST_F(SessionStorageNamespaceImplMojoTest, RemoveOriginDataWithoutBinding) {
SessionStorageNamespaceImplMojo* namespace_impl =
CreateSessionStorageNamespaceImplMojo(test_namespace_id1_);
EXPECT_CALL(listener_,
OnDataMapCreation(StdStringToUint8Vector("0"), testing::_))
.Times(1);
namespace_impl->PopulateFromMetadata(
&database_, metadata_.GetOrCreateNamespaceEntry(test_namespace_id1_),
std::map<std::vector<uint8_t>, SessionStorageDataMap*>());
base::RunLoop loop;
EXPECT_CALL(listener_, OnCommitResult(DatabaseError::OK))
.WillOnce(base::test::RunClosure(loop.QuitClosure()));
namespace_impl->RemoveOriginData(test_origin1_);
loop.Run();
EXPECT_CALL(listener_, OnDataMapDestruction(StdStringToUint8Vector("0")))
.Times(1);
namespaces_.clear();
}
TEST_F(SessionStorageNamespaceImplMojoTest, ProcessLockedToOtherOrigin) {
// Tries to open an area with a process that is locked to a different origin
// and verifies the bad message callback.
......
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