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_GREASEMONKEY_MASTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
6 #define CHROME_BROWSER_GREASEMONKEY_MASTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
7 | 7 |
8 #include "base/directory_watcher.h" | 8 #include "base/directory_watcher.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
13 | 13 |
14 class MessageLoop; | 14 class MessageLoop; |
15 | 15 |
16 // Manages a segment of shared memory that contains the Greasemonkey scripts the | 16 // Manages a segment of shared memory that contains the user scripts the user |
17 // user has installed. Lives on the UI thread. | 17 // has installed. Lives on the UI thread. |
18 class GreasemonkeyMaster : public base::RefCounted<GreasemonkeyMaster>, | 18 class UserScriptMaster : public base::RefCounted<UserScriptMaster>, |
19 public DirectoryWatcher::Delegate { | 19 public DirectoryWatcher::Delegate { |
20 public: | 20 public: |
21 // For testability, the constructor takes the MessageLoop to run the | 21 // For testability, the constructor takes the MessageLoop to run the |
22 // script-reloading worker on as well as the path the scripts live in. | 22 // script-reloading worker on as well as the path the scripts live in. |
23 // These are normally the file thread and a directory inside the profile. | 23 // These are normally the file thread and a directory inside the profile. |
24 GreasemonkeyMaster(MessageLoop* worker, const FilePath& script_dir); | 24 UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); |
25 ~GreasemonkeyMaster(); | 25 ~UserScriptMaster(); |
26 | 26 |
27 // Gets the segment of shared memory for the scripts. | 27 // Gets the segment of shared memory for the scripts. |
28 base::SharedMemory* GetSharedMemory() const { | 28 base::SharedMemory* GetSharedMemory() const { |
29 return shared_memory_.get(); | 29 return shared_memory_.get(); |
30 } | 30 } |
31 | 31 |
32 // Called by the script reloader when new scripts have been loaded. | 32 // Called by the script reloader when new scripts have been loaded. |
33 void NewScriptsAvailable(base::SharedMemory* handle); | 33 void NewScriptsAvailable(base::SharedMemory* handle); |
34 | 34 |
35 // Return true if we have any scripts ready. | 35 // Return true if we have any scripts ready. |
(...skipping 27 matching lines...) Expand all Loading... |
63 scoped_refptr<ScriptReloader> script_reloader_; | 63 scoped_refptr<ScriptReloader> script_reloader_; |
64 | 64 |
65 // Contains the scripts that were found the last time scripts were updated. | 65 // Contains the scripts that were found the last time scripts were updated. |
66 scoped_ptr<base::SharedMemory> shared_memory_; | 66 scoped_ptr<base::SharedMemory> shared_memory_; |
67 | 67 |
68 // If the script directory is modified while we're rescanning it, we note | 68 // If the script directory is modified while we're rescanning it, we note |
69 // that we're currently mid-scan and then start over again once the scan | 69 // that we're currently mid-scan and then start over again once the scan |
70 // finishes. This boolean tracks whether another scan is pending. | 70 // finishes. This boolean tracks whether another scan is pending. |
71 bool pending_scan_; | 71 bool pending_scan_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(GreasemonkeyMaster); | 73 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); |
74 }; | 74 }; |
75 | 75 |
76 #endif // CHROME_BROWSER_GREASEMONKEY_MASTER_H_ | 76 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
OLD | NEW |