OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHARED_MEMORY_SEQLOCK_READER_H_ | 5 #ifndef CONTENT_RENDERER_SHARED_MEMORY_SEQLOCK_READER_H_ |
6 #define CONTENT_RENDERER_SHARED_MEMORY_SEQLOCK_READER_H_ | 6 #define CONTENT_RENDERER_SHARED_MEMORY_SEQLOCK_READER_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "content/common/shared_memory_seqlock_buffer.h" | 11 #include "content/common/shared_memory_seqlock_buffer.h" |
12 | 12 |
| 13 namespace content { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 class SharedMemorySeqLockReaderBase { | 16 class SharedMemorySeqLockReaderBase { |
16 protected: | 17 protected: |
17 SharedMemorySeqLockReaderBase(); | 18 SharedMemorySeqLockReaderBase(); |
18 virtual ~SharedMemorySeqLockReaderBase(); | 19 virtual ~SharedMemorySeqLockReaderBase(); |
19 | 20 |
20 void* InitializeSharedMemory( | 21 void* InitializeSharedMemory( |
21 base::SharedMemoryHandle shared_memory_handle, | 22 base::SharedMemoryHandle shared_memory_handle, |
22 size_t buffer_size); | 23 size_t buffer_size); |
23 | 24 |
24 bool FetchFromBuffer(content::OneWriterSeqLock* seqlock, void* final, | 25 bool FetchFromBuffer(content::OneWriterSeqLock* seqlock, void* final, |
25 void* temp, void* from, size_t size); | 26 void* temp, void* from, size_t size); |
26 | 27 |
27 static const int kMaximumContentionCount = 10; | 28 static const int kMaximumContentionCount = 10; |
28 base::SharedMemoryHandle renderer_shared_memory_handle_; | 29 base::SharedMemoryHandle renderer_shared_memory_handle_; |
29 scoped_ptr<base::SharedMemory> renderer_shared_memory_; | 30 scoped_ptr<base::SharedMemory> renderer_shared_memory_; |
30 }; | 31 }; |
31 | 32 |
32 } // namespace internal | 33 } // namespace internal |
33 | 34 |
34 namespace content { | |
35 | |
36 // Template argument Data should be a pod-like structure only containing | 35 // Template argument Data should be a pod-like structure only containing |
37 // data fields, such that it is copyable by memcpy method. | 36 // data fields, such that it is copyable by memcpy method. |
38 template<typename Data> | 37 template<typename Data> |
39 class SharedMemorySeqLockReader | 38 class SharedMemorySeqLockReader |
40 : private internal::SharedMemorySeqLockReaderBase { | 39 : private internal::SharedMemorySeqLockReaderBase { |
41 public: | 40 public: |
42 SharedMemorySeqLockReader() : buffer_(0) { } | 41 SharedMemorySeqLockReader() : buffer_(0) { } |
43 virtual ~SharedMemorySeqLockReader() { } | 42 virtual ~SharedMemorySeqLockReader() { } |
44 | 43 |
45 bool GetLatestData(Data* data) { | 44 bool GetLatestData(Data* data) { |
(...skipping 16 matching lines...) Expand all Loading... |
62 private: | 61 private: |
63 SharedMemorySeqLockBuffer<Data>* buffer_; | 62 SharedMemorySeqLockBuffer<Data>* buffer_; |
64 scoped_ptr<Data> temp_buffer_; | 63 scoped_ptr<Data> temp_buffer_; |
65 | 64 |
66 DISALLOW_COPY_AND_ASSIGN(SharedMemorySeqLockReader); | 65 DISALLOW_COPY_AND_ASSIGN(SharedMemorySeqLockReader); |
67 }; | 66 }; |
68 | 67 |
69 } // namespace content | 68 } // namespace content |
70 | 69 |
71 #endif // CONTENT_RENDERER_SHARED_MEMORY_SEQLOCK_READER_H_ | 70 #endif // CONTENT_RENDERER_SHARED_MEMORY_SEQLOCK_READER_H_ |
OLD | NEW |