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

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

Issue 2104913002: Rename threadSafeBind() to crossThreadBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_CTCPointer
Patch Set: Rebase Created 4 years, 5 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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "platform/graphics/ImageFrameGenerator.h" 26 #include "platform/graphics/ImageFrameGenerator.h"
27 27
28 #include "platform/CrossThreadFunctional.h"
28 #include "platform/SharedBuffer.h" 29 #include "platform/SharedBuffer.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" 38 #include "wtf/PtrUtil.h"
39 #include <memory> 39 #include <memory>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 char buffer[100 * 100 * 4]; 181 char buffer[100 * 100 * 4];
182 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);
183 EXPECT_EQ(1, m_decodeRequestCount); 183 EXPECT_EQ(1, m_decodeRequestCount);
184 EXPECT_EQ(0, m_decodersDestroyed); 184 EXPECT_EQ(0, m_decodersDestroyed);
185 185
186 // LocalFrame can now be decoded completely. 186 // LocalFrame can now be decoded completely.
187 setFrameStatus(ImageFrame::FrameComplete); 187 setFrameStatus(ImageFrame::FrameComplete);
188 addNewData(); 188 addNewData();
189 std::unique_ptr<WebThread> thread = wrapUnique(Platform::current()->createTh read("DecodeThread")); 189 std::unique_ptr<WebThread> thread = wrapUnique(Platform::current()->createTh read("DecodeThread"));
190 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decode ThreadMain, m_generator, m_segmentReader)); 190 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&decod eThreadMain, m_generator, m_segmentReader));
191 thread.reset(); 191 thread.reset();
192 EXPECT_EQ(2, m_decodeRequestCount); 192 EXPECT_EQ(2, m_decodeRequestCount);
193 EXPECT_EQ(1, m_decodersDestroyed); 193 EXPECT_EQ(1, m_decodersDestroyed);
194 194
195 // Decoder created again. 195 // Decoder created again.
196 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);
197 EXPECT_EQ(3, m_decodeRequestCount); 197 EXPECT_EQ(3, m_decodeRequestCount);
198 198
199 addNewData(); 199 addNewData();
200 200
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // 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
248 // 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
249 // ImageFrameGenerator::tryToResumeDecode(). 249 // ImageFrameGenerator::tryToResumeDecode().
250 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);
251 EXPECT_EQ(3, m_decodeRequestCount); 251 EXPECT_EQ(3, m_decodeRequestCount);
252 EXPECT_EQ(0, m_decodersDestroyed); 252 EXPECT_EQ(0, m_decodersDestroyed);
253 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame); 253 EXPECT_EQ(kNotFound, m_requestedClearExceptFrame);
254 } 254 }
255 255
256 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698