| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/directory_watcher.h" | 10 #include "base/directory_watcher.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 FilePath user_script_dir() const { return user_script_dir_; } | 54 FilePath user_script_dir() const { return user_script_dir_; } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 FRIEND_TEST(UserScriptMasterTest, Parse1); | 57 FRIEND_TEST(UserScriptMasterTest, Parse1); |
| 58 FRIEND_TEST(UserScriptMasterTest, Parse2); | 58 FRIEND_TEST(UserScriptMasterTest, Parse2); |
| 59 FRIEND_TEST(UserScriptMasterTest, Parse3); | 59 FRIEND_TEST(UserScriptMasterTest, Parse3); |
| 60 FRIEND_TEST(UserScriptMasterTest, Parse4); | 60 FRIEND_TEST(UserScriptMasterTest, Parse4); |
| 61 FRIEND_TEST(UserScriptMasterTest, Parse5); | 61 FRIEND_TEST(UserScriptMasterTest, Parse5); |
| 62 FRIEND_TEST(UserScriptMasterTest, Parse6); | 62 FRIEND_TEST(UserScriptMasterTest, Parse6); |
| 63 | 63 |
| 64 public: |
| 64 // We reload user scripts on the file thread to prevent blocking the UI. | 65 // We reload user scripts on the file thread to prevent blocking the UI. |
| 65 // ScriptReloader lives on the file thread and does the reload | 66 // ScriptReloader lives on the file thread and does the reload |
| 66 // work, and then sends a message back to its master with a new SharedMemory*. | 67 // work, and then sends a message back to its master with a new SharedMemory*. |
| 67 // ScriptReloader is the worker that manages running the script scan | 68 // ScriptReloader is the worker that manages running the script scan |
| 68 // on the file thread. It must be created on, and its public API must only be | 69 // on the file thread. It must be created on, and its public API must only be |
| 69 // called from, the master's thread. | 70 // called from, the master's thread. |
| 70 class ScriptReloader | 71 class ScriptReloader |
| 71 : public base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader> { | 72 : public base::RefCountedThreadSafe<UserScriptMaster::ScriptReloader> { |
| 72 public: | 73 public: |
| 73 // Parses the includes out of |script| and returns them in |includes|. | 74 // Parses the includes out of |script| and returns them in |includes|. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // May be NULL if DisownMaster() is called. | 112 // May be NULL if DisownMaster() is called. |
| 112 UserScriptMaster* master_; | 113 UserScriptMaster* master_; |
| 113 | 114 |
| 114 // The message loop to call our master back on. | 115 // The message loop to call our master back on. |
| 115 // Expected to always outlive us. | 116 // Expected to always outlive us. |
| 116 ChromeThread::ID master_thread_id_; | 117 ChromeThread::ID master_thread_id_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); | 119 DISALLOW_COPY_AND_ASSIGN(ScriptReloader); |
| 119 }; | 120 }; |
| 120 | 121 |
| 122 private: |
| 121 // DirectoryWatcher::Delegate implementation. | 123 // DirectoryWatcher::Delegate implementation. |
| 122 virtual void OnDirectoryChanged(const FilePath& path); | 124 virtual void OnDirectoryChanged(const FilePath& path); |
| 123 | 125 |
| 124 // NotificationObserver implementation. | 126 // NotificationObserver implementation. |
| 125 virtual void Observe(NotificationType type, | 127 virtual void Observe(NotificationType type, |
| 126 const NotificationSource& source, | 128 const NotificationSource& source, |
| 127 const NotificationDetails& details); | 129 const NotificationDetails& details); |
| 128 | 130 |
| 129 // Manages our notification registrations. | 131 // Manages our notification registrations. |
| 130 NotificationRegistrar registrar_; | 132 NotificationRegistrar registrar_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 | 153 |
| 152 // If the script directory is modified while we're rescanning it, we note | 154 // If the script directory is modified while we're rescanning it, we note |
| 153 // that we're currently mid-scan and then start over again once the scan | 155 // that we're currently mid-scan and then start over again once the scan |
| 154 // finishes. This boolean tracks whether another scan is pending. | 156 // finishes. This boolean tracks whether another scan is pending. |
| 155 bool pending_scan_; | 157 bool pending_scan_; |
| 156 | 158 |
| 157 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); | 159 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); |
| 158 }; | 160 }; |
| 159 | 161 |
| 160 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
| OLD | NEW |