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

Unified Diff: content/renderer/shared_memory_seqlock_reader.cc

Issue 1164563003: Extract device_sensors to /device via Mojofication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « content/renderer/shared_memory_seqlock_reader.h ('k') | device/device_sensors/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/shared_memory_seqlock_reader.cc
diff --git a/content/renderer/shared_memory_seqlock_reader.cc b/content/renderer/shared_memory_seqlock_reader.cc
deleted file mode 100644
index 2727aa52f99fd015c5c9d51a9cf026c8040d4d9b..0000000000000000000000000000000000000000
--- a/content/renderer/shared_memory_seqlock_reader.cc
+++ /dev/null
@@ -1,60 +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.
-
-#include "content/renderer/shared_memory_seqlock_reader.h"
-
-namespace content {
-namespace internal {
-
-SharedMemorySeqLockReaderBase::SharedMemorySeqLockReaderBase() { }
-
-SharedMemorySeqLockReaderBase::~SharedMemorySeqLockReaderBase() { }
-
-void*
-SharedMemorySeqLockReaderBase::InitializeSharedMemory(
- base::SharedMemoryHandle shared_memory_handle, size_t buffer_size) {
- renderer_shared_memory_handle_ = shared_memory_handle;
- if (!base::SharedMemory::IsHandleValid(renderer_shared_memory_handle_))
- return 0;
- renderer_shared_memory_.reset(new base::SharedMemory(
- renderer_shared_memory_handle_, true));
-
- return (renderer_shared_memory_->Map(buffer_size))
- ? renderer_shared_memory_->memory()
- : 0;
-}
-
-bool SharedMemorySeqLockReaderBase::FetchFromBuffer(
- content::OneWriterSeqLock* seqlock, void* final, void* temp, void* from,
- size_t size) {
-
- if (!base::SharedMemory::IsHandleValid(renderer_shared_memory_handle_))
- return false;
-
- // Only try to read this many times before failing to avoid waiting here
- // very long in case of contention with the writer.
- int contention_count = -1;
- base::subtle::Atomic32 version;
- do {
- version = seqlock->ReadBegin();
- memcpy(temp, from, size);
- ++contention_count;
- if (contention_count == kMaximumContentionCount)
- break;
- } while (seqlock->ReadRetry(version));
-
- if (contention_count >= kMaximumContentionCount) {
- // We failed to successfully read, presumably because the hardware
- // thread was taking unusually long. Don't copy the data to the output
- // buffer, and simply leave what was there before.
- return false;
- }
-
- // New data was read successfully, copy it into the output buffer.
- memcpy(final, temp, size);
- return true;
-}
-
-} // namespace internal
-} // namespace content
« no previous file with comments | « content/renderer/shared_memory_seqlock_reader.h ('k') | device/device_sensors/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698