OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_GREASEMONKEY_MASTER_H__ |
| 6 #define CHROME_BROWSER_GREASEMONKEY_MASTER_H__ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/process.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "base/shared_memory.h" |
| 13 |
| 14 // Manages a segment of shared memory that contains the Greasemonkey scripts the |
| 15 // user has installed. |
| 16 class GreasemonkeyMaster { |
| 17 public: |
| 18 GreasemonkeyMaster() |
| 19 : shared_memory_serial_(0) {} |
| 20 |
| 21 // Reloads scripts from disk into a new chunk of shared memory and notifies |
| 22 // renderers. |
| 23 bool UpdateScripts(); |
| 24 |
| 25 // Creates a handle to the shared memory that can be used in the specified |
| 26 // process. |
| 27 bool ShareToProcess(ProcessHandle process, SharedMemoryHandle* new_handle); |
| 28 |
| 29 // Gets the segment of shared memory for the scripts. |
| 30 SharedMemory* GetSharedMemory() const { |
| 31 return shared_memory_.get(); |
| 32 } |
| 33 |
| 34 private: |
| 35 // Contains the scripts that were found the last time UpdateScripts() was |
| 36 // called. |
| 37 scoped_ptr<SharedMemory> shared_memory_; |
| 38 |
| 39 // A counter that is incremented each time a new shared memory segment is |
| 40 // created. This is used to uniquely identify segments created at different |
| 41 // times by this class. |
| 42 int shared_memory_serial_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(GreasemonkeyMaster); |
| 45 }; |
| 46 |
| 47 #endif // CHROME_BROWSER_GREASEMONKEY_MASTER_H__ |
OLD | NEW |