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

Unified Diff: trunk/src/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc

Issue 23537068: Revert 225008 "Fix a threading bug in the brlapi basec braille c..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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: trunk/src/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc
===================================================================
--- trunk/src/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc (revision 225010)
+++ trunk/src/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc (working copy)
@@ -134,7 +134,7 @@
}
void BrailleControllerImpl::PokeSocketDirForTesting() {
- OnSocketDirChangedOnIOThread();
+ OnSocketDirChanged(base::FilePath(), false /*error*/);
}
void BrailleControllerImpl::StartConnecting() {
@@ -146,44 +146,26 @@
if (!libbrlapi_loader_.loaded()) {
return;
}
- // One could argue that there is a race condition between starting to
- // watch the socket asynchonously and trying to connect. While this is true,
- // we are actually retrying to connect for a while, so this doesn't matter
- // in practice.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE, base::Bind(
- &BrailleControllerImpl::StartWatchingSocketDirOnFileThread,
- base::Unretained(this)));
- ResetRetryConnectHorizon();
- TryToConnect();
-}
-
-void BrailleControllerImpl::StartWatchingSocketDirOnFileThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath brlapi_dir(BRLAPI_SOCKETPATH);
if (!file_path_watcher_.Watch(
brlapi_dir, false, base::Bind(
- &BrailleControllerImpl::OnSocketDirChangedOnFileThread,
+ &BrailleControllerImpl::OnSocketDirChanged,
base::Unretained(this)))) {
LOG(WARNING) << "Couldn't watch brlapi directory " << BRLAPI_SOCKETPATH;
+ return;
}
+ ResetRetryConnectHorizon();
+ TryToConnect();
}
-void BrailleControllerImpl::OnSocketDirChangedOnFileThread(
- const base::FilePath& path, bool error) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+void BrailleControllerImpl::OnSocketDirChanged(const base::FilePath& path,
+ bool error) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(libbrlapi_loader_.loaded());
if (error) {
LOG(ERROR) << "Error watching brlapi directory: " << path.value();
return;
}
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE, base::Bind(
- &BrailleControllerImpl::OnSocketDirChangedOnIOThread,
- base::Unretained(this)));
-}
-
-void BrailleControllerImpl::OnSocketDirChangedOnIOThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
LOG(INFO) << "BrlAPI directory changed";
// Every directory change resets the max retry time to the appropriate delay
// into the future.

Powered by Google App Engine
This is Rietveld 408576698