| 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 #include "platform/testing/TestingPlatformSupport.h" |   31 #include "platform/testing/TestingPlatformSupport.h" | 
|   32  |   32  | 
|   33 #if !OS(ANDROID) |   33 #if !OS(ANDROID) | 
|   34 #include "device/battery/battery_monitor_impl.h" |   34 #include "device/battery/battery_monitor_impl.h" | 
|   35 #endif |   35 #endif | 
|   36  |   36  | 
|   37 #include <cstring> |  | 
|   38  |  | 
|   39 namespace blink { |   37 namespace blink { | 
|   40  |   38  | 
|   41 TestingDiscardableMemory::TestingDiscardableMemory(size_t size) : m_data(size), 
     m_isLocked(true) |  | 
|   42 { |  | 
|   43 } |  | 
|   44  |  | 
|   45 TestingDiscardableMemory::~TestingDiscardableMemory() |  | 
|   46 { |  | 
|   47 } |  | 
|   48  |  | 
|   49 bool TestingDiscardableMemory::lock() |  | 
|   50 { |  | 
|   51     ASSERT(!m_isLocked); |  | 
|   52     m_isLocked = true; |  | 
|   53     return false; |  | 
|   54 } |  | 
|   55  |  | 
|   56 void* TestingDiscardableMemory::data() |  | 
|   57 { |  | 
|   58     ASSERT(m_isLocked); |  | 
|   59     return m_data.data(); |  | 
|   60 } |  | 
|   61  |  | 
|   62 void TestingDiscardableMemory::unlock() |  | 
|   63 { |  | 
|   64     ASSERT(m_isLocked); |  | 
|   65     m_isLocked = false; |  | 
|   66     // Force eviction to catch clients not correctly checking the return value o
     f lock(). |  | 
|   67     memset(m_data.data(), 0, m_data.size()); |  | 
|   68 } |  | 
|   69  |  | 
|   70 WebMemoryAllocatorDump* TestingDiscardableMemory::createMemoryAllocatorDump(cons
     t WebString& name, WebProcessMemoryDump* dump) const |  | 
|   71 { |  | 
|   72     ASSERT_NOT_REACHED(); |  | 
|   73     return nullptr; |  | 
|   74 } |  | 
|   75  |  | 
|   76 TestingPlatformSupport::TestingPlatformSupport() |   39 TestingPlatformSupport::TestingPlatformSupport() | 
|   77     : TestingPlatformSupport(TestingPlatformSupport::Config()) |   40     : TestingPlatformSupport(TestingPlatformSupport::Config()) | 
|   78 { |   41 { | 
|   79 } |   42 } | 
|   80  |   43  | 
|   81 TestingPlatformSupport::TestingPlatformSupport(const Config& config) |   44 TestingPlatformSupport::TestingPlatformSupport(const Config& config) | 
|   82     : m_config(config) |   45     : m_config(config) | 
|   83     , m_oldPlatform(Platform::current()) |   46     , m_oldPlatform(Platform::current()) | 
|   84 { |   47 { | 
|   85     ASSERT(m_oldPlatform); |   48     ASSERT(m_oldPlatform); | 
|   86     Platform::setCurrentPlatformForTesting(this); |   49     Platform::setCurrentPlatformForTesting(this); | 
|   87 } |   50 } | 
|   88  |   51  | 
|   89 TestingPlatformSupport::~TestingPlatformSupport() |   52 TestingPlatformSupport::~TestingPlatformSupport() | 
|   90 { |   53 { | 
|   91     Platform::setCurrentPlatformForTesting(m_oldPlatform); |   54     Platform::setCurrentPlatformForTesting(m_oldPlatform); | 
|   92 } |   55 } | 
|   93  |   56  | 
|   94 WebDiscardableMemory* TestingPlatformSupport::allocateAndLockDiscardableMemory(s
     ize_t bytes) |  | 
|   95 { |  | 
|   96     return !m_config.hasDiscardableMemorySupport ? 0 : new TestingDiscardableMem
     ory(bytes); |  | 
|   97 } |  | 
|   98  |  | 
|   99 WebString TestingPlatformSupport::defaultLocale() |   57 WebString TestingPlatformSupport::defaultLocale() | 
|  100 { |   58 { | 
|  101     return WebString::fromUTF8("en-US"); |   59     return WebString::fromUTF8("en-US"); | 
|  102 } |   60 } | 
|  103  |   61  | 
|  104 WebCompositorSupport* TestingPlatformSupport::compositorSupport() |   62 WebCompositorSupport* TestingPlatformSupport::compositorSupport() | 
|  105 { |   63 { | 
|  106     return m_config.compositorSupport; |   64     return m_config.compositorSupport; | 
|  107 } |   65 } | 
|  108  |   66  | 
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  242 { |  200 { | 
|  243     return m_mockWebThread.get(); |  201     return m_mockWebThread.get(); | 
|  244 } |  202 } | 
|  245  |  203  | 
|  246 TestingPlatformMockScheduler* TestingPlatformSupportWithMockScheduler::mockWebSc
     heduler() |  204 TestingPlatformMockScheduler* TestingPlatformSupportWithMockScheduler::mockWebSc
     heduler() | 
|  247 { |  205 { | 
|  248     return m_mockWebThread->mockWebScheduler(); |  206     return m_mockWebThread->mockWebScheduler(); | 
|  249 } |  207 } | 
|  250  |  208  | 
|  251 } // namespace blink |  209 } // namespace blink | 
| OLD | NEW |