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

Unified Diff: Source/platform/WebThreadSupportingGC.h

Issue 1319363002: Makes WebThreadSupportingGC constructible for an existing thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/WebThreadSupportingGC.h
diff --git a/Source/platform/WebThreadSupportingGC.h b/Source/platform/WebThreadSupportingGC.h
index b2bfd6ae65ae044ffcf44b0a9bd248bbbeef33b6..43abf42a859d03bcb837517c69c713e58e84e817 100644
--- a/Source/platform/WebThreadSupportingGC.h
+++ b/Source/platform/WebThreadSupportingGC.h
@@ -21,10 +21,14 @@ namespace blink {
// thread allocates any objects managed by the Blink GC. The shutdown
// method must be called on the WebThread during shutdown when the thread
// no longer needs to access objects managed by the Blink GC.
+//
+// WebThreadSupportingGC usually internally creates and owns WebThread unless
+// an existing WebThread is given via createForThread.
class PLATFORM_EXPORT WebThreadSupportingGC final {
WTF_MAKE_NONCOPYABLE(WebThreadSupportingGC);
public:
- static PassOwnPtr<WebThreadSupportingGC> create(const char*);
+ static PassOwnPtr<WebThreadSupportingGC> create(const char* name);
+ static PassOwnPtr<WebThreadSupportingGC> createForThread(WebThread*);
~WebThreadSupportingGC();
void postTask(const WebTraceLocation& location, WebThread::Task* task)
@@ -62,10 +66,15 @@ public:
}
private:
- explicit WebThreadSupportingGC(const char*);
+ WebThreadSupportingGC(const char* name, WebThread*);
OwnPtr<PendingGCRunner> m_pendingGCRunner;
- OwnPtr<WebThread> m_thread;
+
+ // m_thread is guaranteed to be non-null after this instance is constructed.
+ // m_owningThread is non-null unless this instance is constructed for an
+ // existing thread via createForThread().
+ WebThread* m_thread = nullptr;
+ OwnPtr<WebThread> m_owningThread;
};
}

Powered by Google App Engine
This is Rietveld 408576698