summaryrefslogtreecommitdiffstats
path: root/chrome/browser/user_style_sheet_watcher.h
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 13:30:43 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 13:30:43 +0000
commit446510d79070b428742f90337b768d9133988d96 (patch)
treea7a2166939b452b2e4b3cf09433c5fba9250cd0a /chrome/browser/user_style_sheet_watcher.h
parent04aa8e062fd9f29d106aca258e7c0cdd34b641eb (diff)
downloadchromium_src-446510d79070b428742f90337b768d9133988d96.zip
chromium_src-446510d79070b428742f90337b768d9133988d96.tar.gz
chromium_src-446510d79070b428742f90337b768d9133988d96.tar.bz2
Rework FileWatcher to avoid race condition upon deletion.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2868114 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/user_style_sheet_watcher.h')
-rw-r--r--chrome/browser/user_style_sheet_watcher.h30
1 files changed, 9 insertions, 21 deletions
diff --git a/chrome/browser/user_style_sheet_watcher.h b/chrome/browser/user_style_sheet_watcher.h
index d029b4f..c4974de 100644
--- a/chrome/browser/user_style_sheet_watcher.h
+++ b/chrome/browser/user_style_sheet_watcher.h
@@ -7,7 +7,6 @@
#pragma once
#include "base/file_path.h"
-#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/chrome_thread.h"
@@ -16,49 +15,38 @@
#include "chrome/common/notification_registrar.h"
#include "googleurl/src/gurl.h"
-// This loads the user style sheet on the file thread and sends a notification
-// when the style sheet is loaded.
+class UserStyleSheetLoader;
+
+// Watches the user style sheet file and triggers reloads on the file thread
+// whenever the file changes.
class UserStyleSheetWatcher
: public base::RefCountedThreadSafe<UserStyleSheetWatcher,
ChromeThread::DeleteOnUIThread>,
- public NotificationObserver,
- public FileWatcher::Delegate {
+ public NotificationObserver {
public:
explicit UserStyleSheetWatcher(const FilePath& profile_path);
- virtual ~UserStyleSheetWatcher() {}
+ virtual ~UserStyleSheetWatcher();
void Init();
- GURL user_style_sheet() const {
- return user_style_sheet_;
- }
+ GURL user_style_sheet() const;
// NotificationObserver interface
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- // FileWatcher::Delegate interface
- virtual void OnFileChanged(const FilePath& path);
-
private:
- // Load the user style sheet on the file thread and convert it to a
- // base64 URL. Posts the base64 URL back to the UI thread.
- void LoadStyleSheet(const FilePath& profile_path);
-
- void SetStyleSheet(const GURL& url);
-
// The directory containing User StyleSheets/Custom.css.
FilePath profile_path_;
- // The user style sheet as a base64 data:// URL.
- GURL user_style_sheet_;
+ // The loader object.
+ scoped_refptr<UserStyleSheetLoader> loader_;
// Watches for changes to the css file so we can reload the style sheet.
scoped_ptr<FileWatcher> file_watcher_;
NotificationRegistrar registrar_;
- bool has_loaded_;
DISALLOW_COPY_AND_ASSIGN(UserStyleSheetWatcher);
};