-
Michael Lippautz authored
CTWP is a weak ref used on a different thread than the object has been original been allocated on. Using the object directly is inherently unsafe as garbage collection only consider the stack of the thread the heap is attached to. For that reason, working on an object must require a strong reference. Note that this does not rule out issues, as the originating thread may terminate in which case even the strong CrossThreadPersistent does not keep the object alive. Nonetheless, the only valid use case of a CTWP should be weakly pointing to an object. The CL introduces a Lock() call, similar to std::weak_ptr::Lock() with the same semantics: The reference (CTP) needs to be check against cleared'ness before the object can be used. Blink: Most use cases rely on external synchronizations when accessing a CTWP, so this change merely hardens the API but likely does not fix any real issues. Bug: 1125495 Change-Id: Ib859df5e9c5f418aa36797c4bd9a444de8c82b15 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391231 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by:
Omer Katz <omerkatz@chromium.org> Reviewed-by:
Anton Bikineev <bikineev@chromium.org> Reviewed-by:
Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/master@{#804864}
dfc90c3d