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

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

Issue 1374213002: [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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 bool DiscardableSharedMemory::Unmap() { 155 bool DiscardableSharedMemory::Unmap() {
156 if (!shared_memory_.Unmap()) 156 if (!shared_memory_.Unmap())
157 return false; 157 return false;
158 158
159 mapped_size_ = 0; 159 mapped_size_ = 0;
160 return true; 160 return true;
161 } 161 }
162 162
163 size_t DiscardableSharedMemory::LockedSize() const {
164 if (!shared_memory_.memory())
165 return 0;
166
167 SharedState result(subtle::NoBarrier_Load(
168 &SharedStateFromSharedMemory(shared_memory_)->value.i));
169
170 return result.GetLockState() == SharedState::LOCKED
171 ? locked_page_count_ * base::GetPageSize()
172 : 0;
173 }
174
163 DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock( 175 DiscardableSharedMemory::LockResult DiscardableSharedMemory::Lock(
164 size_t offset, size_t length) { 176 size_t offset, size_t length) {
165 DCHECK_EQ(AlignToPageSize(offset), offset); 177 DCHECK_EQ(AlignToPageSize(offset), offset);
166 DCHECK_EQ(AlignToPageSize(length), length); 178 DCHECK_EQ(AlignToPageSize(length), length);
167 179
168 // Calls to this function must be synchronized properly. 180 // Calls to this function must be synchronized properly.
169 DFAKE_SCOPED_LOCK(thread_collision_warner_); 181 DFAKE_SCOPED_LOCK(thread_collision_warner_);
170 182
171 DCHECK(shared_memory_.memory()); 183 DCHECK(shared_memory_.memory());
172 184
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 NOTIMPLEMENTED(); 374 NOTIMPLEMENTED();
363 #endif 375 #endif
364 } 376 }
365 #endif 377 #endif
366 378
367 Time DiscardableSharedMemory::Now() const { 379 Time DiscardableSharedMemory::Now() const {
368 return Time::Now(); 380 return Time::Now();
369 } 381 }
370 382
371 } // namespace base 383 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698