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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/test/MockImageDecoder.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 #ifndef MockImageDecoder_h 26 #ifndef MockImageDecoder_h
27 27
28 #include "platform/image-decoders/ImageDecoder.h" 28 #include "platform/image-decoders/ImageDecoder.h"
29 #include "wtf/PtrUtil.h" 29 #include "wtf/PassOwnPtr.h"
30 #include <memory>
31 30
32 namespace blink { 31 namespace blink {
33 32
34 class MockImageDecoderClient { 33 class MockImageDecoderClient {
35 public: 34 public:
36 MockImageDecoderClient() 35 MockImageDecoderClient()
37 : m_firstFrameForcedToBeEmpty(false) 36 : m_firstFrameForcedToBeEmpty(false)
38 { 37 {
39 } 38 }
40 39
(...skipping 18 matching lines...) Expand all
59 }; 58 };
60 59
61 bool firstFrameForcedToBeEmpty() const { return m_firstFrameForcedToBeEmpty; } 60 bool firstFrameForcedToBeEmpty() const { return m_firstFrameForcedToBeEmpty; }
62 61
63 private: 62 private:
64 bool m_firstFrameForcedToBeEmpty; 63 bool m_firstFrameForcedToBeEmpty;
65 }; 64 };
66 65
67 class MockImageDecoder : public ImageDecoder { 66 class MockImageDecoder : public ImageDecoder {
68 public: 67 public:
69 static std::unique_ptr<MockImageDecoder> create(MockImageDecoderClient* clie nt) { return wrapUnique(new MockImageDecoder(client)); } 68 static PassOwnPtr<MockImageDecoder> create(MockImageDecoderClient* client) { return adoptPtr(new MockImageDecoder(client)); }
70 69
71 MockImageDecoder(MockImageDecoderClient* client) 70 MockImageDecoder(MockImageDecoderClient* client)
72 : ImageDecoder(AlphaPremultiplied, GammaAndColorProfileApplied, noDecode dImageByteLimit) 71 : ImageDecoder(AlphaPremultiplied, GammaAndColorProfileApplied, noDecode dImageByteLimit)
73 , m_client(client) 72 , m_client(client)
74 { } 73 { }
75 74
76 ~MockImageDecoder() 75 ~MockImageDecoder()
77 { 76 {
78 m_client->decoderBeingDestroyed(); 77 m_client->decoderBeingDestroyed();
79 } 78 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 130 {
132 m_frameBufferCache[index].setSize(size().width(), size().height()); 131 m_frameBufferCache[index].setSize(size().width(), size().height());
133 m_frameBufferCache[index].setHasAlpha(false); 132 m_frameBufferCache[index].setHasAlpha(false);
134 } 133 }
135 134
136 MockImageDecoderClient* m_client; 135 MockImageDecoderClient* m_client;
137 }; 136 };
138 137
139 class MockImageDecoderFactory : public ImageDecoderFactory { 138 class MockImageDecoderFactory : public ImageDecoderFactory {
140 public: 139 public:
141 static std::unique_ptr<MockImageDecoderFactory> create(MockImageDecoderClien t* client, const SkISize& decodedSize) 140 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl ient, const SkISize& decodedSize)
142 { 141 {
143 return wrapUnique(new MockImageDecoderFactory(client, IntSize(decodedSiz e.width(), decodedSize.height()))); 142 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize. width(), decodedSize.height())));
144 } 143 }
145 144
146 static std::unique_ptr<MockImageDecoderFactory> create(MockImageDecoderClien t* client, const IntSize& decodedSize) 145 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl ient, const IntSize& decodedSize)
147 { 146 {
148 return wrapUnique(new MockImageDecoderFactory(client, decodedSize)); 147 return adoptPtr(new MockImageDecoderFactory(client, decodedSize));
149 } 148 }
150 149
151 std::unique_ptr<ImageDecoder> create() override 150 PassOwnPtr<ImageDecoder> create() override
152 { 151 {
153 std::unique_ptr<MockImageDecoder> decoder = MockImageDecoder::create(m_c lient); 152 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client);
154 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); 153 decoder->setSize(m_decodedSize.width(), m_decodedSize.height());
155 return std::move(decoder); 154 return std::move(decoder);
156 } 155 }
157 156
158 private: 157 private:
159 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod edSize) 158 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod edSize)
160 : m_client(client) 159 : m_client(client)
161 , m_decodedSize(decodedSize) 160 , m_decodedSize(decodedSize)
162 { 161 {
163 } 162 }
164 163
165 MockImageDecoderClient* m_client; 164 MockImageDecoderClient* m_client;
166 IntSize m_decodedSize; 165 IntSize m_decodedSize;
167 }; 166 };
168 167
169 } // namespace blink 168 } // namespace blink
170 169
171 #endif // MockImageDecoder_h 170 #endif // MockImageDecoder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698