diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 02:45:56 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 02:45:56 +0000 |
commit | 9e8d4f92df67dd8d4c8d4097035aaf6279fe84ba (patch) | |
tree | ed08cb639f07c35da5eabc10f4519cb88c10ae64 /base/directory_watcher.h | |
parent | 9b6633c2877f08381f84f60a33a5eeb9bfa0f3e0 (diff) | |
download | chromium_src-9e8d4f92df67dd8d4c8d4097035aaf6279fe84ba.zip chromium_src-9e8d4f92df67dd8d4c8d4097035aaf6279fe84ba.tar.gz chromium_src-9e8d4f92df67dd8d4c8d4097035aaf6279fe84ba.tar.bz2 |
Add a DirectoryWatcher class, allowing objects to be notified whenever
a directory's contents change.
Review URL: http://codereview.chromium.org/6377
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/directory_watcher.h')
-rw-r--r-- | base/directory_watcher.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/base/directory_watcher.h b/base/directory_watcher.h new file mode 100644 index 0000000..3048d66 --- /dev/null +++ b/base/directory_watcher.h @@ -0,0 +1,42 @@ +// Copyright (c) 2006-2008 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. + +// This module provides a way to monitor a directory for changes. + +#ifndef BASE_DIRECTORY_WATCHER_H_ +#define BASE_DIRECTORY_WATCHER_H_ + +#include <string> +#include "base/basictypes.h" +#include "base/ref_counted.h" + +class FilePath; + +// This class lets you register interest in changes on a directory. +// The delegate will get called whenever a file is added or changed in the +// directory. +class DirectoryWatcher { + public: + class Delegate { + public: + virtual void OnDirectoryChanged(const FilePath& path) = 0; + }; + + DirectoryWatcher(); + ~DirectoryWatcher(); + + // Register interest in any changes in the directory |path|. + // OnDirectoryChanged will be called back for each change within the dir. + // Returns false on error. + bool Watch(const FilePath& path, Delegate* delegate); + + private: + class Impl; + friend class Impl; + scoped_refptr<Impl> impl_; + + DISALLOW_COPY_AND_ASSIGN(DirectoryWatcher); +}; + +#endif // BASE_DIRECTORY_WATCHER_H_ |