| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_RENDERER_RENDER_PROCESS_IMPL_H_ | |
| 6 #define CHROME_RENDERER_RENDER_PROCESS_IMPL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/timer.h" | |
| 10 #include "chrome/renderer/render_process.h" | |
| 11 #include "native_client/src/shared/imc/nacl_imc.h" | |
| 12 | |
| 13 namespace skia { | |
| 14 class PlatformCanvas; | |
| 15 } | |
| 16 | |
| 17 // Implementation of the RenderProcess interface for the regular browser. | |
| 18 // See also MockRenderProcess which implements the active "RenderProcess" when | |
| 19 // running under certain unit tests. | |
| 20 class RenderProcessImpl : public RenderProcess { | |
| 21 public: | |
| 22 RenderProcessImpl(); | |
| 23 ~RenderProcessImpl(); | |
| 24 | |
| 25 // RenderProcess implementation. | |
| 26 virtual skia::PlatformCanvas* GetDrawingCanvas(TransportDIB** memory, | |
| 27 const gfx::Rect& rect); | |
| 28 virtual void ReleaseTransportDIB(TransportDIB* memory); | |
| 29 virtual bool UseInProcessPlugins() const; | |
| 30 virtual bool HasInitializedMediaLibrary() const; | |
| 31 | |
| 32 // Like UseInProcessPlugins(), but called before RenderProcess is created | |
| 33 // and does not allow overriding by tests. This just checks the command line | |
| 34 // each time. | |
| 35 static bool InProcessPlugins(); | |
| 36 | |
| 37 private: | |
| 38 // Look in the shared memory cache for a suitable object to reuse. | |
| 39 // result: (output) the memory found | |
| 40 // size: the resulting memory will be >= this size, in bytes | |
| 41 // returns: false if a suitable DIB memory could not be found | |
| 42 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); | |
| 43 | |
| 44 // Maybe put the given shared memory into the shared memory cache. Returns | |
| 45 // true if the SharedMemory object was stored in the cache; otherwise, false | |
| 46 // is returned. | |
| 47 bool PutSharedMemInCache(TransportDIB* memory); | |
| 48 | |
| 49 void ClearTransportDIBCache(); | |
| 50 | |
| 51 // Return the index of a free cache slot in which to install a transport DIB | |
| 52 // of the given size. If all entries in the cache are larger than the given | |
| 53 // size, this doesn't free any slots and returns -1. | |
| 54 int FindFreeCacheSlot(size_t size); | |
| 55 | |
| 56 // Create a new transport DIB of, at least, the given size. Return NULL on | |
| 57 // error. | |
| 58 TransportDIB* CreateTransportDIB(size_t size); | |
| 59 void FreeTransportDIB(TransportDIB*); | |
| 60 | |
| 61 // A very simplistic and small cache. If an entry in this array is non-null, | |
| 62 // then it points to a SharedMemory object that is available for reuse. | |
| 63 TransportDIB* shared_mem_cache_[2]; | |
| 64 | |
| 65 // This DelayTimer cleans up our cache 5 seconds after the last use. | |
| 66 base::DelayTimer<RenderProcessImpl> shared_mem_cache_cleaner_; | |
| 67 | |
| 68 // TransportDIB sequence number | |
| 69 uint32 transport_dib_next_sequence_number_; | |
| 70 | |
| 71 bool in_process_plugins_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(RenderProcessImpl); | |
| 74 }; | |
| 75 | |
| 76 #endif // CHROME_RENDERER_RENDER_PROCESS_IMPL_H_ | |
| OLD | NEW |