| Index: chrome/renderer/render_process.h
|
| diff --git a/chrome/renderer/render_process.h b/chrome/renderer/render_process.h
|
| index 6ba090526ca809d3a3e9dc6f4beb813469a913ec..9c4cabe121f89d5471349e2b678749f52f8fa5cc 100644
|
| --- a/chrome/renderer/render_process.h
|
| +++ b/chrome/renderer/render_process.h
|
| @@ -5,13 +5,17 @@
|
| #ifndef CHROME_RENDERER_RENDER_PROCESS_H__
|
| #define CHROME_RENDERER_RENDER_PROCESS_H__
|
|
|
| +#include "base/timer.h"
|
| #include "chrome/common/child_process.h"
|
| #include "chrome/renderer/render_thread.h"
|
| +#include "skia/ext/platform_canvas.h"
|
|
|
| -namespace base {
|
| - class SharedMemory;
|
| +namespace gfx {
|
| +class Rect;
|
| }
|
|
|
| +class TransportDIB;
|
| +
|
| // Represents the renderer end of the browser<->renderer connection. The
|
| // opposite end is the RenderProcessHost. This is a singleton object for
|
| // each renderer.
|
| @@ -23,19 +27,19 @@ class RenderProcess : public ChildProcess {
|
| // Returns true if plugins should be loaded in-process.
|
| static bool ShouldLoadPluginsInProcess();
|
|
|
| - // Allocates shared memory. When no longer needed, you should pass the
|
| - // SharedMemory pointer to FreeSharedMemory so it can be recycled. The size
|
| - // reported in the resulting SharedMemory object will be greater than or
|
| - // equal to the requested size. This method returns NULL if unable to
|
| - // allocate memory for some reason.
|
| - static base::SharedMemory* AllocSharedMemory(size_t size);
|
| + // Get a canvas suitable for drawing and transporting to the browser
|
| + // memory: (output) the transport DIB memory
|
| + // rect: the rectangle which will be painted, use for sizing the canvas
|
| + // returns: NULL on error
|
| + //
|
| + // When no longer needed, you should pass the TransportDIB to
|
| + // ReleaseTransportDIB so that it can be recycled.
|
| + static skia::PlatformCanvas* GetDrawingCanvas(
|
| + TransportDIB** memory, const gfx::Rect& rect);
|
|
|
| // Frees shared memory allocated by AllocSharedMemory. You should only use
|
| // this function to free the SharedMemory object.
|
| - static void FreeSharedMemory(base::SharedMemory* mem);
|
| -
|
| - // Deletes the shared memory allocated by AllocSharedMemory.
|
| - static void DeleteSharedMem(base::SharedMemory* mem);
|
| + static void ReleaseTransportDIB(TransportDIB* memory);
|
|
|
| private:
|
| friend class ChildProcessFactory<RenderProcess>;
|
| @@ -50,21 +54,28 @@ class RenderProcess : public ChildProcess {
|
|
|
| static ChildProcess* ClassFactory(const std::wstring& channel_name);
|
|
|
| - // Look in the shared memory cache for a suitable object to reuse. Returns
|
| - // NULL if there is none.
|
| - base::SharedMemory* GetSharedMemFromCache(size_t size);
|
| + // Look in the shared memory cache for a suitable object to reuse.
|
| + // result: (output) the memory found
|
| + // size: the resulting memory will be >= this size, in bytes
|
| + // returns: false if a suitable DIB memory could not be found
|
| + bool GetTransportDIBFromCache(TransportDIB** result, size_t size);
|
|
|
| - // Maybe put the given shared memory into the shared memory cache. Returns
|
| + // Maybe put the given shared memory into the shared memory cache. Returns
|
| // true if the SharedMemory object was stored in the cache; otherwise, false
|
| // is returned.
|
| - bool PutSharedMemInCache(base::SharedMemory* mem);
|
| + bool PutSharedMemInCache(TransportDIB* memory);
|
|
|
| - void ClearSharedMemCache();
|
| + void ClearTransportDIBCache();
|
|
|
| - // We want to lazily clear the shared memory cache if no one has requested
|
| - // memory. This methods are used to schedule a deferred call to
|
| - // RenderProcess::ClearSharedMemCache.
|
| - void ScheduleCacheClearer();
|
| + // Return the index of a free cache slot in which to install a transport DIB
|
| + // of the given size. If all entries in the cache are larger than the given
|
| + // size, this doesn't free any slots and returns -1.
|
| + int FindFreeCacheSlot(size_t size);
|
| +
|
| + // Create a new transport DIB of, at least, the given size. Return NULL on
|
| + // error.
|
| + TransportDIB* CreateTransportDIB(size_t size);
|
| + void FreeTransportDIB(TransportDIB*);
|
|
|
| // ChildProcess implementation
|
| virtual void Cleanup();
|
| @@ -74,10 +85,13 @@ class RenderProcess : public ChildProcess {
|
|
|
| // A very simplistic and small cache. If an entry in this array is non-null,
|
| // then it points to a SharedMemory object that is available for reuse.
|
| - base::SharedMemory* shared_mem_cache_[2];
|
| + TransportDIB* shared_mem_cache_[2];
|
| +
|
| + // This DelayTimer cleans up our cache 5 seconds after the last use.
|
| + base::DelayTimer<RenderProcess> shared_mem_cache_cleaner_;
|
|
|
| - // This factory is used to lazily invoke ClearSharedMemCache.
|
| - ScopedRunnableMethodFactory<RenderProcess> clearer_factory_;
|
| + // TransportDIB sequence number
|
| + uint32 sequence_number_;
|
|
|
| static bool load_plugins_in_process_;
|
|
|
|
|