Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: chrome/browser/user_style_sheet_watcher.cc

Issue 11773046: Switch to using FilePathWatcher::Callback instead of FilePathWatcher::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/user_style_sheet_watcher.cc
diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc
index acfe17845a12e3e387ed83b8c1be3230f791e886..119424f1eb3022a87aff9581a5427cd4a8e11c7b 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698