| 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 20 matching lines...) Expand all Loading... |
| 31 #ifndef MockResourceClients_h | 31 #ifndef MockResourceClients_h |
| 32 #define MockResourceClients_h | 32 #define MockResourceClients_h |
| 33 | 33 |
| 34 #include "core/fetch/ImageResourceObserver.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 "core/fetch/ResourceClient.h" |
| 37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class MockResourceClient : public ResourceClient { | 41 class MockResourceClient : public GarbageCollectedFinalized<MockResourceClient>,
public ResourceClient { |
| 42 USING_PRE_FINALIZER(MockResourceClient, dispose); |
| 42 public: | 43 public: |
| 43 explicit MockResourceClient(Resource*); | 44 explicit MockResourceClient(Resource*); |
| 44 ~MockResourceClient() override; | 45 ~MockResourceClient() override; |
| 45 | 46 |
| 46 void notifyFinished(Resource*) override; | 47 void notifyFinished(Resource*) override; |
| 47 String debugName() const override { return "MockResourceClient"; } | 48 String debugName() const override { return "MockResourceClient"; } |
| 48 virtual bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } | 49 virtual bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } |
| 49 | 50 |
| 50 virtual void removeAsClient(); | 51 virtual void removeAsClient(); |
| 52 virtual void dispose(); |
| 53 |
| 54 DECLARE_TRACE(); |
| 51 | 55 |
| 52 protected: | 56 protected: |
| 53 // TODO(Oilpan): properly trace when ResourceClient is on the heap. | 57 Member<Resource> m_resource; |
| 54 UntracedMember<Resource> m_resource; | |
| 55 bool m_notifyFinishedCalled; | 58 bool m_notifyFinishedCalled; |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 class MockImageResourceClient final : public MockResourceClient, public ImageRes
ourceObserver { | 61 class MockImageResourceClient final : public MockResourceClient, public ImageRes
ourceObserver { |
| 59 public: | 62 public: |
| 60 explicit MockImageResourceClient(ImageResource*); | 63 explicit MockImageResourceClient(ImageResource*); |
| 61 ~MockImageResourceClient() override; | 64 ~MockImageResourceClient() override; |
| 62 | 65 |
| 63 void imageNotifyFinished(ImageResource*) override; | 66 void imageNotifyFinished(ImageResource*) override; |
| 64 void imageChanged(ImageResource*, const IntRect*) override; | 67 void imageChanged(ImageResource*, const IntRect*) override; |
| 65 | 68 |
| 66 String debugName() const override { return "MockImageResourceClient"; } | 69 String debugName() const override { return "MockImageResourceClient"; } |
| 67 | 70 |
| 68 bool notifyFinishedCalled() const override; | 71 bool notifyFinishedCalled() const override; |
| 69 | 72 |
| 70 void removeAsClient() override; | 73 void removeAsClient() override; |
| 74 void dispose() override; |
| 71 | 75 |
| 72 int imageChangedCount() const { return m_imageChangedCount; } | 76 int imageChangedCount() const { return m_imageChangedCount; } |
| 73 | 77 |
| 74 private: | 78 private: |
| 75 int m_imageChangedCount; | 79 int m_imageChangedCount; |
| 76 int m_imageNotifyFinishedCount; | 80 int m_imageNotifyFinishedCount; |
| 77 }; | 81 }; |
| 78 | 82 |
| 79 } // namespace blink | 83 } // namespace blink |
| 80 | 84 |
| 81 #endif // MockResourceClients_h | 85 #endif // MockResourceClients_h |
| OLD | NEW |