| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/DataConsumerHandleTestUtil.h" | 6 #include "modules/fetch/DataConsumerHandleTestUtil.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 m_executionContext = nullptr; | 46 m_executionContext = nullptr; |
| 47 m_scriptState = nullptr; | 47 m_scriptState = nullptr; |
| 48 m_thread->shutdown(); | 48 m_thread->shutdown(); |
| 49 if (m_isolateHolder) { | 49 if (m_isolateHolder) { |
| 50 isolate()->Exit(); | 50 isolate()->Exit(); |
| 51 m_isolateHolder = nullptr; | 51 m_isolateHolder = nullptr; |
| 52 } | 52 } |
| 53 m_waitableEvent->signal(); | 53 m_waitableEvent->signal(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class DataConsumerHandleTestUtil::ReplayingHandle::ReaderImpl final : public Rea
der { |
| 57 public: |
| 58 ReaderImpl(PassRefPtr<Context> context, Client* client) |
| 59 : m_context(context) |
| 60 { |
| 61 m_context->attachReader(client); |
| 62 } |
| 63 ~ReaderImpl() |
| 64 { |
| 65 m_context->detachReader(); |
| 66 } |
| 67 |
| 68 Result read(void* buffer, size_t size, Flags flags, size_t* readSize) overri
de |
| 69 { |
| 70 const void* src = nullptr; |
| 71 Result result = beginRead(&src, flags, readSize); |
| 72 if (result != Ok) |
| 73 return result; |
| 74 *readSize = std::min(*readSize, size); |
| 75 memcpy(buffer, src, *readSize); |
| 76 return endRead(*readSize); |
| 77 } |
| 78 Result beginRead(const void** buffer, Flags flags, size_t* available) overri
de |
| 79 { |
| 80 return m_context->beginRead(buffer, flags, available); |
| 81 } |
| 82 Result endRead(size_t readSize) override |
| 83 { |
| 84 return m_context->endRead(readSize); |
| 85 } |
| 86 |
| 87 private: |
| 88 RefPtr<Context> m_context; |
| 89 }; |
| 90 |
| 91 DataConsumerHandleTestUtil::ReplayingHandle::ReplayingHandle() |
| 92 : m_context(Context::create()) |
| 93 { |
| 94 } |
| 95 |
| 96 DataConsumerHandleTestUtil::ReplayingHandle::~ReplayingHandle() |
| 97 { |
| 98 m_context->detachHandle(); |
| 99 } |
| 100 |
| 101 WebDataConsumerHandle::Reader* DataConsumerHandleTestUtil::ReplayingHandle::obta
inReaderInternal(Client* client) |
| 102 { |
| 103 return new ReaderImpl(m_context, client); |
| 104 } |
| 105 |
| 106 void DataConsumerHandleTestUtil::ReplayingHandle::add(const Command& command) |
| 107 { |
| 108 m_context->add(command); |
| 109 } |
| 110 |
| 56 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |