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( | 24 virtual SkCanvas* GetDrawingCanvas( |
25 TransportDIB** memory, | 25 TransportDIB** memory, |
26 const gfx::Rect& rect) OVERRIDE; | 26 const gfx::Rect& rect) OVERRIDE; |
27 virtual void ReleaseTransportDIB(TransportDIB* memory) OVERRIDE; | 27 virtual void ReleaseTransportDIB(TransportDIB* memory) OVERRIDE; |
28 virtual bool UseInProcessPlugins() const OVERRIDE; | |
29 virtual void AddBindings(int bindings) OVERRIDE; | 28 virtual void AddBindings(int bindings) OVERRIDE; |
30 virtual int GetEnabledBindings() const OVERRIDE; | 29 virtual int GetEnabledBindings() const OVERRIDE; |
31 virtual TransportDIB* CreateTransportDIB(size_t size) OVERRIDE; | 30 virtual TransportDIB* CreateTransportDIB(size_t size) OVERRIDE; |
32 virtual void FreeTransportDIB(TransportDIB*) OVERRIDE; | 31 virtual void FreeTransportDIB(TransportDIB*) OVERRIDE; |
33 | 32 |
34 // Like UseInProcessPlugins(), but called before RenderProcess is created | |
35 // and does not allow overriding by tests. This just checks the command line | |
36 // each time. | |
37 static bool InProcessPlugins(); | |
38 | |
39 private: | 33 private: |
40 // Look in the shared memory cache for a suitable object to reuse. | 34 // Look in the shared memory cache for a suitable object to reuse. |
41 // result: (output) the memory found | 35 // result: (output) the memory found |
42 // size: the resulting memory will be >= this size, in bytes | 36 // size: the resulting memory will be >= this size, in bytes |
43 // returns: false if a suitable DIB memory could not be found | 37 // returns: false if a suitable DIB memory could not be found |
44 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); | 38 bool GetTransportDIBFromCache(TransportDIB** result, size_t size); |
45 | 39 |
46 // Maybe put the given shared memory into the shared memory cache. Returns | 40 // Maybe put the given shared memory into the shared memory cache. Returns |
47 // true if the SharedMemory object was stored in the cache; otherwise, false | 41 // true if the SharedMemory object was stored in the cache; otherwise, false |
48 // is returned. | 42 // is returned. |
49 bool PutSharedMemInCache(TransportDIB* memory); | 43 bool PutSharedMemInCache(TransportDIB* memory); |
50 | 44 |
51 void ClearTransportDIBCache(); | 45 void ClearTransportDIBCache(); |
52 | 46 |
53 // Return the index of a free cache slot in which to install a transport DIB | 47 // Return the index of a free cache slot in which to install a transport DIB |
54 // of the given size. If all entries in the cache are larger than the given | 48 // of the given size. If all entries in the cache are larger than the given |
55 // size, this doesn't free any slots and returns -1. | 49 // size, this doesn't free any slots and returns -1. |
56 int FindFreeCacheSlot(size_t size); | 50 int FindFreeCacheSlot(size_t size); |
57 | 51 |
58 // A very simplistic and small cache. If an entry in this array is non-null, | 52 // A very simplistic and small cache. If an entry in this array is non-null, |
59 // then it points to a SharedMemory object that is available for reuse. | 53 // then it points to a SharedMemory object that is available for reuse. |
60 TransportDIB* shared_mem_cache_[2]; | 54 TransportDIB* shared_mem_cache_[2]; |
61 | 55 |
62 // This DelayTimer cleans up our cache 5 seconds after the last use. | 56 // This DelayTimer cleans up our cache 5 seconds after the last use. |
63 base::DelayTimer<RenderProcessImpl> shared_mem_cache_cleaner_; | 57 base::DelayTimer<RenderProcessImpl> shared_mem_cache_cleaner_; |
64 | 58 |
65 // TransportDIB sequence number | 59 // TransportDIB sequence number |
66 uint32 transport_dib_next_sequence_number_; | 60 uint32 transport_dib_next_sequence_number_; |
67 | 61 |
68 bool in_process_plugins_; | |
69 | |
70 // Bitwise-ORed set of extra bindings that have been enabled anywhere in this | 62 // Bitwise-ORed set of extra bindings that have been enabled anywhere in this |
71 // process. See BindingsPolicy for details. | 63 // process. See BindingsPolicy for details. |
72 int enabled_bindings_; | 64 int enabled_bindings_; |
73 | 65 |
74 DISALLOW_COPY_AND_ASSIGN(RenderProcessImpl); | 66 DISALLOW_COPY_AND_ASSIGN(RenderProcessImpl); |
75 }; | 67 }; |
76 | 68 |
77 } // namespace content | 69 } // namespace content |
78 | 70 |
79 #endif // CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ | 71 #endif // CONTENT_RENDERER_RENDER_PROCESS_IMPL_H_ |
OLD | NEW |