| 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 "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "chrome/common/child_process.h" | 9 #include "chrome/common/child_process.h" |
| 10 #include "chrome/renderer/render_thread.h" | 10 #include "chrome/renderer/render_thread.h" |
| 11 | 11 |
| 12 class RenderView; | |
| 13 | |
| 14 // Represents the renderer end of the browser<->renderer connection. The | 12 // Represents the renderer end of the browser<->renderer connection. The |
| 15 // opposite end is the RenderProcessHost. This is a singleton object for | 13 // opposite end is the RenderProcessHost. This is a singleton object for |
| 16 // each renderer. | 14 // each renderer. |
| 17 class RenderProcess : public ChildProcess { | 15 class RenderProcess : public ChildProcess { |
| 18 public: | 16 public: |
| 19 static bool GlobalInit(const std::wstring& channel_name); | 17 static bool GlobalInit(const std::wstring& channel_name); |
| 20 static void GlobalCleanup(); | 18 static void GlobalCleanup(); |
| 21 | 19 |
| 22 // Returns true if plugins should be loaded in-process. | 20 // Returns true if plugins should be loaded in-process. |
| 23 static bool ShouldLoadPluginsInProcess(); | 21 static bool ShouldLoadPluginsInProcess(); |
| 24 | 22 |
| 25 // Allocates shared memory. When no longer needed, you should pass the | 23 // Allocates shared memory. When no longer needed, you should pass the |
| 26 // SharedMemory pointer to FreeSharedMemory so it can be recycled. The size | 24 // SharedMemory pointer to FreeSharedMemory so it can be recycled. The size |
| 27 // reported in the resulting SharedMemory object will be greater than or | 25 // reported in the resulting SharedMemory object will be greater than or |
| 28 // equal to the requested size. This method returns NULL if unable to | 26 // equal to the requested size. This method returns NULL if unable to |
| 29 // allocate memory for some reason. | 27 // allocate memory for some reason. |
| 30 static base::SharedMemory* AllocSharedMemory(size_t size); | 28 static base::SharedMemory* AllocSharedMemory(size_t size); |
| 31 | 29 |
| 32 // Frees shared memory allocated by AllocSharedMemory. You should only use | 30 // Frees shared memory allocated by AllocSharedMemory. You should only use |
| 33 // this function to free the SharedMemory object. | 31 // this function to free the SharedMemory object. |
| 34 static void FreeSharedMemory(base::SharedMemory* mem); | 32 static void FreeSharedMemory(base::SharedMemory* mem); |
| 35 | 33 |
| 36 // Deletes the shared memory allocated by AllocSharedMemory. | 34 // Deletes the shared memory allocated by AllocSharedMemory. |
| 37 static void DeleteSharedMem(base::SharedMemory* mem); | 35 static void DeleteSharedMem(base::SharedMemory* mem); |
| 38 | 36 |
| 39 private: | 37 private: |
| 40 friend class ChildProcessFactory<RenderProcess>; | 38 friend class ChildProcessFactory<RenderProcess>; |
| 41 RenderProcess(const std::wstring& channel_name); | 39 explicit RenderProcess(const std::wstring& channel_name); |
| 42 ~RenderProcess(); | 40 ~RenderProcess(); |
| 43 | 41 |
| 44 // Returns a pointer to the RenderProcess singleton instance. This is | 42 // Returns a pointer to the RenderProcess singleton instance. This is |
| 45 // guaranteed to be non-NULL between calls to GlobalInit and GlobalCleanup. | 43 // guaranteed to be non-NULL between calls to GlobalInit and GlobalCleanup. |
| 46 static RenderProcess* self() { | 44 static RenderProcess* self() { |
| 47 return static_cast<RenderProcess*>(child_process_); | 45 return static_cast<RenderProcess*>(child_process_); |
| 48 } | 46 } |
| 49 | 47 |
| 50 static ChildProcess* ClassFactory(const std::wstring& channel_name); | 48 static ChildProcess* ClassFactory(const std::wstring& channel_name); |
| 51 | 49 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 | 71 |
| 74 // A very simplistic and small cache. If an entry in this array is non-null, | 72 // A very simplistic and small cache. If an entry in this array is non-null, |
| 75 // then it points to a SharedMemory object that is available for reuse. | 73 // then it points to a SharedMemory object that is available for reuse. |
| 76 base::SharedMemory* shared_mem_cache_[2]; | 74 base::SharedMemory* shared_mem_cache_[2]; |
| 77 | 75 |
| 78 // This factory is used to lazily invoke ClearSharedMemCache. | 76 // This factory is used to lazily invoke ClearSharedMemCache. |
| 79 ScopedRunnableMethodFactory<RenderProcess> clearer_factory_; | 77 ScopedRunnableMethodFactory<RenderProcess> clearer_factory_; |
| 80 | 78 |
| 81 static bool load_plugins_in_process_; | 79 static bool load_plugins_in_process_; |
| 82 | 80 |
| 83 DISALLOW_EVIL_CONSTRUCTORS(RenderProcess); | 81 DISALLOW_COPY_AND_ASSIGN(RenderProcess); |
| 84 }; | 82 }; |
| 85 | 83 |
| 86 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ | 84 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ |
| 87 | |
| OLD | NEW |