| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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_RENDERER_RENDER_PROCESS_H__ | 5 #ifndef CHROME_RENDERER_RENDER_PROCESS_H__ |
| 6 #define CHROME_RENDERER_RENDER_PROCESS_H__ | 6 #define CHROME_RENDERER_RENDER_PROCESS_H__ |
| 7 | 7 |
| 8 #include <objidl.h> | 8 #include <objidl.h> |
| 9 #include <mlang.h> | 9 #include <mlang.h> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 static void GlobalCleanup(); | 23 static void GlobalCleanup(); |
| 24 | 24 |
| 25 // Returns true if plugins should be loaded in-process. | 25 // Returns true if plugins should be loaded in-process. |
| 26 static bool ShouldLoadPluginsInProcess(); | 26 static bool ShouldLoadPluginsInProcess(); |
| 27 | 27 |
| 28 // Allocates shared memory. When no longer needed, you should pass the | 28 // Allocates shared memory. When no longer needed, you should pass the |
| 29 // SharedMemory pointer to FreeSharedMemory so it can be recycled. The size | 29 // SharedMemory pointer to FreeSharedMemory so it can be recycled. The size |
| 30 // reported in the resulting SharedMemory object will be greater than or | 30 // reported in the resulting SharedMemory object will be greater than or |
| 31 // equal to the requested size. This method returns NULL if unable to | 31 // equal to the requested size. This method returns NULL if unable to |
| 32 // allocate memory for some reason. | 32 // allocate memory for some reason. |
| 33 static SharedMemory* AllocSharedMemory(size_t size); | 33 static base::SharedMemory* AllocSharedMemory(size_t size); |
| 34 | 34 |
| 35 // Frees shared memory allocated by AllocSharedMemory. You should only use | 35 // Frees shared memory allocated by AllocSharedMemory. You should only use |
| 36 // this function to free the SharedMemory object. | 36 // this function to free the SharedMemory object. |
| 37 static void FreeSharedMemory(SharedMemory* mem); | 37 static void FreeSharedMemory(base::SharedMemory* mem); |
| 38 | 38 |
| 39 // Deletes the shared memory allocated by AllocSharedMemory. | 39 // Deletes the shared memory allocated by AllocSharedMemory. |
| 40 static void DeleteSharedMem(SharedMemory* mem); | 40 static void DeleteSharedMem(base::SharedMemory* mem); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 friend class ChildProcessFactory<RenderProcess>; | 43 friend class ChildProcessFactory<RenderProcess>; |
| 44 RenderProcess(const std::wstring& channel_name); | 44 RenderProcess(const std::wstring& channel_name); |
| 45 ~RenderProcess(); | 45 ~RenderProcess(); |
| 46 | 46 |
| 47 // Returns a pointer to the RenderProcess singleton instance. This is | 47 // Returns a pointer to the RenderProcess singleton instance. This is |
| 48 // guaranteed to be non-NULL between calls to GlobalInit and GlobalCleanup. | 48 // guaranteed to be non-NULL between calls to GlobalInit and GlobalCleanup. |
| 49 static RenderProcess* self() { | 49 static RenderProcess* self() { |
| 50 return static_cast<RenderProcess*>(child_process_); | 50 return static_cast<RenderProcess*>(child_process_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 static ChildProcess* ClassFactory(const std::wstring& channel_name); | 53 static ChildProcess* ClassFactory(const std::wstring& channel_name); |
| 54 | 54 |
| 55 // Look in the shared memory cache for a suitable object to reuse. Returns | 55 // Look in the shared memory cache for a suitable object to reuse. Returns |
| 56 // NULL if there is none. | 56 // NULL if there is none. |
| 57 SharedMemory* GetSharedMemFromCache(size_t size); | 57 base::SharedMemory* GetSharedMemFromCache(size_t size); |
| 58 | 58 |
| 59 // Maybe put the given shared memory into the shared memory cache. Returns | 59 // Maybe put the given shared memory into the shared memory cache. Returns |
| 60 // true if the SharedMemory object was stored in the cache; otherwise, false | 60 // true if the SharedMemory object was stored in the cache; otherwise, false |
| 61 // is returned. | 61 // is returned. |
| 62 bool PutSharedMemInCache(SharedMemory* mem); | 62 bool PutSharedMemInCache(base::SharedMemory* mem); |
| 63 | 63 |
| 64 void ClearSharedMemCache(); | 64 void ClearSharedMemCache(); |
| 65 | 65 |
| 66 // We want to lazily clear the shared memory cache if no one has requested | 66 // We want to lazily clear the shared memory cache if no one has requested |
| 67 // memory. This methods are used to schedule a deferred call to | 67 // memory. This methods are used to schedule a deferred call to |
| 68 // RenderProcess::ClearSharedMemCache. | 68 // RenderProcess::ClearSharedMemCache. |
| 69 void ScheduleCacheClearer(); | 69 void ScheduleCacheClearer(); |
| 70 | 70 |
| 71 // ChildProcess implementation | 71 // ChildProcess implementation |
| 72 virtual void Cleanup(); | 72 virtual void Cleanup(); |
| 73 | 73 |
| 74 // The one render thread (to be replaced with a set of render threads). | 74 // The one render thread (to be replaced with a set of render threads). |
| 75 RenderThread render_thread_; | 75 RenderThread render_thread_; |
| 76 | 76 |
| 77 // A very simplistic and small cache. If an entry in this array is non-null, | 77 // A very simplistic and small cache. If an entry in this array is non-null, |
| 78 // then it points to a SharedMemory object that is available for reuse. | 78 // then it points to a SharedMemory object that is available for reuse. |
| 79 SharedMemory* shared_mem_cache_[2]; | 79 base::SharedMemory* shared_mem_cache_[2]; |
| 80 | 80 |
| 81 // This factory is used to lazily invoke ClearSharedMemCache. | 81 // This factory is used to lazily invoke ClearSharedMemCache. |
| 82 ScopedRunnableMethodFactory<RenderProcess> clearer_factory_; | 82 ScopedRunnableMethodFactory<RenderProcess> clearer_factory_; |
| 83 | 83 |
| 84 static bool load_plugins_in_process_; | 84 static bool load_plugins_in_process_; |
| 85 | 85 |
| 86 DISALLOW_EVIL_CONSTRUCTORS(RenderProcess); | 86 DISALLOW_EVIL_CONSTRUCTORS(RenderProcess); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ | 89 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ |
| 90 | 90 |
| OLD | NEW |