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" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #include "chrome/common/extensions/user_script.h" | 14 #include "chrome/common/extensions/user_script.h" |
15 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
16 #include "testing/gtest/include/gtest/gtest_prod.h" | 16 #include "testing/gtest/include/gtest/gtest_prod.h" |
17 | 17 |
18 class MessageLoop; | 18 class MessageLoop; |
19 class StringPiece; | 19 class StringPiece; |
20 | 20 |
21 // Manages a segment of shared memory that contains the user scripts the user | 21 // Manages a segment of shared memory that contains the user scripts the user |
22 // has installed. Lives on the UI thread. | 22 // has installed. Lives on the UI thread. |
23 class UserScriptMaster : public base::RefCounted<UserScriptMaster>, | 23 class UserScriptMaster : public base::RefCountedThreadSafe<UserScriptMaster>, |
24 public DirectoryWatcher::Delegate, | 24 public DirectoryWatcher::Delegate, |
25 public NotificationObserver { | 25 public NotificationObserver { |
26 public: | 26 public: |
27 // For testability, the constructor takes the MessageLoop to run the | 27 // For testability, the constructor takes the MessageLoop to run the |
28 // script-reloading worker on as well as the path the scripts live in. | 28 // script-reloading worker on as well as the path the scripts live in. |
29 // These are normally the file thread and a directory inside the profile. | 29 // These are normally the file thread and a directory inside the profile. |
30 UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); | 30 UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); |
31 ~UserScriptMaster(); | 31 ~UserScriptMaster(); |
32 | 32 |
33 // Add a watched directory. All scripts will be reloaded when any file in | 33 // Add a watched directory. All scripts will be reloaded when any file in |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 // If the script directory is modified while we're rescanning it, we note | 155 // If the script directory is modified while we're rescanning it, we note |
156 // that we're currently mid-scan and then start over again once the scan | 156 // that we're currently mid-scan and then start over again once the scan |
157 // finishes. This boolean tracks whether another scan is pending. | 157 // finishes. This boolean tracks whether another scan is pending. |
158 bool pending_scan_; | 158 bool pending_scan_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); | 160 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); |
161 }; | 161 }; |
162 | 162 |
163 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 163 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
OLD | NEW |