| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 16 matching lines...) Expand all Loading... |
| 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 TestingPlatformSupport_h | 31 #ifndef TestingPlatformSupport_h |
| 32 #define TestingPlatformSupport_h | 32 #define TestingPlatformSupport_h |
| 33 | 33 |
| 34 #include "platform/PlatformExport.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 36 #include "public/platform/WebCompositorSupport.h" | 36 #include "public/platform/WebCompositorSupport.h" |
| 37 #include "public/platform/WebDiscardableMemory.h" | |
| 38 #include "public/platform/WebScheduler.h" | 37 #include "public/platform/WebScheduler.h" |
| 39 #include "public/platform/WebThread.h" | 38 #include "public/platform/WebThread.h" |
| 40 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 class TestingPlatformMockWebTaskRunner; | 43 class TestingPlatformMockWebTaskRunner; |
| 45 class TestingPlatformMockWebThread; | 44 class TestingPlatformMockWebThread; |
| 46 class WebCompositorSupport; | 45 class WebCompositorSupport; |
| 47 class WebThread; | 46 class WebThread; |
| 48 | 47 |
| 49 class TestingDiscardableMemory : public WebDiscardableMemory { | |
| 50 public: | |
| 51 explicit TestingDiscardableMemory(size_t); | |
| 52 ~TestingDiscardableMemory() override; | |
| 53 | |
| 54 // WebDiscardableMemory: | |
| 55 bool lock() override; | |
| 56 void* data() override; | |
| 57 void unlock() override; | |
| 58 WebMemoryAllocatorDump* createMemoryAllocatorDump(const WebString& name, Web
ProcessMemoryDump*) const override; | |
| 59 | |
| 60 private: | |
| 61 Vector<char> m_data; | |
| 62 bool m_isLocked; | |
| 63 }; | |
| 64 | |
| 65 class TestingCompositorSupport : public WebCompositorSupport { | 48 class TestingCompositorSupport : public WebCompositorSupport { |
| 66 }; | 49 }; |
| 67 | 50 |
| 68 class TestingPlatformMockScheduler : public WebScheduler { | 51 class TestingPlatformMockScheduler : public WebScheduler { |
| 69 WTF_MAKE_NONCOPYABLE(TestingPlatformMockScheduler); | 52 WTF_MAKE_NONCOPYABLE(TestingPlatformMockScheduler); |
| 70 public: | 53 public: |
| 71 TestingPlatformMockScheduler(); | 54 TestingPlatformMockScheduler(); |
| 72 ~TestingPlatformMockScheduler() override; | 55 ~TestingPlatformMockScheduler() override; |
| 73 | 56 |
| 74 void runSingleTask(); | 57 void runSingleTask(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 | 75 |
| 93 private: | 76 private: |
| 94 WTF::Deque<OwnPtr<WebTaskRunner::Task>> m_tasks; | 77 WTF::Deque<OwnPtr<WebTaskRunner::Task>> m_tasks; |
| 95 OwnPtr<TestingPlatformMockWebTaskRunner> m_mockWebTaskRunner; | 78 OwnPtr<TestingPlatformMockWebTaskRunner> m_mockWebTaskRunner; |
| 96 }; | 79 }; |
| 97 | 80 |
| 98 class TestingPlatformSupport : public Platform { | 81 class TestingPlatformSupport : public Platform { |
| 99 WTF_MAKE_NONCOPYABLE(TestingPlatformSupport); | 82 WTF_MAKE_NONCOPYABLE(TestingPlatformSupport); |
| 100 public: | 83 public: |
| 101 struct Config { | 84 struct Config { |
| 102 Config() | 85 WebCompositorSupport* compositorSupport = nullptr; |
| 103 : hasDiscardableMemorySupport(false) | |
| 104 , compositorSupport(nullptr) { } | |
| 105 | |
| 106 bool hasDiscardableMemorySupport; | |
| 107 WebCompositorSupport* compositorSupport; | |
| 108 }; | 86 }; |
| 109 | 87 |
| 110 TestingPlatformSupport(); | 88 TestingPlatformSupport(); |
| 111 explicit TestingPlatformSupport(const Config&); | 89 explicit TestingPlatformSupport(const Config&); |
| 112 | 90 |
| 113 ~TestingPlatformSupport() override; | 91 ~TestingPlatformSupport() override; |
| 114 | 92 |
| 115 // Platform: | 93 // Platform: |
| 116 WebDiscardableMemory* allocateAndLockDiscardableMemory(size_t bytes) overrid
e; | |
| 117 WebString defaultLocale() override; | 94 WebString defaultLocale() override; |
| 118 WebCompositorSupport* compositorSupport() override; | 95 WebCompositorSupport* compositorSupport() override; |
| 119 WebThread* currentThread() override; | 96 WebThread* currentThread() override; |
| 120 WebUnitTestSupport* unitTestSupport() override; | 97 WebUnitTestSupport* unitTestSupport() override; |
| 121 void registerMemoryDumpProvider(blink::WebMemoryDumpProvider*, const char* n
ame) override {} | 98 void registerMemoryDumpProvider(blink::WebMemoryDumpProvider*, const char* n
ame) override {} |
| 122 void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider*) override {} | 99 void unregisterMemoryDumpProvider(blink::WebMemoryDumpProvider*) override {} |
| 123 void connectToRemoteService(const char* name, mojo::ScopedMessagePipeHandle)
override; | 100 void connectToRemoteService(const char* name, mojo::ScopedMessagePipeHandle)
override; |
| 124 | 101 |
| 125 protected: | 102 protected: |
| 126 const Config m_config; | 103 const Config m_config; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 WebThread* currentThread() override; | 115 WebThread* currentThread() override; |
| 139 TestingPlatformMockScheduler* mockWebScheduler(); | 116 TestingPlatformMockScheduler* mockWebScheduler(); |
| 140 | 117 |
| 141 protected: | 118 protected: |
| 142 OwnPtr<TestingPlatformMockWebThread> m_mockWebThread; | 119 OwnPtr<TestingPlatformMockWebThread> m_mockWebThread; |
| 143 }; | 120 }; |
| 144 | 121 |
| 145 } // namespace blink | 122 } // namespace blink |
| 146 | 123 |
| 147 #endif // TestingPlatformSupport_h | 124 #endif // TestingPlatformSupport_h |
| OLD | NEW |