diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 10:35:46 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 10:35:46 +0000 |
commit | 5199d74e9d09b9a0b3ab9f600fcc96a54a5902ba (patch) | |
tree | 6f9cd0f89fca60d9c3ecb8f53a740f051428e862 /chrome/browser/user_style_sheet_watcher.cc | |
parent | bdb541d643bce8fa366b8102c579ff84f42e40be (diff) | |
download | chromium_src-5199d74e9d09b9a0b3ab9f600fcc96a54a5902ba.zip chromium_src-5199d74e9d09b9a0b3ab9f600fcc96a54a5902ba.tar.gz chromium_src-5199d74e9d09b9a0b3ab9f600fcc96a54a5902ba.tar.bz2 |
Reland 56341 - Add support for watching directories to FileWatcher.
BUG=none
TEST=Unit tests in file_watcher_unittest.cc.
Review URL: http://codereview.chromium.org/3184010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/user_style_sheet_watcher.cc')
-rw-r--r-- | chrome/browser/user_style_sheet_watcher.cc | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc index 3743820..a8789fd 100644 --- a/chrome/browser/user_style_sheet_watcher.cc +++ b/chrome/browser/user_style_sheet_watcher.cc @@ -22,21 +22,21 @@ const char kUserStyleSheetFile[] = "Custom.css"; // file thread and sends a notification when the style sheet is loaded. It is // a helper to UserStyleSheetWatcher. The reference graph is as follows: // -// .-----------------------. owns .-------------. -// | UserStyleSheetWatcher |----------->| FileWatcher | -// '-----------------------' '-------------' -// | | -// V | -// .----------------------. | -// | UserStyleSheetLoader |<------------------' +// .-----------------------. owns .-----------------. +// | UserStyleSheetWatcher |----------->| FilePathWatcher | +// '-----------------------' '-----------------' +// | | +// V | +// .----------------------. | +// | UserStyleSheetLoader |<--------------------' // '----------------------' // -// FileWatcher's reference to UserStyleSheetLoader is used for delivering the -// change notifications. Since they happen asynchronously, UserStyleSheetWatcher -// and its FileWatcher may be destroyed while a callback to UserStyleSheetLoader -// is in progress, in which case the UserStyleSheetLoader object outlives the -// watchers. -class UserStyleSheetLoader : public FileWatcher::Delegate { +// FilePathWatcher's reference to UserStyleSheetLoader is used for delivering +// the change notifications. Since they happen asynchronously, +// UserStyleSheetWatcher and its FilePathWatcher may be destroyed while a +// callback to UserStyleSheetLoader is in progress, in which case the +// UserStyleSheetLoader object outlives the watchers. +class UserStyleSheetLoader : public FilePathWatcher::Delegate { public: UserStyleSheetLoader(); virtual ~UserStyleSheetLoader() {} @@ -52,8 +52,8 @@ class UserStyleSheetLoader : public FileWatcher::Delegate { // Send out a notification if the stylesheet has already been loaded. void NotifyLoaded(); - // FileWatcher::Delegate interface - virtual void OnFileChanged(const FilePath& path); + // FilePathWatcher::Delegate interface + virtual void OnFilePathChanged(const FilePath& path); private: // Called on the UI thread after the stylesheet has loaded. @@ -81,7 +81,7 @@ void UserStyleSheetLoader::NotifyLoaded() { } } -void UserStyleSheetLoader::OnFileChanged(const FilePath& path) { +void UserStyleSheetLoader::OnFilePathChanged(const FilePath& path) { LoadStyleSheet(path); } @@ -145,11 +145,11 @@ void UserStyleSheetWatcher::Init() { } if (!file_watcher_.get()) { - file_watcher_.reset(new FileWatcher); - file_watcher_->Watch(profile_path_.AppendASCII(kStyleSheetDir) - .AppendASCII(kUserStyleSheetFile), loader_.get()); + file_watcher_.reset(new FilePathWatcher); FilePath style_sheet_file = profile_path_.AppendASCII(kStyleSheetDir) .AppendASCII(kUserStyleSheetFile); + if (!file_watcher_->Watch(style_sheet_file, loader_.get())) + LOG(ERROR) << "Failed to setup watch for " << style_sheet_file.value(); loader_->LoadStyleSheet(style_sheet_file); } } |