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