| 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 "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 result_.Append(".\n"); | 104 result_.Append(".\n"); |
| 105 } | 105 } |
| 106 | 106 |
| 107 String Result() { | 107 String Result() { |
| 108 MutexLocker locker(logging_mutex_); | 108 MutexLocker locker(logging_mutex_); |
| 109 return result_.ToString(); | 109 return result_.ToString(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void RegisterThreadHolder(ThreadHolder* holder) { | 112 void RegisterThreadHolder(ThreadHolder* holder) { |
| 113 MutexLocker locker(holder_mutex_); | 113 MutexLocker locker(holder_mutex_); |
| 114 ASSERT(!holder_); | 114 DCHECK(!holder_); |
| 115 holder_ = holder; | 115 holder_ = holder; |
| 116 } | 116 } |
| 117 void UnregisterThreadHolder() { | 117 void UnregisterThreadHolder() { |
| 118 MutexLocker locker(holder_mutex_); | 118 MutexLocker locker(holder_mutex_); |
| 119 ASSERT(holder_); | 119 DCHECK(holder_); |
| 120 holder_ = nullptr; | 120 holder_ = nullptr; |
| 121 } | 121 } |
| 122 void PostTaskToReadingThread(const WebTraceLocation& location, | 122 void PostTaskToReadingThread(const WebTraceLocation& location, |
| 123 std::unique_ptr<CrossThreadClosure> task) { | 123 std::unique_ptr<CrossThreadClosure> task) { |
| 124 MutexLocker locker(holder_mutex_); | 124 MutexLocker locker(holder_mutex_); |
| 125 ASSERT(holder_); | 125 DCHECK(holder_); |
| 126 holder_->ReadingThread()->PostTask(location, std::move(task)); | 126 holder_->ReadingThread()->PostTask(location, std::move(task)); |
| 127 } | 127 } |
| 128 void PostTaskToUpdatingThread(const WebTraceLocation& location, | 128 void PostTaskToUpdatingThread(const WebTraceLocation& location, |
| 129 std::unique_ptr<CrossThreadClosure> task) { | 129 std::unique_ptr<CrossThreadClosure> task) { |
| 130 MutexLocker locker(holder_mutex_); | 130 MutexLocker locker(holder_mutex_); |
| 131 ASSERT(holder_); | 131 DCHECK(holder_); |
| 132 holder_->UpdatingThread()->PostTask(location, std::move(task)); | 132 holder_->UpdatingThread()->PostTask(location, std::move(task)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 Context() : holder_(nullptr) {} | 136 Context() : holder_(nullptr) {} |
| 137 String CurrentThreadName() { | 137 String CurrentThreadName() { |
| 138 MutexLocker locker(holder_mutex_); | 138 MutexLocker locker(holder_mutex_); |
| 139 if (holder_) { | 139 if (holder_) { |
| 140 if (holder_->ReadingThread()->IsCurrentThread()) | 140 if (holder_->ReadingThread()->IsCurrentThread()) |
| 141 return "the reading thread"; | 141 return "the reading thread"; |
| (...skipping 374 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 |