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