Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: device/sensors/public/cpp/shared_memory_seqlock_reader.h

Issue 2819273006: Move //device/sensor impl to be part of the internal implemenation of the Device Service. (Closed)
Patch Set: Move //device/sensor impl to be part of the internal implemenation of the Device Service Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/sensors/public/cpp/shared_memory_seqlock_reader.h
diff --git a/device/sensors/public/cpp/shared_memory_seqlock_reader.h b/device/sensors/public/cpp/shared_memory_seqlock_reader.h
deleted file mode 100644
index 6b1453293004238d48d985916e728556839d5ddf..0000000000000000000000000000000000000000
--- a/device/sensors/public/cpp/shared_memory_seqlock_reader.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef DEVICE_SENSORS_PUBLIC_CPP_SHARED_MEMORY_SEQLOCK_READER_H_
-#define DEVICE_SENSORS_PUBLIC_CPP_SHARED_MEMORY_SEQLOCK_READER_H_
-
-#include <stddef.h>
-
-#include <memory>
-
-#include "base/macros.h"
-#include "base/memory/shared_memory.h"
-#include "device/base/synchronization/shared_memory_seqlock_buffer.h"
-
-namespace device {
-namespace internal {
-
-class SharedMemorySeqLockReaderBase {
- protected:
- SharedMemorySeqLockReaderBase();
- virtual ~SharedMemorySeqLockReaderBase();
-
- void* InitializeSharedMemory(base::SharedMemoryHandle shared_memory_handle,
- size_t buffer_size);
-
- bool FetchFromBuffer(device::OneWriterSeqLock* seqlock,
- void* final,
- void* temp,
- void* from,
- size_t size);
-
- static const int kMaximumContentionCount = 10;
- base::SharedMemoryHandle renderer_shared_memory_handle_;
- std::unique_ptr<base::SharedMemory> renderer_shared_memory_;
-};
-
-} // namespace internal
-
-// Template argument Data should be a pod-like structure only containing
-// data fields, such that it is copyable by memcpy method.
-template <typename Data>
-class SharedMemorySeqLockReader
- : private internal::SharedMemorySeqLockReaderBase {
- public:
- SharedMemorySeqLockReader() : buffer_(0) {}
- virtual ~SharedMemorySeqLockReader() {}
-
- bool GetLatestData(Data* data) {
- DCHECK(buffer_);
- DCHECK(sizeof(*data) == sizeof(*temp_buffer_));
- return FetchFromBuffer(&buffer_->seqlock, data, temp_buffer_.get(),
- &buffer_->data, sizeof(*temp_buffer_));
- }
-
- bool Initialize(base::SharedMemoryHandle shared_memory_handle) {
- if (void* memory = InitializeSharedMemory(
- shared_memory_handle,
- sizeof(device::SharedMemorySeqLockBuffer<Data>))) {
- buffer_ = static_cast<device::SharedMemorySeqLockBuffer<Data>*>(memory);
- temp_buffer_.reset(new Data);
- return true;
- }
- return false;
- }
-
- private:
- device::SharedMemorySeqLockBuffer<Data>* buffer_;
- std::unique_ptr<Data> temp_buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(SharedMemorySeqLockReader);
-};
-
-} // namespace device
-
-#endif // DEVICE_SENSORS_PUBLIC_CPP_SHARED_MEMORY_SEQLOCK_READER_H_
« no previous file with comments | « device/sensors/public/cpp/orientation_data.cc ('k') | device/sensors/public/cpp/shared_memory_seqlock_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698