commit | 0454521fb89d5069d85c4e0d514b334d062f8dfb | [log] [tgz] |
---|---|---|
author | Min Qin <[email protected]> | Wed Nov 06 01:10:49 2019 |
committer | Commit Bot <[email protected]> | Wed Nov 06 01:10:49 2019 |
tree | ab7eaee63872a1a322d7af0e529b67f15274b2fa | |
parent | fe343e8118712c1b87d0b0c6e12b18b93b9e94d7 [diff] |
Fix a crash when calling GetNetworkService() on Android On Android, NetworkChangeNotifier can be created in 2 situations: 1. In BrowserMainLoop::PostMainMessageLoopStart(), NetworkChangeNotifierAndroid will be created on UI thread. 2. Triggered by the GetNetworkService() call when network service is running in-process, NetworkChangeNotifierPosix will be created on IO thread Because 1 and 2 happens on 2 different threads, there is a race condition that both creation calls could take place. This CL fixes the issue by: 1. Combining NetworkChangeNotifier::HasNetworkChangeNotifier() and NetworkChangeNotifier::Create() into a single method CreateIfNeeded(), so that race condition won't be introduced between Has() and Create(). 2. Use a lock to protect CreateIfNeeded(), so that only one global instance will be created if multiple threads are competing with each other. The original logic of not using a lock is introduce 9 years ago: http://codereview.chromium.org/2802015, but with network service, the situation is more complicated. As a result, the lock usage will provide a safer and more simple approach to solve the issue. 3. Calling SetNetworkChangeNotifierFactory early for Android code. BUG=1009981 Change-Id: I88dd50ca23d08f110f7ac7ffe08d50da65a05fac Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872414 Reviewed-by: Clark DuVall <[email protected]> Reviewed-by: Mike Dougherty <[email protected]> Reviewed-by: John Abd-El-Malek <[email protected]> Reviewed-by: Paul Jensen <[email protected]> Reviewed-by: Gary Kacmarcik <[email protected]> Reviewed-by: Changwan Ryu <[email protected]> Reviewed-by: Xi Han <[email protected]> Commit-Queue: Min Qin <[email protected]> Cr-Commit-Position: refs/heads/master@{#712848}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .