diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 08:14:38 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 08:14:38 +0000 |
commit | a4378256e3c3530bd84f8cce49d1edb82874632b (patch) | |
tree | 47266268730220458ec5996a4a5994abce798dd7 /chrome | |
parent | 3747791d3d47eeaa9aef440bda06b50f594bd386 (diff) | |
download | chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.zip chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.tar.gz chromium_src-a4378256e3c3530bd84f8cce49d1edb82874632b.tar.bz2 |
Remove DirectoryWatcher and the only thing using it.
DirectoryWatcher was problematic. We couldn't get it right on Linux,
it can hit the disk on UI thread on Windows (Really Bad, tm). And
finally, the UserScriptMaster didn't work right with it.
TEST=Covered by unit_tests and browser_tests
BUG=8968, 6051, 6080, 20832
Review URL: http://codereview.chromium.org/586010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc | 30 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master.h | 15 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master_unittest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 4 |
5 files changed, 1 insertions, 75 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index e284f69..82bd20b 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -2242,14 +2242,13 @@ void AutomationProvider::InstallExtension(const FilePath& crx_path, void AutomationProvider::LoadExpandedExtension( const FilePath& extension_dir, IPC::Message* reply_message) { - if (profile_->GetExtensionsService() && profile_->GetUserScriptMaster()) { + if (profile_->GetExtensionsService()) { // The observer will delete itself when done. new ExtensionNotificationObserver(this, AutomationMsg_LoadExpandedExtension::ID, reply_message); profile_->GetExtensionsService()->LoadExtension(extension_dir); - profile_->GetUserScriptMaster()->AddWatchedPath(extension_dir); } else { AutomationMsg_LoadExpandedExtension::WriteReplyParams( reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index d142e0a..3478b68 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -289,9 +289,6 @@ UserScriptMaster::UserScriptMaster(const FilePath& script_dir, Profile* profile) extensions_service_ready_(false), pending_scan_(false), profile_(profile) { - if (!user_script_dir_.value().empty()) - AddWatchedPath(script_dir); - registrar_.Add(this, NotificationType::EXTENSIONS_READY, Source<Profile>(profile_)); registrar_.Add(this, NotificationType::EXTENSION_LOADED, @@ -303,22 +300,6 @@ UserScriptMaster::UserScriptMaster(const FilePath& script_dir, Profile* profile) UserScriptMaster::~UserScriptMaster() { if (script_reloader_) script_reloader_->DisownMaster(); - -// TODO(aa): Enable this when DirectoryWatcher is implemented for linux. -#if defined(OS_WIN) || defined(OS_MACOSX) - STLDeleteElements(&dir_watchers_); -#endif -} - -void UserScriptMaster::AddWatchedPath(const FilePath& path) { -// TODO(aa): Enable this when DirectoryWatcher is implemented for linux. -#if defined(OS_WIN) || defined(OS_MACOSX) - DirectoryWatcher* watcher = new DirectoryWatcher(); - base::Thread* file_thread = g_browser_process->file_thread(); - watcher->Watch(path, this, file_thread ? file_thread->message_loop() : NULL, - true); - dir_watchers_.push_back(watcher); -#endif } void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { @@ -343,17 +324,6 @@ void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { } } -void UserScriptMaster::OnDirectoryChanged(const FilePath& path) { - if (script_reloader_.get()) { - // We're already scanning for scripts. We note that we should rescan when - // we get the chance. - pending_scan_ = true; - return; - } - - StartScan(); -} - void UserScriptMaster::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { diff --git a/chrome/browser/extensions/user_script_master.h b/chrome/browser/extensions/user_script_master.h index 3a7afd5..645e91d 100644 --- a/chrome/browser/extensions/user_script_master.h +++ b/chrome/browser/extensions/user_script_master.h @@ -5,9 +5,6 @@ #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ -#include <vector> - -#include "base/directory_watcher.h" #include "base/file_path.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" @@ -24,17 +21,12 @@ class StringPiece; // Manages a segment of shared memory that contains the user scripts the user // has installed. Lives on the UI thread. class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, - public DirectoryWatcher::Delegate, public NotificationObserver { public: // For testability, the constructor takes the path the scripts live in. // This is normally a directory inside the profile. explicit UserScriptMaster(const FilePath& script_dir, Profile* profile); - // Add a watched directory. All scripts will be reloaded when any file in - // this directory changes. - void AddWatchedPath(const FilePath& path); - // Kicks off a process on the file thread to reload scripts from disk // into a new chunk of shared memory and notify renderers. virtual void StartScan(); @@ -129,9 +121,6 @@ class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, }; private: - // DirectoryWatcher::Delegate implementation. - virtual void OnDirectoryChanged(const FilePath& path); - // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, @@ -143,10 +132,6 @@ class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, // The directories containing user scripts. FilePath user_script_dir_; - // The watcher watches the profile's user scripts directory for new scripts. - std::vector<DirectoryWatcher*> dir_watchers_; - - // ScriptReloader (in another thread) reloads script off disk. // We hang on to our pointer to know if we've already got one running. scoped_refptr<ScriptReloader> script_reloader_; diff --git a/chrome/browser/extensions/user_script_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc index ef5ac2f..ec8c728 100644 --- a/chrome/browser/extensions/user_script_master_unittest.cc +++ b/chrome/browser/extensions/user_script_master_unittest.cc @@ -91,30 +91,6 @@ TEST_F(UserScriptMasterTest, NoScripts) { ASSERT_TRUE(shared_memory_ != NULL); } -// TODO(shess): Disabled on Linux because of missing DirectoryWatcher. -#if defined(OS_WIN) || defined(OS_MACOSX) -// Test that we get notified about new scripts after they're added. -TEST_F(UserScriptMasterTest, NewScripts) { - TestingProfile profile; - scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_, - &profile)); - - FilePath path = script_dir_.AppendASCII("script.user.js"); - - const char content[] = "some content"; - size_t written = file_util::WriteFile(path, content, sizeof(content)); - ASSERT_EQ(written, sizeof(content)); - - // Post a delayed task so that we fail rather than hanging if things - // don't work. - message_loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, 5000); - - message_loop_.Run(); - - ASSERT_TRUE(shared_memory_ != NULL); -} -#endif - // Test that we get notified about scripts if they're already in the test dir. TEST_F(UserScriptMasterTest, ExistingScripts) { TestingProfile profile; diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index e46cb81..63b8c1d 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -672,10 +672,6 @@ void ProfileImpl::InitExtensions() { if (command_line->HasSwitch(switches::kLoadExtension)) { FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension); extensions_service_->LoadExtension(path); - - // Tell UserScriptMaser to watch this extension's directory for changes so - // you can live edit content scripts during development. - user_script_master_->AddWatchedPath(path); } } |