Commit 5ae1e4ce authored by Thiabaud Engelbrecht's avatar Thiabaud Engelbrecht Committed by Chromium LUCI CQ

[parkable_image] Allow DiskDataAllocator::Read to be called from any

thread

Bug: 1169394
Change-Id: Ic6808b5275d954eb0cfef920c2e372e20e0f4f93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644456Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Commit-Queue: Thiabaud Engelbrecht <thiabaud@google.com>
Cr-Commit-Position: refs/heads/master@{#846141}
parent 029371af
......@@ -137,8 +137,6 @@ std::unique_ptr<DiskDataMetadata> DiskDataAllocator::Write(const void* data,
}
void DiskDataAllocator::Read(const DiskDataMetadata& metadata, void* data) {
DCHECK(IsMainThread());
// Doesn't need locking as files support concurrent access, and we don't
// update metadata.
char* data_char = reinterpret_cast<char*>(data);
......
......@@ -28,8 +28,7 @@ class DiskDataMetadata;
// available.
//
// Threading:
// - Reads must be done from the main thread
// - Writes can be done from any thread.
// - Reads and writes can be done from any thread.
// - public methods are thread-safe, and unless otherwise noted, can be called
// from any thread.
class PLATFORM_EXPORT DiskDataAllocator : public mojom::blink::DiskAllocator {
......@@ -47,14 +46,16 @@ class PLATFORM_EXPORT DiskDataAllocator : public mojom::blink::DiskAllocator {
std::unique_ptr<DiskDataMetadata> Write(const void* data, size_t size);
// Reads data. A read failure is fatal.
// Must be called from the main thread.
// Caller must make sure that this is not called at the same time as
// |Discard()|.
// Can be called at any time before |Discard()| destroys |metadata|.
//
// |data| must point to an area large enough to fit a |metadata.size|-ed
// array. Note that this performs a blocking disk read.
void Read(const DiskDataMetadata& metadata, void* data);
// Discards existing data pointed at by |metadata|.
// Discards existing data pointed at by |metadata|. Caller must make sure this
// is not called while the same file is being read.
void Discard(std::unique_ptr<DiskDataMetadata> metadata);
~DiskDataAllocator() override;
......
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