| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ |
| 6 #define CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "content/renderer/render_process.h" | 9 #include "content/renderer/render_process.h" |
| 10 | 10 |
| 11 class SkCanvas; | 11 class SkCanvas; |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Implementation of the RenderProcess interface for the regular browser. | 15 // Implementation of the RenderProcess interface for the regular browser. |
| 16 // See also MockRenderProcess which implements the active "RenderProcess" when | 16 // See also MockRenderProcess which implements the active "RenderProcess" when |
| 17 // running under certain unit tests. | 17 // running under certain unit tests. |
| 18 class RenderProcessImpl : public RenderProcess { | 18 class RenderProcessImpl : public RenderProcess { |
| 19 public: | 19 public: |
| 20 RenderProcessImpl(); | 20 RenderProcessImpl(); |
| 21 virtual ~RenderProcessImpl(); | 21 virtual ~RenderProcessImpl(); |
| 22 | 22 |
| 23 // RenderProcess implementation. | 23 // RenderProcess implementation. |
| 24 virtual SkCanvas* GetDrawingCanvas( | |
| 25 TransportDIB** memory, | |
| 26 const gfx::Rect& rect) OVERRIDE; | |
| 27 virtual void ReleaseTransportDIB(TransportDIB* memory) OVERRIDE; | |
| 28 virtual void AddBindings(int bindings) OVERRIDE; | 24 virtual void AddBindings(int bindings) OVERRIDE; |
| 29 virtual int GetEnabledBindings() const OVERRIDE; | 25 virtual int GetEnabledBindings() const OVERRIDE; |
| 30 virtual TransportDIB* CreateTransportDIB(size_t size) OVERRIDE; | |
| 31 virtual void FreeTransportDIB(TransportDIB*) OVERRIDE; | |
| 32 | 26 |
| 33 private: | 27 private: |
| 34 // Look in the shared memory cache for a suitable object to reuse. | |
| 35 // result: (output) the memory found | |
| 36 // size: the resulting memory will be >= this size, in bytes | |
| 37 // returns: false if a suitable DIB memory could not be found | |
| 38 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); | |
| 39 | |
| 40 // Maybe put the given shared memory into the shared memory cache. Returns | |
| 41 // true if the SharedMemory object was stored in the cache; otherwise, false | |
| 42 // is returned. | |
| 43 bool PutSharedMemInCache(TransportDIB* memory); | |
| 44 | |
| 45 void ClearTransportDIBCache(); | |
| 46 | |
| 47 // Return the index of a free cache slot in which to install a transport DIB | |
| 48 // of the given size. If all entries in the cache are larger than the given | |
| 49 // size, this doesn't free any slots and returns -1. | |
| 50 int FindFreeCacheSlot(size_t size); | |
| 51 | |
| 52 // A very simplistic and small cache. If an entry in this array is non-null, | |
| 53 // then it points to a SharedMemory object that is available for reuse. | |
| 54 TransportDIB* shared_mem_cache_[2]; | |
| 55 | |
| 56 // This DelayTimer cleans up our cache 5 seconds after the last use. | |
| 57 base::DelayTimer<RenderProcessImpl> shared_mem_cache_cleaner_; | |
| 58 | |
| 59 // TransportDIB sequence number | |
| 60 uint32 transport_dib_next_sequence_number_; | |
| 61 | |
| 62 // Bitwise-ORed set of extra bindings that have been enabled anywhere in this | 28 // Bitwise-ORed set of extra bindings that have been enabled anywhere in this |
| 63 // process. See BindingsPolicy for details. | 29 // process. See BindingsPolicy for details. |
| 64 int enabled_bindings_; | 30 int enabled_bindings_; |
| 65 | 31 |
| 66 DISALLOW_COPY_AND_ASSIGN(RenderProcessImpl); | 32 DISALLOW_COPY_AND_ASSIGN(RenderProcessImpl); |
| 67 }; | 33 }; |
| 68 | 34 |
| 69 } // namespace content | 35 } // namespace content |
| 70 | 36 |
| 71 #endif // CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ | 37 #endif // CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ |
| OLD | NEW |