OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef MockImageResourceClient_h | 31 #ifndef MockResourceClients_h |
32 #define MockImageResourceClient_h | 32 #define MockResourceClients_h |
33 | 33 |
34 #include "core/fetch/ImageResourceClient.h" | 34 #include "core/fetch/ImageResourceObserver.h" |
35 #include "core/fetch/Resource.h" | 35 #include "core/fetch/Resource.h" |
| 36 #include "core/fetch/ResourceClient.h" |
36 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 class MockImageResourceClient final : public ImageResourceClient { | 41 class MockResourceClient : public ResourceClient { |
41 public: | 42 public: |
42 explicit MockImageResourceClient(const PassRefPtrWillBeRawPtr<Resource>); | 43 explicit MockResourceClient(const PassRefPtrWillBeRawPtr<Resource>); |
| 44 ~MockResourceClient() override; |
| 45 |
| 46 void notifyFinished(Resource*) override; |
| 47 String debugName() const override { return "MockResourceClient"; } |
| 48 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } |
| 49 |
| 50 virtual void removeAsClient(); |
| 51 |
| 52 protected: |
| 53 // TODO(Oilpan): properly trace when ResourceClient is on the heap. |
| 54 RawPtrWillBeUntracedMember<Resource> m_resource; |
| 55 bool m_notifyFinishedCalled; |
| 56 }; |
| 57 |
| 58 class MockImageResourceClient final : public MockResourceClient, public ImageRes
ourceObserver { |
| 59 public: |
| 60 explicit MockImageResourceClient(const PassRefPtrWillBeRawPtr<ImageResource>
); |
43 ~MockImageResourceClient() override; | 61 ~MockImageResourceClient() override; |
44 | 62 |
45 void imageChanged(ImageResource*, const IntRect*) override | 63 void imageChanged(ImageResource*, const IntRect*) override; |
46 { | |
47 m_imageChangedCount++; | |
48 } | |
49 | 64 |
50 void notifyFinished(Resource*) override; | |
51 String debugName() const override { return "MockImageResourceClient"; } | 65 String debugName() const override { return "MockImageResourceClient"; } |
52 | 66 |
| 67 void removeAsClient() override; |
| 68 |
53 int imageChangedCount() const { return m_imageChangedCount; } | 69 int imageChangedCount() const { return m_imageChangedCount; } |
54 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } | |
55 | |
56 void removeAsClient(); | |
57 | 70 |
58 private: | 71 private: |
59 // TODO(Oilpan): properly trace when ImageResourceClient is on the heap. | |
60 RawPtrWillBeUntracedMember<Resource> m_resource; | |
61 int m_imageChangedCount; | 72 int m_imageChangedCount; |
62 bool m_notifyFinishedCalled; | |
63 }; | 73 }; |
64 | 74 |
65 } // namespace blink | 75 } // namespace blink |
66 | 76 |
67 #endif // MockImageResourceClient_h | 77 #endif // MockResourceClients_h |
OLD | NEW |