summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/directory_watcher_unittest.cc9
-rw-r--r--base/directory_watcher_win.cc4
-rw-r--r--chrome/browser/greasemonkey_master.cc9
3 files changed, 14 insertions, 8 deletions
diff --git a/base/directory_watcher_unittest.cc b/base/directory_watcher_unittest.cc
index 39f64bb..5e32a36 100644
--- a/base/directory_watcher_unittest.cc
+++ b/base/directory_watcher_unittest.cc
@@ -184,3 +184,12 @@ TEST_F(DirectoryWatcherTest, DeleteDuringNotify) {
// Might as well double-check it got deleted, too.
ASSERT_TRUE(deleter.watcher_.get() == NULL);
}
+
+// Verify that watching a directory that doesn't exist fails, but doesn't
+// asssert.
+// Basic test: add a file and verify we notice it.
+TEST_F(DirectoryWatcherTest, NonExistentDirectory) {
+ DirectoryWatcher watcher;
+ ASSERT_FALSE(watcher.Watch(
+ test_dir_.Append(FILE_PATH_LITERAL("does-not-exist")), this));
+}
diff --git a/base/directory_watcher_win.cc b/base/directory_watcher_win.cc
index cdaec39..6fe6ba5 100644
--- a/base/directory_watcher_win.cc
+++ b/base/directory_watcher_win.cc
@@ -48,10 +48,8 @@ bool DirectoryWatcher::Impl::Watch(const FilePath& path) {
FALSE, // Don't watch subtree.
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE |
FILE_NOTIFY_CHANGE_LAST_WRITE);
- if (handle_ == INVALID_HANDLE_VALUE) {
- NOTREACHED();
+ if (handle_ == INVALID_HANDLE_VALUE)
return false;
- }
path_ = path;
watcher_.StartWatching(handle_, this);
diff --git a/chrome/browser/greasemonkey_master.cc b/chrome/browser/greasemonkey_master.cc
index 11c3085..715da54 100644
--- a/chrome/browser/greasemonkey_master.cc
+++ b/chrome/browser/greasemonkey_master.cc
@@ -168,11 +168,10 @@ GreasemonkeyMaster::GreasemonkeyMaster(MessageLoop* worker_loop,
worker_loop_(worker_loop),
pending_scan_(false) {
// Watch our scripts directory for modifications.
- bool ok = dir_watcher_->Watch(script_dir, this);
- DCHECK(ok);
-
- // (Asynchronously) scan for our initial set of scripts.
- StartScan();
+ if (dir_watcher_->Watch(script_dir, this)) {
+ // (Asynchronously) scan for our initial set of scripts.
+ StartScan();
+ }
}
GreasemonkeyMaster::~GreasemonkeyMaster() {