diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 08:14:38 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 08:14:38 +0000 |
commit | a4378256e3c3530bd84f8cce49d1edb82874632b (patch) | |
tree | 47266268730220458ec5996a4a5994abce798dd7 /base/directory_watcher_win.cc | |
parent | 3747791d3d47eeaa9aef440bda06b50f594bd386 (diff) | |
download | chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.zip chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.tar.gz chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.tar.bz2 |
Remove DirectoryWatcher and the only thing using it.
DirectoryWatcher was problematic. We couldn't get it right on Linux,
it can hit the disk on UI thread on Windows (Really Bad, tm). And
finally, the UserScriptMaster didn't work right with it.
TEST=Covered by unit_tests and browser_tests
BUG=8968, 6051, 6080, 20832
Review URL: http://codereview.chromium.org/586010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/directory_watcher_win.cc')
-rw-r--r-- | base/directory_watcher_win.cc | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/base/directory_watcher_win.cc b/base/directory_watcher_win.cc deleted file mode 100644 index e318d4b..0000000 --- a/base/directory_watcher_win.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/directory_watcher.h" - -#include "base/file_path.h" -#include "base/logging.h" -#include "base/object_watcher.h" -#include "base/ref_counted.h" - -namespace { - -class DirectoryWatcherImpl : public DirectoryWatcher::PlatformDelegate, - public base::ObjectWatcher::Delegate { - public: - DirectoryWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} - - virtual bool Watch(const FilePath& path, DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive); - - // Callback from MessageLoopForIO. - virtual void OnObjectSignaled(HANDLE object); - - private: - virtual ~DirectoryWatcherImpl(); - - // Delegate to notify upon changes. - DirectoryWatcher::Delegate* delegate_; - // Path we're watching (passed to delegate). - FilePath path_; - // Handle for FindFirstChangeNotification. - HANDLE handle_; - // ObjectWatcher to watch handle_ for events. - base::ObjectWatcher watcher_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryWatcherImpl); -}; - -DirectoryWatcherImpl::~DirectoryWatcherImpl() { - if (handle_ != INVALID_HANDLE_VALUE) { - watcher_.StopWatching(); - FindCloseChangeNotification(handle_); - } -} - -bool DirectoryWatcherImpl::Watch(const FilePath& path, - DirectoryWatcher::Delegate* delegate, - MessageLoop* backend_loop, bool recursive) { - DCHECK(path_.value().empty()); // Can only watch one path. - - handle_ = FindFirstChangeNotification( - path.value().c_str(), - recursive, - FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE | - FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_DIR_NAME); - if (handle_ == INVALID_HANDLE_VALUE) - return false; - - delegate_ = delegate; - path_ = path; - watcher_.StartWatching(handle_, this); - - return true; -} - -void DirectoryWatcherImpl::OnObjectSignaled(HANDLE object) { - DCHECK(object == handle_); - // Make sure we stay alive through the body of this function. - scoped_refptr<DirectoryWatcherImpl> keep_alive(this); - - delegate_->OnDirectoryChanged(path_); - - // Register for more notifications on file change. - BOOL ok = FindNextChangeNotification(object); - DCHECK(ok); - watcher_.StartWatching(object, this); -} - -} // namespace - -DirectoryWatcher::DirectoryWatcher() { - impl_ = new DirectoryWatcherImpl(); -} |