Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/CrossThreadHolder.h

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CrossThreadHolder_h 5 #ifndef CrossThreadHolder_h
6 #define CrossThreadHolder_h 6 #define CrossThreadHolder_h
7 7
8 #include "core/dom/ActiveDOMObject.h" 8 #include "core/dom/ActiveDOMObject.h"
9 #include "core/dom/CrossThreadTask.h" 9 #include "core/dom/CrossThreadTask.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // destructed (possibly on the calling thread or on the thread of 46 // destructed (possibly on the calling thread or on the thread of
47 // |executionContext|) when |executionContext| is stopped or 47 // |executionContext|) when |executionContext| is stopped or
48 // CrossThreadHolder is destructed. 48 // CrossThreadHolder is destructed.
49 void postTask(PassOwnPtr<WTF::Function<void(T*, ExecutionContext*), WTF::Cro ssThreadAffinity>> task) 49 void postTask(PassOwnPtr<WTF::Function<void(T*, ExecutionContext*), WTF::Cro ssThreadAffinity>> task)
50 { 50 {
51 MutexLocker locker(m_mutex->mutex()); 51 MutexLocker locker(m_mutex->mutex());
52 if (!m_bridge) { 52 if (!m_bridge) {
53 // The bridge has already disappeared. 53 // The bridge has already disappeared.
54 return; 54 return;
55 } 55 }
56 m_bridge->executionContext()->postTask(BLINK_FROM_HERE, createCrossThrea dTask(&Bridge::runTask, m_bridge.get(), task)); 56 m_bridge->getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossTh readTask(&Bridge::runTask, m_bridge.get(), task));
57 } 57 }
58 58
59 ~CrossThreadHolder() 59 ~CrossThreadHolder()
60 { 60 {
61 MutexLocker locker(m_mutex->mutex()); 61 MutexLocker locker(m_mutex->mutex());
62 clearInternal(); 62 clearInternal();
63 } 63 }
64 64
65 private: 65 private:
66 // Object graph: 66 // Object graph:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // can be called on any thread. 114 // can be called on any thread.
115 void clearInternal() 115 void clearInternal()
116 { 116 {
117 // We don't clear |m_obj| here to destruct |m_obj| on the thread 117 // We don't clear |m_obj| here to destruct |m_obj| on the thread
118 // of |executionContext|. 118 // of |executionContext|.
119 m_holder = nullptr; 119 m_holder = nullptr;
120 } 120 }
121 121
122 void runTask(PassOwnPtr<WTF::Function<void(T*, ExecutionContext*), WTF:: CrossThreadAffinity>> task) 122 void runTask(PassOwnPtr<WTF::Function<void(T*, ExecutionContext*), WTF:: CrossThreadAffinity>> task)
123 { 123 {
124 ASSERT(executionContext()->isContextThread()); 124 ASSERT(getExecutionContext()->isContextThread());
125 if (m_obj) 125 if (m_obj)
126 (*task)(m_obj.get(), executionContext()); 126 (*task)(m_obj.get(), getExecutionContext());
127 } 127 }
128 128
129 private: 129 private:
130 // ActiveDOMObject 130 // ActiveDOMObject
131 void stop() override 131 void stop() override
132 { 132 {
133 ASSERT(executionContext()->isContextThread()); 133 ASSERT(getExecutionContext()->isContextThread());
134 { 134 {
135 MutexLocker locker(m_mutex->mutex()); 135 MutexLocker locker(m_mutex->mutex());
136 if (m_holder) 136 if (m_holder)
137 m_holder->clearInternal(); 137 m_holder->clearInternal();
138 ASSERT(!m_holder); 138 ASSERT(!m_holder);
139 } 139 }
140 140
141 // We have to destruct |*m_obj| here because destructing |*m_obj| 141 // We have to destruct |*m_obj| here because destructing |*m_obj|
142 // in ~Bridge() might be too late when |executionContext| is 142 // in ~Bridge() might be too late when |executionContext| is
143 // stopped. 143 // stopped.
(...skipping 24 matching lines...) Expand all
168 RefPtr<MutexWrapper> m_mutex; 168 RefPtr<MutexWrapper> m_mutex;
169 // |m_bridge| is protected by |m_mutex|. 169 // |m_bridge| is protected by |m_mutex|.
170 // |m_bridge| is cleared before the thread that allocated |*m_bridge| 170 // |m_bridge| is cleared before the thread that allocated |*m_bridge|
171 // is stopped. 171 // is stopped.
172 CrossThreadPersistent<Bridge> m_bridge; 172 CrossThreadPersistent<Bridge> m_bridge;
173 }; 173 };
174 174
175 } // namespace blink 175 } // namespace blink
176 176
177 #endif // CrossThreadHolder_h 177 #endif // CrossThreadHolder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698