| 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 "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/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/process.h" | 11 #include "base/process.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 "base/string_piece.h" | 14 #include "base/string_piece.h" |
| 15 #include "googleurl/src/gurl.h" | |
| 16 | |
| 17 struct UserScriptInfo { | |
| 18 GURL url; | |
| 19 FilePath path; | |
| 20 std::vector<std::string> matches; | |
| 21 }; | |
| 22 typedef std::vector<UserScriptInfo> UserScriptList; | |
| 23 | 15 |
| 24 // Manages a segment of shared memory that contains the user scripts the user | 16 // Manages a segment of shared memory that contains the user scripts the user |
| 25 // has installed. Lives on the UI thread. | 17 // has installed. Lives on the UI thread. |
| 26 class UserScriptMaster : public base::RefCounted<UserScriptMaster>, | 18 class UserScriptMaster : public base::RefCounted<UserScriptMaster>, |
| 27 public DirectoryWatcher::Delegate { | 19 public DirectoryWatcher::Delegate { |
| 28 public: | 20 public: |
| 29 // For testability, the constructor takes the MessageLoop to run the | 21 // For testability, the constructor takes the MessageLoop to run the |
| 30 // 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. |
| 31 // 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. |
| 32 UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); | 24 UserScriptMaster(MessageLoop* worker, const FilePath& script_dir); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 128 |
| 137 // If the script directory is modified while we're rescanning it, we note | 129 // If the script directory is modified while we're rescanning it, we note |
| 138 // that we're currently mid-scan and then start over again once the scan | 130 // that we're currently mid-scan and then start over again once the scan |
| 139 // finishes. This boolean tracks whether another scan is pending. | 131 // finishes. This boolean tracks whether another scan is pending. |
| 140 bool pending_scan_; | 132 bool pending_scan_; |
| 141 | 133 |
| 142 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); | 134 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); |
| 143 }; | 135 }; |
| 144 | 136 |
| 145 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ | 137 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ |
| OLD | NEW |