Commit 221c38d7 authored by rsimha@chromium.org's avatar rsimha@chromium.org

Allow IO operations in destructor of net::NetworkConfigWatcherMacThread

The destructor of net::NetworkConfigWatcherMacThread ends up calling
PlatformThread::Join(), an operation that needs to be done only from an
IO thread. This currently causes a DCHECK to fire in base::ThreadRestrictions.

The bug was discovered by running the sync integration tests on a mac trybot.
The tests create Profile objects during setup, that indirectly call
~NetworkConfigWatcherMacThread() from their destructors.

This patch allows IO operations in ~NetworkConfigWatcherMacThread()
using a ScopedAllowIO.

BUG=70190
TEST=sync_integration_tests

Review URL: http://codereview.chromium.org/6353008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72030 0039d316-1c4b-4281-b951-d872f2087c98
parent bff3df1e
......@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/threading/thread.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/threading/thread_restrictions.h"
namespace net {
......@@ -54,10 +55,18 @@ NetworkConfigWatcherMacThread::NetworkConfigWatcherMacThread(
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
NetworkConfigWatcherMacThread::~NetworkConfigWatcherMacThread() {
// Allow IO because Stop() calls PlatformThread::Join(), which is a blocking
// operation. This is expected during shutdown.
base::ThreadRestrictions::ScopedAllowIO allow_io;
Stop();
}
void NetworkConfigWatcherMacThread::Init() {
// Disallow IO to make sure NetworkConfigWatcherMacThread's helper thread does
// not perform blocking operations.
base::ThreadRestrictions::SetIOAllowed(false);
// TODO(willchan): Look to see if there's a better signal for when it's ok to
// initialize this, rather than just delaying it by a fixed time.
const int kInitializationDelayMS = 1000;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment