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

Side by Side Diff: base/memory/discardable_shared_memory.cc

Issue 1386333003: Revert of [tracing] Display the locked size of discardable memory segment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/memory/discardable_shared_memory.h" 5 #include "base/memory/discardable_shared_memory.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <unistd.h> 8 #include <unistd.h>
9 #endif 9 #endif
10 10
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 bool DiscardableSharedMemory::IsMemoryResident() const { 333 bool DiscardableSharedMemory::IsMemoryResident() const {
334 DCHECK(shared_memory_.memory()); 334 DCHECK(shared_memory_.memory());
335 335
336 SharedState result(subtle::NoBarrier_Load( 336 SharedState result(subtle::NoBarrier_Load(
337 &SharedStateFromSharedMemory(shared_memory_)->value.i)); 337 &SharedStateFromSharedMemory(shared_memory_)->value.i));
338 338
339 return result.GetLockState() == SharedState::LOCKED || 339 return result.GetLockState() == SharedState::LOCKED ||
340 !result.GetTimestamp().is_null(); 340 !result.GetTimestamp().is_null();
341 } 341 }
342 342
343 bool DiscardableSharedMemory::IsMemoryLocked() const {
344 DCHECK(shared_memory_.memory());
345
346 SharedState result(subtle::NoBarrier_Load(
347 &SharedStateFromSharedMemory(shared_memory_)->value.i));
348
349 return result.GetLockState() == SharedState::LOCKED;
350 }
351
352 void DiscardableSharedMemory::Close() { 343 void DiscardableSharedMemory::Close() {
353 shared_memory_.Close(); 344 shared_memory_.Close();
354 } 345 }
355 346
356 #if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING) 347 #if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING)
357 void DiscardableSharedMemory::Shrink() { 348 void DiscardableSharedMemory::Shrink() {
358 #if defined(OS_POSIX) 349 #if defined(OS_POSIX)
359 SharedMemoryHandle handle = shared_memory_.handle(); 350 SharedMemoryHandle handle = shared_memory_.handle();
360 if (!SharedMemory::IsHandleValid(handle)) 351 if (!SharedMemory::IsHandleValid(handle))
361 return; 352 return;
362 353
363 // Truncate shared memory to size of SharedState. 354 // Truncate shared memory to size of SharedState.
364 if (HANDLE_EINTR(ftruncate(SharedMemory::GetFdFromSharedMemoryHandle(handle), 355 if (HANDLE_EINTR(ftruncate(SharedMemory::GetFdFromSharedMemoryHandle(handle),
365 AlignToPageSize(sizeof(SharedState)))) != 0) { 356 AlignToPageSize(sizeof(SharedState)))) != 0) {
366 DPLOG(ERROR) << "ftruncate() failed"; 357 DPLOG(ERROR) << "ftruncate() failed";
367 return; 358 return;
368 } 359 }
369 mapped_size_ = 0; 360 mapped_size_ = 0;
370 #else 361 #else
371 NOTIMPLEMENTED(); 362 NOTIMPLEMENTED();
372 #endif 363 #endif
373 } 364 }
374 #endif 365 #endif
375 366
376 Time DiscardableSharedMemory::Now() const { 367 Time DiscardableSharedMemory::Now() const {
377 return Time::Now(); 368 return Time::Now();
378 } 369 }
379 370
380 } // namespace base 371 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_shared_memory.h ('k') | base/memory/discardable_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698