| 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 "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/testing/NullExecutionContext.h" | 9 #include "core/testing/NullExecutionContext.h" |
| 10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include <gmock/gmock.h> | 30 #include <gmock/gmock.h> |
| 31 #include <gtest/gtest.h> | 31 #include <gtest/gtest.h> |
| 32 #include <v8.h> | 32 #include <v8.h> |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class DataConsumerHandleTestUtil { | 36 class DataConsumerHandleTestUtil { |
| 37 STATIC_ONLY(DataConsumerHandleTestUtil); | 37 STATIC_ONLY(DataConsumerHandleTestUtil); |
| 38 public: | 38 public: |
| 39 class NoopClient final : public WebDataConsumerHandle::Client { | 39 class NoopClient final : public WebDataConsumerHandle::Client { |
| 40 DISALLOW_ALLOCATION(); | 40 DISALLOW_NEW(); |
| 41 public: | 41 public: |
| 42 void didGetReadable() override { } | 42 void didGetReadable() override { } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // Thread has a WebThreadSupportingGC. It initializes / shutdowns | 45 // Thread has a WebThreadSupportingGC. It initializes / shutdowns |
| 46 // additional objects based on the given policy. The constructor and the | 46 // additional objects based on the given policy. The constructor and the |
| 47 // destructor blocks during the setup and the teardown. | 47 // destructor blocks during the setup and the teardown. |
| 48 class Thread final { | 48 class Thread final { |
| 49 USING_FAST_MALLOC(Thread); | 49 USING_FAST_MALLOC(Thread); |
| 50 public: | 50 public: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 // Protects |m_holder|. | 151 // Protects |m_holder|. |
| 152 Mutex m_holderMutex; | 152 Mutex m_holderMutex; |
| 153 // Because Context outlives ThreadHolder, holding a raw pointer | 153 // Because Context outlives ThreadHolder, holding a raw pointer |
| 154 // here is safe. | 154 // here is safe. |
| 155 ThreadHolder* m_holder; | 155 ThreadHolder* m_holder; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 // The reading/updating threads are alive while ThreadHolder is alive. | 158 // The reading/updating threads are alive while ThreadHolder is alive. |
| 159 class ThreadHolder { | 159 class ThreadHolder { |
| 160 DISALLOW_ALLOCATION(); | 160 DISALLOW_NEW(); |
| 161 public: | 161 public: |
| 162 ThreadHolder(ThreadingTestBase* test) | 162 ThreadHolder(ThreadingTestBase* test) |
| 163 : m_context(test->m_context) | 163 : m_context(test->m_context) |
| 164 , m_readingThread(adoptPtr(new Thread("reading thread"))) | 164 , m_readingThread(adoptPtr(new Thread("reading thread"))) |
| 165 , m_updatingThread(adoptPtr(new Thread("updating thread"))) | 165 , m_updatingThread(adoptPtr(new Thread("updating thread"))) |
| 166 { | 166 { |
| 167 m_context->registerThreadHolder(this); | 167 m_context->registerThreadHolder(this); |
| 168 } | 168 } |
| 169 ~ThreadHolder() | 169 ~ThreadHolder() |
| 170 { | 170 { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 { | 355 { |
| 356 didFetchDataLoadedArrayBufferMock(arrayBuffer); | 356 didFetchDataLoadedArrayBufferMock(arrayBuffer); |
| 357 } | 357 } |
| 358 void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle> blobDataHan
dle) override | 358 void didFetchDataLoadedBlobHandle(PassRefPtr<BlobDataHandle> blobDataHan
dle) override |
| 359 { | 359 { |
| 360 didFetchDataLoadedBlobHandleMock(blobDataHandle); | 360 didFetchDataLoadedBlobHandleMock(blobDataHandle); |
| 361 } | 361 } |
| 362 }; | 362 }; |
| 363 | 363 |
| 364 class Command final { | 364 class Command final { |
| 365 ALLOW_ONLY_INLINE_ALLOCATION(); | 365 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 366 public: | 366 public: |
| 367 enum Name { | 367 enum Name { |
| 368 Data, | 368 Data, |
| 369 Done, | 369 Done, |
| 370 Error, | 370 Error, |
| 371 Wait, | 371 Wait, |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 Command(Name name) : m_name(name) { } | 374 Command(Name name) : m_name(name) { } |
| 375 Command(Name name, const Vector<char>& body) : m_name(name), m_body(body
) { } | 375 Command(Name name, const Vector<char>& body) : m_name(name), m_body(body
) { } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 OwnPtr<HandleReadResult> m_result; | 536 OwnPtr<HandleReadResult> m_result; |
| 537 bool m_isDone; | 537 bool m_isDone; |
| 538 | 538 |
| 539 OwnPtr<T> m_handleReader; | 539 OwnPtr<T> m_handleReader; |
| 540 }; | 540 }; |
| 541 }; | 541 }; |
| 542 | 542 |
| 543 } // namespace blink | 543 } // namespace blink |
| 544 | 544 |
| 545 #endif // DataConsumerHandleTestUtil_h | 545 #endif // DataConsumerHandleTestUtil_h |
| OLD | NEW |