diff options
Diffstat (limited to 'chromium/components/services/storage')
18 files changed, 220 insertions, 52 deletions
diff --git a/chromium/components/services/storage/BUILD.gn b/chromium/components/services/storage/BUILD.gn index fc75d2084e7..6a7fe891fe8 100644 --- a/chromium/components/services/storage/BUILD.gn +++ b/chromium/components/services/storage/BUILD.gn @@ -144,8 +144,8 @@ source_set("tests") { "//components/services/storage/public/cpp", "//components/services/storage/public/cpp/filesystem:tests", "//components/services/storage/public/mojom", - "//mojo/core/embedder", "//mojo/public/cpp/bindings", + "//mojo/public/cpp/system", "//sql:test_support", "//testing/gmock", "//testing/gtest", diff --git a/chromium/components/services/storage/dom_storage/DEPS b/chromium/components/services/storage/dom_storage/DEPS index b8295c5742c..d211be61481 100644 --- a/chromium/components/services/storage/dom_storage/DEPS +++ b/chromium/components/services/storage/dom_storage/DEPS @@ -10,7 +10,4 @@ specific_include_rules = { "+sql", "+storage/common/database", ], - "session_storage_impl_unittest\.cc": [ - "+mojo/core", - ], } diff --git a/chromium/components/services/storage/dom_storage/local_storage_impl.cc b/chromium/components/services/storage/dom_storage/local_storage_impl.cc index db35923adc1..71b7be5bc39 100644 --- a/chromium/components/services/storage/dom_storage/local_storage_impl.cc +++ b/chromium/components/services/storage/dom_storage/local_storage_impl.cc @@ -520,7 +520,7 @@ void LocalStorageImpl::DeleteStorage(const url::Origin& origin, found->second->storage_area()->ScheduleImmediateCommit(); } else if (database_) { DeleteOrigins( - database_.get(), {std::move(origin)}, + database_.get(), {origin}, base::BindOnce([](base::OnceClosure callback, leveldb::Status) { std::move(callback).Run(); }, std::move(callback))); diff --git a/chromium/components/services/storage/dom_storage/session_storage_impl_unittest.cc b/chromium/components/services/storage/dom_storage/session_storage_impl_unittest.cc index 7ce47e6431a..d875c4b8004 100644 --- a/chromium/components/services/storage/dom_storage/session_storage_impl_unittest.cc +++ b/chromium/components/services/storage/dom_storage/session_storage_impl_unittest.cc @@ -26,8 +26,8 @@ #include "components/services/storage/dom_storage/legacy_dom_storage_database.h" #include "components/services/storage/dom_storage/storage_area_test_util.h" #include "components/services/storage/dom_storage/testing_legacy_session_storage_database.h" -#include "mojo/core/embedder/embedder.h" #include "mojo/public/cpp/bindings/remote.h" +#include "mojo/public/cpp/system/functions.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/features.h" #include "url/gurl.h" @@ -65,15 +65,14 @@ class SessionStorageImplTest : public testing::Test { } void SetUp() override { - mojo::core::SetDefaultProcessErrorCallback(base::BindRepeating( + mojo::SetDefaultProcessErrorHandler(base::BindRepeating( &SessionStorageImplTest::OnBadMessage, base::Unretained(this))); } void TearDown() override { if (session_storage_) ShutDownSessionStorage(); - mojo::core::SetDefaultProcessErrorCallback( - mojo::core::ProcessErrorCallback()); + mojo::SetDefaultProcessErrorHandler(base::NullCallback()); } void OnBadMessage(const std::string& reason) { bad_message_called_ = true; } diff --git a/chromium/components/services/storage/dom_storage/session_storage_metadata.cc b/chromium/components/services/storage/dom_storage/session_storage_metadata.cc index 31beda77160..59f8a304ffd 100644 --- a/chromium/components/services/storage/dom_storage/session_storage_metadata.cc +++ b/chromium/components/services/storage/dom_storage/session_storage_metadata.cc @@ -4,6 +4,7 @@ #include "components/services/storage/dom_storage/session_storage_metadata.h" +#include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" diff --git a/chromium/components/services/storage/indexed_db/leveldb/leveldb_factory.cc b/chromium/components/services/storage/indexed_db/leveldb/leveldb_factory.cc index 848d28fa2cb..c4082447fb4 100644 --- a/chromium/components/services/storage/indexed_db/leveldb/leveldb_factory.cc +++ b/chromium/components/services/storage/indexed_db/leveldb/leveldb_factory.cc @@ -4,6 +4,7 @@ #include "components/services/storage/indexed_db/leveldb/leveldb_factory.h" +#include "base/logging.h" #include "base/system/sys_info.h" #include "components/services/storage/indexed_db/leveldb/leveldb_state.h" #include "third_party/leveldatabase/leveldb_chrome.h" diff --git a/chromium/components/services/storage/indexed_db/leveldb/leveldb_state.cc b/chromium/components/services/storage/indexed_db/leveldb/leveldb_state.cc index c2f12753efa..0773cd8632e 100644 --- a/chromium/components/services/storage/indexed_db/leveldb/leveldb_state.cc +++ b/chromium/components/services/storage/indexed_db/leveldb/leveldb_state.cc @@ -17,9 +17,10 @@ scoped_refptr<LevelDBState> LevelDBState::CreateForDiskDB( const leveldb::Comparator* comparator, std::unique_ptr<leveldb::DB> database, base::FilePath database_path) { - return base::WrapRefCounted(new LevelDBState( - nullptr, comparator, std::move(database), std::move(database_path), - database_path.BaseName().AsUTF8Unsafe())); + auto name_for_tracing = database_path.BaseName().AsUTF8Unsafe(); + return base::WrapRefCounted( + new LevelDBState(nullptr, comparator, std::move(database), + std::move(database_path), std::move(name_for_tracing))); } // static diff --git a/chromium/components/services/storage/indexed_db/scopes/leveldb_scope.h b/chromium/components/services/storage/indexed_db/scopes/leveldb_scope.h index 7e76964bb7e..10538eafcfd 100644 --- a/chromium/components/services/storage/indexed_db/scopes/leveldb_scope.h +++ b/chromium/components/services/storage/indexed_db/scopes/leveldb_scope.h @@ -12,9 +12,9 @@ #include <vector> #include "base/callback.h" +#include "base/check_op.h" #include "base/compiler_specific.h" #include "base/containers/flat_map.h" -#include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/numerics/checked_math.h" diff --git a/chromium/components/services/storage/indexed_db/scopes/scope_lock.h b/chromium/components/services/storage/indexed_db/scopes/scope_lock.h index 0da1bc3670f..26067646c51 100644 --- a/chromium/components/services/storage/indexed_db/scopes/scope_lock.h +++ b/chromium/components/services/storage/indexed_db/scopes/scope_lock.h @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/callback_helpers.h" -#include "base/logging.h" #include "base/macros.h" #include "components/services/storage/indexed_db/scopes/scope_lock_range.h" #include "third_party/leveldatabase/src/include/leveldb/comparator.h" diff --git a/chromium/components/services/storage/indexed_db/scopes/scope_lock_range.h b/chromium/components/services/storage/indexed_db/scopes/scope_lock_range.h index 6b0730dee4d..d941bdd079a 100644 --- a/chromium/components/services/storage/indexed_db/scopes/scope_lock_range.h +++ b/chromium/components/services/storage/indexed_db/scopes/scope_lock_range.h @@ -8,7 +8,6 @@ #include <iosfwd> #include <vector> -#include "base/logging.h" #include "third_party/leveldatabase/src/include/leveldb/comparator.h" #include "third_party/leveldatabase/src/include/leveldb/slice.h" diff --git a/chromium/components/services/storage/indexed_db/scopes/scopes_lock_manager.h b/chromium/components/services/storage/indexed_db/scopes/scopes_lock_manager.h index b29217473f4..6f515f2940e 100644 --- a/chromium/components/services/storage/indexed_db/scopes/scopes_lock_manager.h +++ b/chromium/components/services/storage/indexed_db/scopes/scopes_lock_manager.h @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/containers/flat_set.h" -#include "base/logging.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "components/services/storage/indexed_db/scopes/scope_lock.h" diff --git a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.cc b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.cc index c8ba2323217..15b64768a65 100644 --- a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.cc +++ b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.cc @@ -97,10 +97,12 @@ leveldb::Status TransactionalLevelDBTransaction::Rollback() { } std::unique_ptr<TransactionalLevelDBIterator> -TransactionalLevelDBTransaction::CreateIterator() { - leveldb::Status s = scope_->WriteChangesAndUndoLog(); +TransactionalLevelDBTransaction::CreateIterator(leveldb::Status& s) { + s = scope_->WriteChangesAndUndoLog(); if (!s.ok() && !s.IsNotFound()) return nullptr; + // Only return a "not ok" if the returned iterator is null. + s = leveldb::Status::OK(); std::unique_ptr<TransactionalLevelDBIterator> it = db_->CreateIterator( weak_factory_.GetWeakPtr(), db_->DefaultReadOptions()); loaded_iterators_.insert(it.get()); diff --git a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.h b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.h index 02dee6459fa..976cd266cca 100644 --- a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.h +++ b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.h @@ -65,8 +65,9 @@ class TransactionalLevelDBTransaction leveldb::Status Rollback() WARN_UNUSED_RESULT; // The returned iterator must be destroyed before the destruction of this - // transaction. - std::unique_ptr<TransactionalLevelDBIterator> CreateIterator(); + // transaction. This may return null, if it does, status will explain why. + std::unique_ptr<TransactionalLevelDBIterator> CreateIterator( + leveldb::Status& status); uint64_t GetTransactionSize() const; diff --git a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction_unittest.cc b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction_unittest.cc index 124ca34475e..52432a73758 100644 --- a/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction_unittest.cc +++ b/chromium/components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction_unittest.cc @@ -216,8 +216,10 @@ TEST_F(TransactionalLevelDBTransactionTest, Iterator) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); it->Seek(std::string("b")); @@ -280,20 +282,26 @@ TEST_F(TransactionalLevelDBTransactionTest, IterationWithEvictedCursors) { CreateTransaction(); std::unique_ptr<TransactionalLevelDBIterator> evicted_normal_location = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); std::unique_ptr<TransactionalLevelDBIterator> evicted_before_start = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); std::unique_ptr<TransactionalLevelDBIterator> evicted_after_end = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); std::unique_ptr<TransactionalLevelDBIterator> it1 = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); std::unique_ptr<TransactionalLevelDBIterator> it2 = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); std::unique_ptr<TransactionalLevelDBIterator> it3 = - transaction->CreateIterator(); + transaction->CreateIterator(status); + ASSERT_TRUE(status.ok()); evicted_normal_location->Seek("b-key1"); evicted_before_start->Seek("b-key1"); @@ -360,8 +368,10 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorReloadingNext) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); it->Seek(std::string("b")); ASSERT_TRUE(it->IsValid()); @@ -397,8 +407,10 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorReloadingPrev) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); it->SeekToLast(); ASSERT_TRUE(it->IsValid()); @@ -430,8 +442,10 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorSkipsScopesMetadata) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); // Should skip metadata, and go to key1. it->Seek(""); @@ -462,8 +476,10 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorReflectsInitialChanges) { TransactionPut(transaction.get(), key1, value); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); it->Seek(""); ASSERT_TRUE(it->IsValid()); @@ -596,7 +612,8 @@ TEST_P(LevelDBTransactionRangeTest, RemoveRangeIteratorRetainsKey) { leveldb::Status status; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction_->CreateIterator(); + transaction_->CreateIterator(status); + ASSERT_TRUE(status.ok()); status = it->Seek(key_in_range1_); EXPECT_TRUE(status.ok()); EXPECT_TRUE(it->IsValid()); @@ -643,10 +660,12 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorValueStaysTheSame) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -685,10 +704,12 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorPutInvalidation) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -767,10 +788,12 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorRemoveInvalidation) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -834,10 +857,12 @@ TEST_F(TransactionalLevelDBTransactionTest, IteratorGoesInvalidAfterRemove) { scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -905,10 +930,12 @@ TEST_F(TransactionalLevelDBTransactionTest, scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -940,10 +967,12 @@ TEST_F(TransactionalLevelDBTransactionTest, scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key2")); + s = it->Seek(std::string("b-key2")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); @@ -976,10 +1005,12 @@ TEST_F(TransactionalLevelDBTransactionTest, scoped_refptr<TransactionalLevelDBTransaction> transaction = CreateTransaction(); + leveldb::Status s; std::unique_ptr<TransactionalLevelDBIterator> it = - transaction->CreateIterator(); + transaction->CreateIterator(s); + ASSERT_TRUE(s.ok()); - leveldb::Status s = it->Seek(std::string("b-key1")); + s = it->Seek(std::string("b-key1")); ASSERT_TRUE(it->IsValid()); EXPECT_TRUE(s.ok()); diff --git a/chromium/components/services/storage/public/mojom/BUILD.gn b/chromium/components/services/storage/public/mojom/BUILD.gn index deca2936c52..454e9d47add 100644 --- a/chromium/components/services/storage/public/mojom/BUILD.gn +++ b/chromium/components/services/storage/public/mojom/BUILD.gn @@ -6,6 +6,7 @@ import("//mojo/public/tools/bindings/mojom.gni") mojom("mojom") { sources = [ + "blob_storage_context.mojom", "indexed_db_control.mojom", "indexed_db_control_test.mojom", "local_storage_control.mojom", @@ -21,12 +22,14 @@ mojom("mojom") { public_deps = [ "//components/services/storage/public/mojom/filesystem", "//mojo/public/mojom/base", + "//third_party/blink/public/mojom:mojom_core", "//third_party/blink/public/mojom:mojom_modules", "//third_party/blink/public/mojom:mojom_platform", "//url/mojom:url_mojom_origin", ] overridden_deps = [ + "//third_party/blink/public/mojom:mojom_core", "//third_party/blink/public/mojom:mojom_modules", "//third_party/blink/public/mojom:mojom_platform", ] diff --git a/chromium/components/services/storage/public/mojom/blob_storage_context.mojom b/chromium/components/services/storage/public/mojom/blob_storage_context.mojom new file mode 100644 index 00000000000..798a1083bfb --- /dev/null +++ b/chromium/components/services/storage/public/mojom/blob_storage_context.mojom @@ -0,0 +1,88 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module storage.mojom; + +import "mojo/public/mojom/base/big_buffer.mojom"; +import "mojo/public/mojom/base/file_path.mojom"; +import "mojo/public/mojom/base/time.mojom"; +import "third_party/blink/public/mojom/blob/blob.mojom"; + +// A reader for the data and side data in a cache storage entry. +interface BlobDataItemReader { + // Causes a subrange of the contents of this entry to be written into the + // given data pipe. Returns the net::Error result. + Read(uint64 offset, uint64 length, handle<data_pipe_producer> pipe) + => (int32 success); + // Reads the side-data (if any) associated with this entry. Returns + // a net::Error result and the data, if any. + ReadSideData() => (int32 success, mojo_base.mojom.BigBuffer data); +}; + +// The type of BlobDataItem. Used for histograms. +enum BlobDataItemType { + kUnknown, // Type not known. + kCacheStorage, // Data comes from the cache storage system. + kIndexedDB, // Data comes from the IndexedDB storage system. +}; + +// A remote representation of a BlobDataItem::DataHandle for cache storage. +struct BlobDataItem { + BlobDataItemType type; + + // The size of the normal data. BlobDataItem::DataHandle needs this + // synchronously, which is why it is in a struct and not the interface. + uint64 size; + + // The size of the side data. If this is zero, reader.ReadSideData() + // should not be called, and there is no side data. + uint64 side_data_size; + + // The mime type of this data item. This is empty if unknown. + string content_type; + + // An interface to read the normal and side data of this entry. + pending_remote<BlobDataItemReader> reader; +}; + +// The result of writing a blob to disk. +enum WriteBlobToFileResult { + kError, // There was an error writing the blob to a file. + kBadPath, // The path given is not accessible or has references. + kInvalidBlob, // The blob is invalid and cannot be read. + kIOError, // Error writing bytes on disk. + kTimestampError, // Error writing the last modified timestamp. + kSuccess, +}; + +// This interface is the primary access point to the browser's blob system +// for chrome internals. This interface lives in the browser process. This is a +// simplified version of the blink.mojom.BlobRegistry interface. +// +// This interface has enhanced capabilities that should NOT be accessible to a +// renderer, which is why it is a separate interface. For example, +// WriteBlobToFile writes a blob to an arbitrary file path. +interface BlobStorageContext { + // Create a blob with a particular uuid and consisting of a single + // BlobDataItem::DataHandle constructed from |item|. + RegisterFromDataItem(pending_receiver<blink.mojom.Blob> blob, string uuid, + BlobDataItem item); + // Create a blob with a particular uuid whose contents are contained + // in |data|. + RegisterFromMemory(pending_receiver<blink.mojom.Blob> blob, string uuid, + mojo_base.mojom.BigBuffer data); + + // Writes the given blob to the given file path. If the given |path| is not + // under the blob storage context's profile directory or if it has references + // (like "..") then the implementation returns kBadPath. If the directory + // that contains the file at |path| does not exist, then this function will + // return kIOError. If a file already exists at |path| then it is + // overwritten. If |flush_on_write| is true, then Flush will be called on the + // new file before it is closed. + WriteBlobToFile(pending_remote<blink.mojom.Blob> blob, + mojo_base.mojom.FilePath path, + bool flush_on_write, + mojo_base.mojom.Time? last_modified) + => (WriteBlobToFileResult result); +}; diff --git a/chromium/components/services/storage/public/mojom/indexed_db_control.mojom b/chromium/components/services/storage/public/mojom/indexed_db_control.mojom index 3222711095a..f463dba02f1 100644 --- a/chromium/components/services/storage/public/mojom/indexed_db_control.mojom +++ b/chromium/components/services/storage/public/mojom/indexed_db_control.mojom @@ -35,6 +35,15 @@ struct IndexedDBStorageUsageInfo { mojo_base.mojom.Time last_modified_time; }; +// Indicates a policy update for a specific origin. +struct IndexedDBStoragePolicyUpdate { + // The origin to which this policy applies. + url.mojom.Origin origin; + + // Indicates whether data for this origin should be purged on shutdown. + bool purge_on_shutdown; +}; + // Communicates with IndexedDB clients about changes in IndexedDB. interface IndexedDBObserver { // This function is called when the size of the usage for a particular origin @@ -92,6 +101,10 @@ interface IndexedDBControl { // Adds an observer to be notified about modifications to IndexedDB. AddObserver(pending_remote<IndexedDBObserver> observer); + // Applies changes to data retention policy which are relevant at shutdown. + // See IndexedDBStoragePolicyUpdate. + ApplyPolicyUpdates(array<IndexedDBStoragePolicyUpdate> policy_updates); + // Binds the testing interface for extra functionality only available in // tests. BindTestInterface(pending_receiver<IndexedDBControlTest> receiver); diff --git a/chromium/components/services/storage/public/mojom/service_worker_storage_control.mojom b/chromium/components/services/storage/public/mojom/service_worker_storage_control.mojom index dac94fb9898..b8c9744f6c3 100644 --- a/chromium/components/services/storage/public/mojom/service_worker_storage_control.mojom +++ b/chromium/components/services/storage/public/mojom/service_worker_storage_control.mojom @@ -17,15 +17,33 @@ struct SerializedServiceWorkerRegistration { array<ServiceWorkerResourceRecord> resources; }; +// An interface that is used to keep track of which service worker versions are +// being used by clients of the storage service. This is an empty interface that +// is mapped internally by the storage service to a single version. +// +// This is used to decide when it's safe to purge resources for a service worker +// version whose registration has been deleted. A service worker version can be +// still be used and may need to be started and stopped multiple times after +// unregistration. The client of the storage service should hold on to the +// reference as long as it's using the version, i.e., by making the reference +// owned by the C++ ServiceWorkerVersion instance. +interface ServiceWorkerLiveVersionRef {}; + // Conveys a result of finding a registration. If a registration is found, -// |status| will be kOk. |registration| and |resources| are null and empty -// if there is no matching registration. +// |status| will be kOk. |version_reference|, |registration| and |resources| are +// null or empty if there is no matching registration. // // The Storage Service (components/services/storage) supplies this // information and the //content consumes the information. struct ServiceWorkerFindRegistrationResult { + // The result of a find operation. ServiceWorkerDatabaseStatus status; + // A reference to a service worker version associated with + // |registration->version_id|. + pending_remote<ServiceWorkerLiveVersionRef>? version_reference; + // Stored registration. ServiceWorkerRegistrationData? registration; + // Resources associated with |registration|. array<ServiceWorkerResourceRecord> resources; }; @@ -137,10 +155,13 @@ interface ServiceWorkerStorageControl { // storage. Returns blink::mojom::kInvalidServiceWorkerRegistrationId if the // storage is disabled. GetNewRegistrationId() => (int64 registration_id); - // Returns a new service worker version id which is guaranteed to be unique - // in the storage. Returns blink::mojom::kInvalidServiceWorkerVersionId if - // the storage is disabled. - GetNewVersionId() => (int64 version_id); + // Returns a new service worker version id, which is guaranteed to be unique + // in the storage, and a reference to the version id. + // blink::mojom::kInvalidServiceWorkerVersionId and null reference are + // returned if the storage is disabled. + GetNewVersionId() => + (int64 version_id, + pending_remote<ServiceWorkerLiveVersionRef>? version_reference); // Returns a new resource id which is guaranteed to be unique in the storage. // Returns blink::mojom::kInvalidServiceWorkerResourceId if the storage // is disabled. @@ -157,6 +178,19 @@ interface ServiceWorkerStorageControl { int64 resource_id, pending_receiver<ServiceWorkerResourceMetadataWriter> writer); + // Puts |resource_id| on the uncommitted resource list in storage. Once + // |resource_id| is put on the uncommitted resource list, the corresponding + // resource is considered to be existing in storage but it's not associated + // with any registration yet. + // StoreRegistration() or DoomUncommittedResources() needs to be + // called later to clear the |resource_id| from the uncommitted resource list. + StoreUncommittedResourceId(int64 resource_id, url.mojom.Url origin) => + (ServiceWorkerDatabaseStatus status); + + // Removes |resource_ids| from the uncommitted resource list. + DoomUncommittedResources(array<int64> resource_ids) => + (ServiceWorkerDatabaseStatus status); + // Gets user data associated with the given |registration_id|. // Succeeds only when all keys are found. On success, the size and the order // of |values| are the same as |keys|. |