Commit 035a1008 authored by Thiabaud Engelbrecht's avatar Thiabaud Engelbrecht Committed by Commit Bot

[blink] Add DCHECKs to enforce immutability of image after all data

 received.

This is already obeyed in the code, but not enforced. Add DCHECKs to
 make it explicit.

Bug: 1142834
Change-Id: I08c6ec08563c662fb5f98be6c965721655c87fbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2535611
Commit-Queue: Thiabaud Engelbrecht <thiabaud@google.com>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827781}
parent 0863ab95
...@@ -276,12 +276,6 @@ TEST_F(BitmapImageTest, isAllDataReceived) { ...@@ -276,12 +276,6 @@ TEST_F(BitmapImageTest, isAllDataReceived) {
image->SetData(image_data, true); image->SetData(image_data, true);
EXPECT_TRUE(image->IsAllDataReceived()); EXPECT_TRUE(image->IsAllDataReceived());
image->SetData(SharedBuffer::Create("data", sizeof("data")), false);
EXPECT_FALSE(image->IsAllDataReceived());
image->SetData(image_data, true);
EXPECT_TRUE(image->IsAllDataReceived());
} }
TEST_F(BitmapImageTest, noColorProfile) { TEST_F(BitmapImageTest, noColorProfile) {
......
...@@ -266,6 +266,8 @@ void DeferredImageDecoder::SetData(scoped_refptr<SharedBuffer> data, ...@@ -266,6 +266,8 @@ void DeferredImageDecoder::SetData(scoped_refptr<SharedBuffer> data,
void DeferredImageDecoder::SetDataInternal(scoped_refptr<SharedBuffer> data, void DeferredImageDecoder::SetDataInternal(scoped_refptr<SharedBuffer> data,
bool all_data_received, bool all_data_received,
bool push_data_to_decoder) { bool push_data_to_decoder) {
// Once all the data has been received, the image should not change.
DCHECK(!all_data_received_);
if (metadata_decoder_) { if (metadata_decoder_) {
all_data_received_ = all_data_received; all_data_received_ = all_data_received;
if (push_data_to_decoder) if (push_data_to_decoder)
......
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