summaryrefslogtreecommitdiff
path: root/chromium/storage/browser/blob
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/storage/browser/blob')
-rw-r--r--chromium/storage/browser/blob/blob_data_builder.h2
-rw-r--r--chromium/storage/browser/blob/blob_data_item.h2
-rw-r--r--chromium/storage/browser/blob/blob_memory_controller.cc26
-rw-r--r--chromium/storage/browser/blob/blob_memory_controller.h3
-rw-r--r--chromium/storage/browser/blob/blob_memory_controller_unittest.cc85
-rw-r--r--chromium/storage/browser/blob/blob_registry_impl_unittest.cc7
-rw-r--r--chromium/storage/browser/blob/blob_storage_context.h2
-rw-r--r--chromium/storage/browser/blob/blob_storage_context_mojo_unittest.cc2
-rw-r--r--chromium/storage/browser/blob/blob_transport_strategy_unittest.cc9
-rw-r--r--chromium/storage/browser/blob/blob_url_loader.cc2
-rw-r--r--chromium/storage/browser/blob/blob_url_store_impl_unittest.cc8
-rw-r--r--chromium/storage/browser/blob/mojom/OWNERS5
-rw-r--r--chromium/storage/browser/blob/mojom/blob_storage_context.mojom88
-rw-r--r--chromium/storage/browser/blob/scoped_file.cc4
-rw-r--r--chromium/storage/browser/blob/shareable_file_reference.cc1
-rw-r--r--chromium/storage/browser/blob/write_blob_to_file.h2
16 files changed, 98 insertions, 150 deletions
diff --git a/chromium/storage/browser/blob/blob_data_builder.h b/chromium/storage/browser/blob/blob_data_builder.h
index 50e0acbe042..a40f4ef4854 100644
--- a/chromium/storage/browser/blob/blob_data_builder.h
+++ b/chromium/storage/browser/blob/blob_data_builder.h
@@ -16,10 +16,10 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/numerics/checked_math.h"
+#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "storage/browser/blob/blob_data_item.h"
#include "storage/browser/blob/blob_data_snapshot.h"
#include "storage/browser/blob/blob_entry.h"
-#include "storage/browser/blob/mojom/blob_storage_context.mojom.h"
#include "storage/browser/blob/shareable_blob_data_item.h"
#include "storage/browser/blob/shareable_file_reference.h"
#include "storage/browser/file_system/file_system_context.h"
diff --git a/chromium/storage/browser/blob/blob_data_item.h b/chromium/storage/browser/blob/blob_data_item.h
index 9ec2e5a9ae0..d40d1edf6c1 100644
--- a/chromium/storage/browser/blob/blob_data_item.h
+++ b/chromium/storage/browser/blob/blob_data_item.h
@@ -15,8 +15,8 @@
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
+#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "net/base/io_buffer.h"
-#include "storage/browser/blob/mojom/blob_storage_context.mojom.h"
#include "storage/browser/blob/shareable_file_reference.h"
#include "url/gurl.h"
diff --git a/chromium/storage/browser/blob/blob_memory_controller.cc b/chromium/storage/browser/blob/blob_memory_controller.cc
index e538ce2c181..d5166cc7fdc 100644
--- a/chromium/storage/browser/blob/blob_memory_controller.cc
+++ b/chromium/storage/browser/blob/blob_memory_controller.cc
@@ -14,6 +14,7 @@
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/containers/small_map.h"
+#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/guid.h"
#include "base/location.h"
@@ -40,6 +41,13 @@ using base::File;
using base::FilePath;
namespace storage {
+
+// static
+const base::Feature
+ BlobMemoryController::kInhibitBlobMemoryControllerMemoryPressureResponse{
+ "InhibitBlobMemoryControllerMemoryPressureResponse",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
namespace {
constexpr int64_t kUnknownDiskAvailability = -1ll;
constexpr uint64_t kMegabyte = 1024ull * 1024;
@@ -535,6 +543,7 @@ BlobMemoryController::BlobMemoryController(
populated_memory_items_(
base::MRUCache<uint64_t, ShareableBlobDataItem*>::NO_AUTO_EVICT),
memory_pressure_listener_(
+ FROM_HERE,
base::BindRepeating(&BlobMemoryController::OnMemoryPressure,
base::Unretained(this))) {}
@@ -1039,13 +1048,24 @@ void BlobMemoryController::OnEvictionComplete(
void BlobMemoryController::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
- // TODO(sebmarchand): Check if MEMORY_PRESSURE_LEVEL_MODERATE should also be
- // ignored.
+ // Under critical memory pressure the system is probably already swapping out
+ // memory and making heavy use of IO. Adding to that is not desirable.
+ // Furthermore, scheduling a task to write files to disk risks paging-in
+ // memory that was already committed to disk which compounds the problem. Do
+ // not take any action on critical memory pressure.
if (memory_pressure_level ==
- base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) {
+ base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
return;
}
+ if (base::FeatureList::IsEnabled(
+ kInhibitBlobMemoryControllerMemoryPressureResponse)) {
+ return;
+ }
+
+ // TODO(crbug.com/1087530): Run trial to see if we should get rid of this
+ // whole intervention or leave it on for MEMORY_PRESSURE_LEVEL_MODERATE.
+
auto time_from_last_evicion = base::TimeTicks::Now() - last_eviction_time_;
if (last_eviction_time_ != base::TimeTicks() &&
time_from_last_evicion.InSeconds() < kMinSecondsForPressureEvictions) {
diff --git a/chromium/storage/browser/blob/blob_memory_controller.h b/chromium/storage/browser/blob/blob_memory_controller.h
index 997fd9377f3..1293e42af10 100644
--- a/chromium/storage/browser/blob/blob_memory_controller.h
+++ b/chromium/storage/browser/blob/blob_memory_controller.h
@@ -20,6 +20,7 @@
#include "base/callback_helpers.h"
#include "base/component_export.h"
#include "base/containers/mru_cache.h"
+#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
@@ -54,6 +55,8 @@ class ShareableFileReference;
// This class can only be interacted with on the IO thread.
class COMPONENT_EXPORT(STORAGE_BROWSER) BlobMemoryController {
public:
+ static const base::Feature kInhibitBlobMemoryControllerMemoryPressureResponse;
+
enum class Strategy {
// We don't have enough memory for this blob.
TOO_LARGE,
diff --git a/chromium/storage/browser/blob/blob_memory_controller_unittest.cc b/chromium/storage/browser/blob/blob_memory_controller_unittest.cc
index d376b24df84..89b811e7740 100644
--- a/chromium/storage/browser/blob/blob_memory_controller_unittest.cc
+++ b/chromium/storage/browser/blob/blob_memory_controller_unittest.cc
@@ -12,6 +12,7 @@
#include "base/system/sys_info.h"
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
+#include "base/test/with_feature_override.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "storage/browser/blob/blob_data_builder.h"
@@ -47,9 +48,13 @@ int64_t FakeDiskSpaceMethod(const base::FilePath& path) {
return sFakeDiskSpace;
}
-class BlobMemoryControllerTest : public testing::Test {
+class BlobMemoryControllerTest : public base::test::WithFeatureOverride,
+ public testing::Test {
protected:
- BlobMemoryControllerTest() = default;
+ BlobMemoryControllerTest()
+ : base::test::WithFeatureOverride(
+ BlobMemoryController::
+ kInhibitBlobMemoryControllerMemoryPressureResponse) {}
void SetUp() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -168,7 +173,7 @@ class BlobMemoryControllerTest : public testing::Test {
base::test::SingleThreadTaskEnvironment task_environment_;
};
-TEST_F(BlobMemoryControllerTest, Strategy) {
+TEST_P(BlobMemoryControllerTest, Strategy) {
{
BlobMemoryController controller(temp_dir_.GetPath(), nullptr);
SetTestMemoryLimits(&controller);
@@ -226,7 +231,7 @@ TEST_F(BlobMemoryControllerTest, Strategy) {
}
}
-TEST_F(BlobMemoryControllerTest, GrantMemory) {
+TEST_P(BlobMemoryControllerTest, GrantMemory) {
const std::string kId = "id";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
@@ -249,7 +254,7 @@ TEST_F(BlobMemoryControllerTest, GrantMemory) {
EXPECT_TRUE(HasMemoryAllocation(items[0].get()));
}
-TEST_F(BlobMemoryControllerTest, SimpleMemoryRequest) {
+TEST_P(BlobMemoryControllerTest, SimpleMemoryRequest) {
const std::string kId = "id";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
@@ -275,7 +280,7 @@ TEST_F(BlobMemoryControllerTest, SimpleMemoryRequest) {
EXPECT_EQ(0u, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, PageToDisk) {
+TEST_P(BlobMemoryControllerTest, PageToDisk) {
const std::string kId = "id";
const std::string kId2 = "id2";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
@@ -347,7 +352,7 @@ TEST_F(BlobMemoryControllerTest, PageToDisk) {
EXPECT_EQ(0u, controller.disk_usage());
}
-TEST_F(BlobMemoryControllerTest, NoDiskTooLarge) {
+TEST_P(BlobMemoryControllerTest, NoDiskTooLarge) {
BlobMemoryController controller(temp_dir_.GetPath(), nullptr);
SetTestMemoryLimits(&controller);
@@ -356,14 +361,14 @@ TEST_F(BlobMemoryControllerTest, NoDiskTooLarge) {
1));
}
-TEST_F(BlobMemoryControllerTest, TooLargeForDisk) {
+TEST_P(BlobMemoryControllerTest, TooLargeForDisk) {
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
EXPECT_FALSE(controller.CanReserveQuota(kTestBlobStorageMaxDiskSpace + 1));
}
-TEST_F(BlobMemoryControllerTest, CancelMemoryRequest) {
+TEST_P(BlobMemoryControllerTest, CancelMemoryRequest) {
const std::string kId = "id";
const std::string kId2 = "id2";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
@@ -423,7 +428,7 @@ TEST_F(BlobMemoryControllerTest, CancelMemoryRequest) {
EXPECT_EQ(0u, controller.disk_usage());
}
-TEST_F(BlobMemoryControllerTest, FileRequest) {
+TEST_P(BlobMemoryControllerTest, FileRequest) {
const std::string kId = "id";
const size_t kBlobSize = kTestBlobStorageMaxBlobMemorySize + 1;
@@ -479,7 +484,7 @@ TEST_F(BlobMemoryControllerTest, FileRequest) {
EXPECT_EQ(0u, controller.disk_usage());
}
-TEST_F(BlobMemoryControllerTest, CancelFileRequest) {
+TEST_P(BlobMemoryControllerTest, CancelFileRequest) {
const std::string kId = "id";
const size_t kBlobSize = kTestBlobStorageMaxBlobMemorySize + 1;
@@ -512,7 +517,7 @@ TEST_F(BlobMemoryControllerTest, CancelFileRequest) {
base::RunLoop().RunUntilIdle();
}
-TEST_F(BlobMemoryControllerTest, MultipleFilesPaged) {
+TEST_P(BlobMemoryControllerTest, MultipleFilesPaged) {
const std::string kId1 = "id";
const size_t kSize1 = kTestBlobStorageMaxFileSizeBytes;
char kData1[kSize1];
@@ -605,7 +610,7 @@ TEST_F(BlobMemoryControllerTest, MultipleFilesPaged) {
EXPECT_EQ(0u, controller.disk_usage());
}
-TEST_F(BlobMemoryControllerTest, FullEviction) {
+TEST_P(BlobMemoryControllerTest, FullEviction) {
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
AssertEnoughDiskSpace();
@@ -660,7 +665,7 @@ TEST_F(BlobMemoryControllerTest, FullEviction) {
EXPECT_TRUE(memory_quota_result_);
}
-TEST_F(BlobMemoryControllerTest, PagingStopsWhenFull) {
+TEST_P(BlobMemoryControllerTest, PagingStopsWhenFull) {
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
AssertEnoughDiskSpace();
@@ -786,7 +791,7 @@ TEST_F(BlobMemoryControllerTest, PagingStopsWhenFull) {
EXPECT_EQ(Strategy::TOO_LARGE, controller.DetermineStrategy(1u, 1ull));
}
-TEST_F(BlobMemoryControllerTest, DisableDiskWithFileAndMemoryPending) {
+TEST_P(BlobMemoryControllerTest, DisableDiskWithFileAndMemoryPending) {
const std::string kFirstMemoryId = "id";
const uint64_t kFirstMemorySize = kTestBlobStorageMaxBlobMemorySize;
const std::string kSecondMemoryId = "id2";
@@ -871,7 +876,7 @@ TEST_F(BlobMemoryControllerTest, DisableDiskWithFileAndMemoryPending) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceTooSmallForItem) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceTooSmallForItem) {
const std::string kFileId = "id2";
const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
@@ -905,7 +910,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceTooSmallForItem) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceHitMinAvailable) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceHitMinAvailable) {
const std::string kFileId = "id2";
const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
@@ -947,7 +952,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceHitMinAvailable) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceBeforeMinAvailable) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceBeforeMinAvailable) {
const std::string kFileId = "id2";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
@@ -988,7 +993,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceBeforeMinAvailable) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceNearMinAvailable) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceNearMinAvailable) {
const std::string kFileId = "id2";
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
@@ -1030,7 +1035,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceNearMinAvailable) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceResetAfterIncrease) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceResetAfterIncrease) {
const std::string kFileId = "id2";
const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
@@ -1098,7 +1103,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceResetAfterIncrease) {
EXPECT_EQ(0ull, controller.memory_usage());
}
-TEST_F(BlobMemoryControllerTest, DiskSpaceUnknown) {
+TEST_P(BlobMemoryControllerTest, DiskSpaceUnknown) {
const std::string kFileId = "id2";
const uint64_t kFileBlobSize = kTestBlobStorageMaxBlobMemorySize;
@@ -1127,7 +1132,7 @@ TEST_F(BlobMemoryControllerTest, DiskSpaceUnknown) {
EXPECT_FALSE(controller.limits().IsDiskSpaceConstrained());
}
-TEST_F(BlobMemoryControllerTest, OnMemoryPressure) {
+TEST_P(BlobMemoryControllerTest, OnMemoryPressure) {
BlobMemoryController controller(temp_dir_.GetPath(), file_runner_);
SetTestMemoryLimits(&controller);
AssertEnoughDiskSpace();
@@ -1154,24 +1159,36 @@ TEST_F(BlobMemoryControllerTest, OnMemoryPressure) {
EXPECT_FALSE(file_runner_->HasPendingTask());
EXPECT_EQ(size_to_load, controller.memory_usage());
+ const size_t memory_usage_before_eviction = controller.memory_usage();
+ const size_t disk_usage_before_eviction = controller.disk_usage();
+
controller.OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel::
- MEMORY_PRESSURE_LEVEL_CRITICAL);
+ MEMORY_PRESSURE_LEVEL_MODERATE);
- EXPECT_TRUE(file_runner_->HasPendingTask());
- RunFileThreadTasks();
+ // Tasks are only posted if the memory pressure response is active.
+ const bool memory_pressure_response_active = !base::FeatureList::IsEnabled(
+ BlobMemoryController::kInhibitBlobMemoryControllerMemoryPressureResponse);
+ EXPECT_EQ(file_runner_->HasPendingTask(), memory_pressure_response_active);
- base::RunLoop().RunUntilIdle();
+ if (memory_pressure_response_active) {
+ RunFileThreadTasks();
- // 2 page files of size |kTestBlobStorageMaxBlobMemorySize *
- // kTestMaxBlobInMemorySpaceUnderPressureRatio| should be evicted with 1 byte
- // left in-memory.
- EXPECT_EQ(1u, controller.memory_usage());
- EXPECT_EQ(size_to_load - 1, controller.disk_usage());
- return;
+ base::RunLoop().RunUntilIdle();
+
+ // 2 page files of size |kTestBlobStorageMaxBlobMemorySize *
+ // kTestMaxBlobInMemorySpaceUnderPressureRatio| should be evicted with 1
+ // byte left in-memory.
+ EXPECT_EQ(1u, controller.memory_usage());
+ EXPECT_EQ(size_to_load - 1, controller.disk_usage());
+ } else {
+ // No intervention means the memory usage and disk usage is unchanged.
+ EXPECT_EQ(memory_usage_before_eviction, controller.memory_usage());
+ EXPECT_EQ(disk_usage_before_eviction, controller.disk_usage());
+ }
}
-TEST_F(BlobMemoryControllerTest, LowMemoryDevice) {
+TEST_P(BlobMemoryControllerTest, LowMemoryDevice) {
BlobMemoryController controller(temp_dir_.GetPath(), nullptr);
// Make 1% of physical memory size just less than min_page_file_size
controller.set_amount_of_physical_memory_for_testing(
@@ -1182,4 +1199,6 @@ TEST_F(BlobMemoryControllerTest, LowMemoryDevice) {
EXPECT_TRUE(controller.limits().IsValid());
}
+INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE(BlobMemoryControllerTest);
+
} // namespace storage
diff --git a/chromium/storage/browser/blob/blob_registry_impl_unittest.cc b/chromium/storage/browser/blob/blob_registry_impl_unittest.cc
index cf58926cb84..3495bcaf310 100644
--- a/chromium/storage/browser/blob/blob_registry_impl_unittest.cc
+++ b/chromium/storage/browser/blob/blob_registry_impl_unittest.cc
@@ -21,13 +21,13 @@
#include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_restrictions.h"
-#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
+#include "mojo/public/cpp/system/functions.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_storage_context.h"
@@ -86,7 +86,7 @@ class BlobRegistryImplTest : public testing::Test {
registry_impl_->Bind(registry_.BindNewPipeAndPassReceiver(),
std::move(delegate));
- mojo::core::SetDefaultProcessErrorCallback(base::BindRepeating(
+ mojo::SetDefaultProcessErrorHandler(base::BindRepeating(
&BlobRegistryImplTest::OnBadMessage, base::Unretained(this)));
BlobStorageLimits limits;
@@ -107,8 +107,7 @@ class BlobRegistryImplTest : public testing::Test {
void TearDown() override {
base::ThreadRestrictions::SetIOAllowed(true);
- mojo::core::SetDefaultProcessErrorCallback(
- mojo::core::ProcessErrorCallback());
+ mojo::SetDefaultProcessErrorHandler(base::NullCallback());
}
std::unique_ptr<BlobDataHandle> CreateBlobFromString(
diff --git a/chromium/storage/browser/blob/blob_storage_context.h b/chromium/storage/browser/blob/blob_storage_context.h
index 46297e542ff..575bcd3c129 100644
--- a/chromium/storage/browser/blob/blob_storage_context.h
+++ b/chromium/storage/browser/blob/blob_storage_context.h
@@ -21,6 +21,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/trace_event/memory_dump_provider.h"
+#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
@@ -29,7 +30,6 @@
#include "storage/browser/blob/blob_memory_controller.h"
#include "storage/browser/blob/blob_storage_constants.h"
#include "storage/browser/blob/blob_storage_registry.h"
-#include "storage/browser/blob/mojom/blob_storage_context.mojom.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
class GURL;
diff --git a/chromium/storage/browser/blob/blob_storage_context_mojo_unittest.cc b/chromium/storage/browser/blob/blob_storage_context_mojo_unittest.cc
index adb36e3e85d..cc8280fea3a 100644
--- a/chromium/storage/browser/blob/blob_storage_context_mojo_unittest.cc
+++ b/chromium/storage/browser/blob/blob_storage_context_mojo_unittest.cc
@@ -18,6 +18,7 @@
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_restrictions.h"
+#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "mojo/public/cpp/base/big_buffer.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -26,7 +27,6 @@
#include "net/base/net_errors.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/blob/blob_impl.h"
-#include "storage/browser/blob/mojom/blob_storage_context.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
diff --git a/chromium/storage/browser/blob/blob_transport_strategy_unittest.cc b/chromium/storage/browser/blob/blob_transport_strategy_unittest.cc
index adabe1f3831..b092056823f 100644
--- a/chromium/storage/browser/blob/blob_transport_strategy_unittest.cc
+++ b/chromium/storage/browser/blob/blob_transport_strategy_unittest.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/rand_util.h"
@@ -20,8 +21,8 @@
#include "base/task/thread_pool.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_restrictions.h"
-#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
+#include "mojo/public/cpp/system/functions.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/test/mock_bytes_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,7 +70,7 @@ class BlobTransportStrategyTest : public testing::Test {
limits_.min_page_file_size = kTestBlobStorageMinFileSizeBytes;
limits_.max_file_size = kTestBlobStorageMaxFileSizeBytes;
- mojo::core::SetDefaultProcessErrorCallback(base::BindRepeating(
+ mojo::SetDefaultProcessErrorHandler(base::BindRepeating(
&BlobTransportStrategyTest::OnBadMessage, base::Unretained(this)));
// Disallow IO on the main loop.
@@ -78,9 +79,7 @@ class BlobTransportStrategyTest : public testing::Test {
void TearDown() override {
base::ThreadRestrictions::SetIOAllowed(true);
-
- mojo::core::SetDefaultProcessErrorCallback(
- mojo::core::ProcessErrorCallback());
+ mojo::SetDefaultProcessErrorHandler(base::NullCallback());
}
void OnBadMessage(const std::string& error) {
diff --git a/chromium/storage/browser/blob/blob_url_loader.cc b/chromium/storage/browser/blob/blob_url_loader.cc
index a2e31303d90..6b925d6f5af 100644
--- a/chromium/storage/browser/blob/blob_url_loader.cc
+++ b/chromium/storage/browser/blob/blob_url_loader.cc
@@ -212,10 +212,10 @@ void BlobURLLoader::HeadersCompleted(
std::string mime_type;
response->headers->GetMimeType(&mime_type);
- // Match logic in StreamURLRequestJob::HeadersCompleted.
if (mime_type.empty())
mime_type = "text/plain";
response->mime_type = mime_type;
+ response->headers->GetCharset(&response->charset);
// TODO(jam): some of this code can be shared with
// services/network/url_loader.h
diff --git a/chromium/storage/browser/blob/blob_url_store_impl_unittest.cc b/chromium/storage/browser/blob/blob_url_store_impl_unittest.cc
index 979e675fc51..8bf46428e21 100644
--- a/chromium/storage/browser/blob/blob_url_store_impl_unittest.cc
+++ b/chromium/storage/browser/blob/blob_url_store_impl_unittest.cc
@@ -5,10 +5,11 @@
#include "storage/browser/blob/blob_url_store_impl.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
-#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
+#include "mojo/public/cpp/system/functions.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
@@ -27,13 +28,12 @@ class BlobURLStoreImplTest : public testing::Test {
void SetUp() override {
context_ = std::make_unique<BlobStorageContext>();
- mojo::core::SetDefaultProcessErrorCallback(base::BindRepeating(
+ mojo::SetDefaultProcessErrorHandler(base::BindRepeating(
&BlobURLStoreImplTest::OnBadMessage, base::Unretained(this)));
}
void TearDown() override {
- mojo::core::SetDefaultProcessErrorCallback(
- mojo::core::ProcessErrorCallback());
+ mojo::SetDefaultProcessErrorHandler(base::NullCallback());
}
void OnBadMessage(const std::string& error) {
diff --git a/chromium/storage/browser/blob/mojom/OWNERS b/chromium/storage/browser/blob/mojom/OWNERS
deleted file mode 100644
index 676a080c626..00000000000
--- a/chromium/storage/browser/blob/mojom/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-per-file *.mojom=set noparent
-per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# TEAM: storage-dev@chromium.org
-# COMPONENT: Blink>Storage>FileAPI
diff --git a/chromium/storage/browser/blob/mojom/blob_storage_context.mojom b/chromium/storage/browser/blob/mojom/blob_storage_context.mojom
deleted file mode 100644
index 798a1083bfb..00000000000
--- a/chromium/storage/browser/blob/mojom/blob_storage_context.mojom
+++ /dev/null
@@ -1,88 +0,0 @@
-// 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/storage/browser/blob/scoped_file.cc b/chromium/storage/browser/blob/scoped_file.cc
index bf2571095c9..b1a01a1e23f 100644
--- a/chromium/storage/browser/blob/scoped_file.cc
+++ b/chromium/storage/browser/blob/scoped_file.cc
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/location.h"
+#include "base/logging.h"
#include "base/task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -69,8 +70,7 @@ void ScopedFile::Reset() {
if (scope_out_policy_ == DELETE_ON_SCOPE_OUT) {
file_task_runner_->PostTask(
- FROM_HERE, base::BindOnce(base::IgnoreResult(&base::DeleteFile), path_,
- false /* recursive */));
+ FROM_HERE, base::BindOnce(base::GetDeleteFileCallback(), path_));
}
// Clear all fields.
diff --git a/chromium/storage/browser/blob/shareable_file_reference.cc b/chromium/storage/browser/blob/shareable_file_reference.cc
index 2e0de77611f..c126698482d 100644
--- a/chromium/storage/browser/blob/shareable_file_reference.cc
+++ b/chromium/storage/browser/blob/shareable_file_reference.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "base/task_runner.h"
diff --git a/chromium/storage/browser/blob/write_blob_to_file.h b/chromium/storage/browser/blob/write_blob_to_file.h
index 0f0968bc398..2e1e8af3edc 100644
--- a/chromium/storage/browser/blob/write_blob_to_file.h
+++ b/chromium/storage/browser/blob/write_blob_to_file.h
@@ -8,10 +8,10 @@
#include "base/files/file_path.h"
#include "base/optional.h"
#include "base/time/time.h"
+#include "components/services/storage/public/mojom/blob_storage_context.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_entry.h"
-#include "storage/browser/blob/mojom/blob_storage_context.mojom.h"
namespace storage {