summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-07 22:19:50 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-07 22:19:50 +0000
commitcfa428e0e42218b43f0c0b2486d2cc19b675d37d (patch)
tree7377cebabc3d676447cc1dcd564ec1cb9d17664c
parent861d4339e73a774ccd04401e1a90d5b5403e1e3f (diff)
downloadchromium_src-cfa428e0e42218b43f0c0b2486d2cc19b675d37d.zip
chromium_src-cfa428e0e42218b43f0c0b2486d2cc19b675d37d.tar.gz
chromium_src-cfa428e0e42218b43f0c0b2486d2cc19b675d37d.tar.bz2
Don't DCHECK if a watched directory doesn't exist.
The caller can't easily check whether a directory exists before calling this functions. Also modify GreasemonkeyMaster to allow this condition. Review URL: http://codereview.chromium.org/16580 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7687 0039d316-1c4b-4281-b951-d872f2087c98
-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() {