diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-27 03:59:31 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-27 03:59:31 +0000 |
commit | d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1 (patch) | |
tree | e03156e3142955f7cf637fe404a1ce2c6f7aaaf4 /chrome/browser/chromeos | |
parent | 76a188be4e3ddc42c42beabfeeeb618b2adae11e (diff) | |
download | chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.zip chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.tar.gz chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.tar.bz2 |
Simplify threading in browser thread by making only ChromeThread deal with different thread lifetimes.The rest of the code doesn't get MessageLoop pointers since they're not thread-safe and instead just call PostTask on ChromeThread. If the target thread is not alive, then the task is simply deleted.In a followup change, I'll remove any remaining MessageLoop* caching. With this change, there's little to be gained by caching since no locks are involved if the target MessageLoop is guaranteed to outlive the current thread (inferred automatically by the order of the chrome_threads_ array).BUG=25354
Review URL: http://codereview.chromium.org/306032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r-- | chrome/browser/chromeos/cros_network_library.cc | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros_power_library.cc | 7 |
2 files changed, 8 insertions, 9 deletions
diff --git a/chrome/browser/chromeos/cros_network_library.cc b/chrome/browser/chromeos/cros_network_library.cc index 8ca9abc..3253a85 100644 --- a/chrome/browser/chromeos/cros_network_library.cc +++ b/chrome/browser/chromeos/cros_network_library.cc @@ -137,11 +137,11 @@ void CrosNetworkLibrary::UpdateNetworkStatus( const WifiNetworkVector& networks, bool ethernet_connected) { // Make sure we run on UI thread. if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { - MessageLoop* loop = ChromeThread::GetMessageLoop(ChromeThread::UI); - if (loop) - loop->PostTask(FROM_HERE, NewRunnableMethod(this, - &CrosNetworkLibrary::UpdateNetworkStatus, networks, - ethernet_connected)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod(this, + &CrosNetworkLibrary::UpdateNetworkStatus, networks, + ethernet_connected)); return; } diff --git a/chrome/browser/chromeos/cros_power_library.cc b/chrome/browser/chromeos/cros_power_library.cc index d3188e8..d8a8e2b 100644 --- a/chrome/browser/chromeos/cros_power_library.cc +++ b/chrome/browser/chromeos/cros_power_library.cc @@ -86,10 +86,9 @@ void CrosPowerLibrary::Init() { void CrosPowerLibrary::UpdatePowerStatus(const chromeos::PowerStatus& status) { // Make sure we run on UI thread. if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { - MessageLoop* loop = ChromeThread::GetMessageLoop(ChromeThread::UI); - if (loop) - loop->PostTask(FROM_HERE, NewRunnableMethod(this, - &CrosPowerLibrary::UpdatePowerStatus, status)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod(this, &CrosPowerLibrary::UpdatePowerStatus, status)); return; } |