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 #ifndef DataConsumerHandleTestUtil_h | 5 #ifndef DataConsumerHandleTestUtil_h |
6 #define DataConsumerHandleTestUtil_h | 6 #define DataConsumerHandleTestUtil_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "core/testing/NullExecutionContext.h" | 10 #include "core/testing/NullExecutionContext.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 RefPtr<Context> context_; | 180 RefPtr<Context> context_; |
181 std::unique_ptr<Thread> reading_thread_; | 181 std::unique_ptr<Thread> reading_thread_; |
182 std::unique_ptr<Thread> updating_thread_; | 182 std::unique_ptr<Thread> updating_thread_; |
183 }; | 183 }; |
184 | 184 |
185 class ReaderImpl final : public WebDataConsumerHandle::Reader { | 185 class ReaderImpl final : public WebDataConsumerHandle::Reader { |
186 USING_FAST_MALLOC(ReaderImpl); | 186 USING_FAST_MALLOC(ReaderImpl); |
187 | 187 |
188 public: | 188 public: |
189 ReaderImpl(const String& name, PassRefPtr<Context> context) | 189 ReaderImpl(const String& name, PassRefPtr<Context> context) |
190 : name_(name.IsolatedCopy()), context_(context) { | 190 : name_(name.IsolatedCopy()), context_(std::move(context)) { |
191 context_->RecordAttach(name_.IsolatedCopy()); | 191 context_->RecordAttach(name_.IsolatedCopy()); |
192 } | 192 } |
193 ~ReaderImpl() override { context_->RecordDetach(name_.IsolatedCopy()); } | 193 ~ReaderImpl() override { context_->RecordDetach(name_.IsolatedCopy()); } |
194 | 194 |
195 using Result = WebDataConsumerHandle::Result; | 195 using Result = WebDataConsumerHandle::Result; |
196 using Flags = WebDataConsumerHandle::Flags; | 196 using Flags = WebDataConsumerHandle::Flags; |
197 Result BeginRead(const void**, Flags, size_t*) override { | 197 Result BeginRead(const void**, Flags, size_t*) override { |
198 return WebDataConsumerHandle::kShouldWait; | 198 return WebDataConsumerHandle::kShouldWait; |
199 } | 199 } |
200 Result EndRead(size_t) override { | 200 Result EndRead(size_t) override { |
(...skipping 10 matching lines...) Expand all Loading... |
211 public: | 211 public: |
212 static std::unique_ptr<WebDataConsumerHandle> Create( | 212 static std::unique_ptr<WebDataConsumerHandle> Create( |
213 const String& name, | 213 const String& name, |
214 PassRefPtr<Context> context) { | 214 PassRefPtr<Context> context) { |
215 return WTF::WrapUnique( | 215 return WTF::WrapUnique( |
216 new DataConsumerHandle(name, std::move(context))); | 216 new DataConsumerHandle(name, std::move(context))); |
217 } | 217 } |
218 | 218 |
219 private: | 219 private: |
220 DataConsumerHandle(const String& name, PassRefPtr<Context> context) | 220 DataConsumerHandle(const String& name, PassRefPtr<Context> context) |
221 : name_(name.IsolatedCopy()), context_(context) {} | 221 : name_(name.IsolatedCopy()), context_(std::move(context)) {} |
222 | 222 |
223 std::unique_ptr<Reader> ObtainReader(Client*) { | 223 std::unique_ptr<Reader> ObtainReader(Client*) { |
224 return WTF::MakeUnique<ReaderImpl>(name_, context_); | 224 return WTF::MakeUnique<ReaderImpl>(name_, context_); |
225 } | 225 } |
226 const char* DebugName() const override { | 226 const char* DebugName() const override { |
227 return "ThreadingTestBase::DataConsumerHandle"; | 227 return "ThreadingTestBase::DataConsumerHandle"; |
228 } | 228 } |
229 | 229 |
230 const String name_; | 230 const String name_; |
231 RefPtr<Context> context_; | 231 RefPtr<Context> context_; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 std::unique_ptr<T> handle_reader_; | 516 std::unique_ptr<T> handle_reader_; |
517 }; | 517 }; |
518 | 518 |
519 static std::unique_ptr<WebDataConsumerHandle> | 519 static std::unique_ptr<WebDataConsumerHandle> |
520 CreateWaitingDataConsumerHandle(); | 520 CreateWaitingDataConsumerHandle(); |
521 }; | 521 }; |
522 | 522 |
523 } // namespace blink | 523 } // namespace blink |
524 | 524 |
525 #endif // DataConsumerHandleTestUtil_h | 525 #endif // DataConsumerHandleTestUtil_h |
OLD | NEW |