| OLD | NEW |
| 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 "content/child/child_discardable_shared_memory_manager.h" | 5 #include "content/child/child_discardable_shared_memory_manager.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/memory/discardable_memory.h" | 10 #include "base/memory/discardable_memory.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 is_locked_ = true; | 53 is_locked_ = true; |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 void Unlock() override { | 56 void Unlock() override { |
| 57 DCHECK(is_locked_); | 57 DCHECK(is_locked_); |
| 58 | 58 |
| 59 manager_->UnlockSpan(span_.get()); | 59 manager_->UnlockSpan(span_.get()); |
| 60 is_locked_ = false; | 60 is_locked_ = false; |
| 61 } | 61 } |
| 62 void* Memory() const override { | 62 void* data() const override { |
| 63 DCHECK(is_locked_); | 63 DCHECK(is_locked_); |
| 64 return reinterpret_cast<void*>(span_->start() * base::GetPageSize()); | 64 return reinterpret_cast<void*>(span_->start() * base::GetPageSize()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 ChildDiscardableSharedMemoryManager* const manager_; | 68 ChildDiscardableSharedMemoryManager* const manager_; |
| 69 scoped_ptr<DiscardableSharedMemoryHeap::Span> span_; | 69 scoped_ptr<DiscardableSharedMemoryHeap::Span> span_; |
| 70 bool is_locked_; | 70 bool is_locked_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryImpl); | 72 DISALLOW_COPY_AND_ASSIGN(DiscardableMemoryImpl); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 "discardable-memory-allocated"; | 283 "discardable-memory-allocated"; |
| 284 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, | 284 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, |
| 285 base::Uint64ToString(new_bytes_total)); | 285 base::Uint64ToString(new_bytes_total)); |
| 286 | 286 |
| 287 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; | 287 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; |
| 288 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, | 288 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, |
| 289 base::Uint64ToString(new_bytes_free)); | 289 base::Uint64ToString(new_bytes_free)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace content | 292 } // namespace content |
| OLD | NEW |