Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 #include "platform/SharedBuffer.h" 28 #include "platform/SharedBuffer.h"
29 #include "platform/ThreadSafeFunctional.h" 29 #include "platform/ThreadSafeFunctional.h"
30 #include "platform/graphics/ImageDecodingStore.h" 30 #include "platform/graphics/ImageDecodingStore.h"
31 #include "platform/graphics/test/MockImageDecoder.h" 31 #include "platform/graphics/test/MockImageDecoder.h"
32 #include "platform/image-decoders/SegmentReader.h" 32 #include "platform/image-decoders/SegmentReader.h"
33 #include "public/platform/Platform.h" 33 #include "public/platform/Platform.h"
34 #include "public/platform/WebTaskRunner.h" 34 #include "public/platform/WebTaskRunner.h"
35 #include "public/platform/WebThread.h" 35 #include "public/platform/WebThread.h"
36 #include "public/platform/WebTraceLocation.h" 36 #include "public/platform/WebTraceLocation.h"
37 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 #include "wtf/PtrUtil.h"
39 #include <memory>
38 40
39 namespace blink { 41 namespace blink {
40 42
41 namespace { 43 namespace {
42 44
43 // Helper methods to generate standard sizes. 45 // Helper methods to generate standard sizes.
44 SkISize fullSize() { return SkISize::Make(100, 100); } 46 SkISize fullSize() { return SkISize::Make(100, 100); }
45 47
46 SkImageInfo imageInfo() 48 SkImageInfo imageInfo()
47 { 49 {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 setFrameStatus(ImageFrame::FramePartial); 179 setFrameStatus(ImageFrame::FramePartial);
178 180
179 char buffer[100 * 100 * 4]; 181 char buffer[100 * 100 * 4];
180 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu ffer, 100 * 4); 182 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu ffer, 100 * 4);
181 EXPECT_EQ(1, m_decodeRequestCount); 183 EXPECT_EQ(1, m_decodeRequestCount);
182 EXPECT_EQ(0, m_decodersDestroyed); 184 EXPECT_EQ(0, m_decodersDestroyed);
183 185
184 // LocalFrame can now be decoded completely. 186 // LocalFrame can now be decoded completely.
185 setFrameStatus(ImageFrame::FrameComplete); 187 setFrameStatus(ImageFrame::FrameComplete);
186 addNewData(); 188 addNewData();
187 OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("Decod eThread")); 189 std::unique_ptr<WebThread> thread = wrapUnique(Platform::current()->createTh read("DecodeThread"));
188 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decode ThreadMain, m_generator, m_segmentReader)); 190 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decode ThreadMain, m_generator, m_segmentReader));
189 thread.reset(); 191 thread.reset();
190 EXPECT_EQ(2, m_decodeRequestCount); 192 EXPECT_EQ(2, m_decodeRequestCount);
191 EXPECT_EQ(1, m_decodersDestroyed); 193 EXPECT_EQ(1, m_decodersDestroyed);
192 194
193 // Decoder created again. 195 // Decoder created again.
194 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu ffer, 100 * 4); 196 m_generator->decodeAndScale(m_segmentReader.get(), false, 0, imageInfo(), bu ffer, 100 * 4);
195 EXPECT_EQ(3, m_decodeRequestCount); 197 EXPECT_EQ(3, m_decodeRequestCount);
196 198
197 addNewData(); 199 addNewData();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // Decoding the last frame of a multi-frame images should trigger clearing 247 // Decoding the last frame of a multi-frame images should trigger clearing
246 // all the frame data, but not destroying the decoder. See comments in 248 // all the frame data, but not destroying the decoder. See comments in
247 // ImageFrameGenerator::tryToResumeDecode(). 249 // ImageFrameGenerator::tryToResumeDecode().
248 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(), buf fer, 100 * 4); 250 m_generator->decodeAndScale(m_segmentReader.get(), true, 2, imageInfo(), buf fer, 100 * 4);
249 EXPECT_EQ(3, m_decodeRequestCount); 251 EXPECT_EQ(3, m_decodeRequestCount);
250 EXPECT_EQ(0, m_decodersDestroyed); 252 EXPECT_EQ(0, m_decodersDestroyed);
251 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame); 253 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame);
252 } 254 }
253 255
254 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698