| 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/timer.h" | 8 #include "base/timer.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 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Rect; | 14 class Rect; |
| 15 } | 15 } |
| 16 | 16 |
| 17 class TransportDIB; | 17 class TransportDIB; |
| 18 | 18 |
| 19 // Represents the renderer end of the browser<->renderer connection. The | 19 // Represents the renderer end of the browser<->renderer connection. The |
| 20 // opposite end is the RenderProcessHost. This is a singleton object for | 20 // opposite end is the RenderProcessHost. This is a singleton object for |
| 21 // each renderer. | 21 // each renderer. |
| 22 class RenderProcess : public ChildProcess { | 22 class RenderProcess : public ChildProcess { |
| 23 public: | 23 public: |
| 24 // This constructor grabs the channel name from the command line arguments. | |
| 25 RenderProcess(); | 24 RenderProcess(); |
| 26 // This constructor uses the given channel name. | |
| 27 RenderProcess(const std::string& channel_name); | |
| 28 | |
| 29 ~RenderProcess(); | 25 ~RenderProcess(); |
| 30 | 26 |
| 31 // Get a canvas suitable for drawing and transporting to the browser | 27 // Get a canvas suitable for drawing and transporting to the browser |
| 32 // memory: (output) the transport DIB memory | 28 // memory: (output) the transport DIB memory |
| 33 // rect: the rectangle which will be painted, use for sizing the canvas | 29 // rect: the rectangle which will be painted, use for sizing the canvas |
| 34 // returns: NULL on error | 30 // returns: NULL on error |
| 35 // | 31 // |
| 36 // When no longer needed, you should pass the TransportDIB to | 32 // When no longer needed, you should pass the TransportDIB to |
| 37 // ReleaseTransportDIB so that it can be recycled. | 33 // ReleaseTransportDIB so that it can be recycled. |
| 38 skia::PlatformCanvas* GetDrawingCanvas( | 34 skia::PlatformCanvas* GetDrawingCanvas( |
| 39 TransportDIB** memory, const gfx::Rect& rect); | 35 TransportDIB** memory, const gfx::Rect& rect); |
| 40 | 36 |
| 41 // Frees shared memory allocated by AllocSharedMemory. You should only use | 37 // Frees shared memory allocated by AllocSharedMemory. You should only use |
| 42 // this function to free the SharedMemory object. | 38 // this function to free the SharedMemory object. |
| 43 void ReleaseTransportDIB(TransportDIB* memory); | 39 void ReleaseTransportDIB(TransportDIB* memory); |
| 44 | 40 |
| 45 // Returns true if plugins should be loaded in-process. | 41 // Returns true if plugins should be loaded in-process. |
| 46 bool in_process_plugins() const { return in_process_plugins_; } | 42 bool in_process_plugins() const { return in_process_plugins_; } |
| 47 | 43 |
| 48 bool initialized_media_library() const { return initialized_media_library_; } | 44 bool initialized_media_library() const { return initialized_media_library_; } |
| 49 | 45 |
| 50 // Returns a pointer to the RenderProcess singleton instance. | 46 // Returns a pointer to the RenderProcess singleton instance. |
| 51 static RenderProcess* current() { | 47 static RenderProcess* current() { |
| 52 return static_cast<RenderProcess*>(ChildProcess::current()); | 48 return static_cast<RenderProcess*>(ChildProcess::current()); |
| 53 } | 49 } |
| 54 | 50 |
| 55 protected: | |
| 56 friend class RenderThread; | |
| 57 // Just like in_process_plugins(), but called before RenderProcess is created. | 51 // Just like in_process_plugins(), but called before RenderProcess is created. |
| 58 static bool InProcessPlugins(); | 52 static bool InProcessPlugins(); |
| 59 | 53 |
| 60 private: | 54 private: |
| 61 void Init(); | |
| 62 | |
| 63 // Look in the shared memory cache for a suitable object to reuse. | 55 // Look in the shared memory cache for a suitable object to reuse. |
| 64 // result: (output) the memory found | 56 // result: (output) the memory found |
| 65 // size: the resulting memory will be >= this size, in bytes | 57 // size: the resulting memory will be >= this size, in bytes |
| 66 // returns: false if a suitable DIB memory could not be found | 58 // returns: false if a suitable DIB memory could not be found |
| 67 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); | 59 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); |
| 68 | 60 |
| 69 // Maybe put the given shared memory into the shared memory cache. Returns | 61 // Maybe put the given shared memory into the shared memory cache. Returns |
| 70 // true if the SharedMemory object was stored in the cache; otherwise, false | 62 // true if the SharedMemory object was stored in the cache; otherwise, false |
| 71 // is returned. | 63 // is returned. |
| 72 bool PutSharedMemInCache(TransportDIB* memory); | 64 bool PutSharedMemInCache(TransportDIB* memory); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 93 // TransportDIB sequence number | 85 // TransportDIB sequence number |
| 94 uint32 sequence_number_; | 86 uint32 sequence_number_; |
| 95 | 87 |
| 96 bool in_process_plugins_; | 88 bool in_process_plugins_; |
| 97 bool initialized_media_library_; | 89 bool initialized_media_library_; |
| 98 | 90 |
| 99 DISALLOW_COPY_AND_ASSIGN(RenderProcess); | 91 DISALLOW_COPY_AND_ASSIGN(RenderProcess); |
| 100 }; | 92 }; |
| 101 | 93 |
| 102 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ | 94 #endif // CHROME_RENDERER_RENDER_PROCESS_H__ |
| OLD | NEW |