summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-08 19:08:41 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-08 19:08:41 +0000
commit4624de3c49d26fea125418ebb30c66d9bb9c9f53 (patch)
tree7b2368423030be20c91fc92948ff8af5f66ffeac /chrome
parent07b71c86d06a34f21bbd4109f74fc6b24f2bcd68 (diff)
downloadchromium_src-4624de3c49d26fea125418ebb30c66d9bb9c9f53.zip
chromium_src-4624de3c49d26fea125418ebb30c66d9bb9c9f53.tar.gz
chromium_src-4624de3c49d26fea125418ebb30c66d9bb9c9f53.tar.bz2
Switch to using FilePathWatcher::Callback instead of FilePathWatcher::Delegate.
BUG=130980 Review URL: https://codereview.chromium.org/11773046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/user_style_sheet_watcher.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc
index acfe178..119424f 100644
--- a/chrome/browser/user_style_sheet_watcher.cc
+++ b/chrome/browser/user_style_sheet_watcher.cc
@@ -44,7 +44,8 @@ const char kUserStyleSheetFile[] = "Custom.css";
// 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 {
+class UserStyleSheetLoader
+ : public base::RefCountedThreadSafe<UserStyleSheetLoader> {
public:
UserStyleSheetLoader();
@@ -59,11 +60,12 @@ class UserStyleSheetLoader : public FilePathWatcher::Delegate {
// Send out a notification if the stylesheet has already been loaded.
void NotifyLoaded();
- // FilePathWatcher::Delegate interface
- virtual void OnFilePathChanged(const FilePath& path);
+ // FilePathWatcher::Callback method:
+ void NotifyPathChanged(const FilePath& path, bool error);
private:
- virtual ~UserStyleSheetLoader() {}
+ friend class base::RefCountedThreadSafe<UserStyleSheetLoader>;
+ ~UserStyleSheetLoader() {}
// Called on the UI thread after the stylesheet has loaded.
void SetStyleSheet(const GURL& url);
@@ -90,8 +92,9 @@ void UserStyleSheetLoader::NotifyLoaded() {
}
}
-void UserStyleSheetLoader::OnFilePathChanged(const FilePath& path) {
- LoadStyleSheet(path);
+void UserStyleSheetLoader::NotifyPathChanged(const FilePath& path, bool error) {
+ if (!error)
+ LoadStyleSheet(path);
}
void UserStyleSheetLoader::LoadStyleSheet(const FilePath& style_sheet_file) {
@@ -162,8 +165,10 @@ void UserStyleSheetWatcher::Init() {
FilePath style_sheet_file = profile_path_.AppendASCII(kStyleSheetDir)
.AppendASCII(kUserStyleSheetFile);
if (!file_watcher_->Watch(
- style_sheet_file,
- loader_.get())) {
+ style_sheet_file,
+ false,
+ base::Bind(&UserStyleSheetLoader::NotifyPathChanged,
+ loader_.get()))) {
LOG(ERROR) << "Failed to setup watch for " << style_sheet_file.value();
}
loader_->LoadStyleSheet(style_sheet_file);