| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/debug/activity_tracker.h" | 5 #include "base/debug/activity_tracker.h" |
| 6 | 6 |
| 7 #include "base/debug/stack_trace.h" | 7 #include "base/debug/stack_trace.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 474 |
| 475 // Create and map the file into memory and make it globally available. | 475 // Create and map the file into memory and make it globally available. |
| 476 std::unique_ptr<MemoryMappedFile> mapped_file(new MemoryMappedFile()); | 476 std::unique_ptr<MemoryMappedFile> mapped_file(new MemoryMappedFile()); |
| 477 bool success = | 477 bool success = |
| 478 mapped_file->Initialize(File(file_path, | 478 mapped_file->Initialize(File(file_path, |
| 479 File::FLAG_CREATE_ALWAYS | File::FLAG_READ | | 479 File::FLAG_CREATE_ALWAYS | File::FLAG_READ | |
| 480 File::FLAG_WRITE | File::FLAG_SHARE_DELETE), | 480 File::FLAG_WRITE | File::FLAG_SHARE_DELETE), |
| 481 {0, static_cast<int64_t>(size)}, | 481 {0, static_cast<int64_t>(size)}, |
| 482 MemoryMappedFile::READ_WRITE_EXTEND); | 482 MemoryMappedFile::READ_WRITE_EXTEND); |
| 483 DCHECK(success); | 483 DCHECK(success); |
| 484 CreateWithAllocator(WrapUnique(new FilePersistentMemoryAllocator( | 484 CreateWithAllocator(MakeUnique<FilePersistentMemoryAllocator>( |
| 485 std::move(mapped_file), size, id, name, false)), | 485 std::move(mapped_file), size, id, name, false), |
| 486 stack_depth); | 486 stack_depth); |
| 487 } | 487 } |
| 488 #endif // !defined(OS_NACL) | 488 #endif // !defined(OS_NACL) |
| 489 | 489 |
| 490 // static | 490 // static |
| 491 void GlobalActivityTracker::CreateWithLocalMemory(size_t size, | 491 void GlobalActivityTracker::CreateWithLocalMemory(size_t size, |
| 492 uint64_t id, | 492 uint64_t id, |
| 493 StringPiece name, | 493 StringPiece name, |
| 494 int stack_depth) { | 494 int stack_depth) { |
| 495 CreateWithAllocator( | 495 CreateWithAllocator( |
| 496 WrapUnique(new LocalPersistentMemoryAllocator(size, id, name)), | 496 MakeUnique<LocalPersistentMemoryAllocator>(size, id, name), stack_depth); |
| 497 stack_depth); | |
| 498 } | 497 } |
| 499 | 498 |
| 500 ThreadActivityTracker* GlobalActivityTracker::CreateTrackerForCurrentThread() { | 499 ThreadActivityTracker* GlobalActivityTracker::CreateTrackerForCurrentThread() { |
| 501 DCHECK(!this_thread_tracker_.Get()); | 500 DCHECK(!this_thread_tracker_.Get()); |
| 502 | 501 |
| 503 PersistentMemoryAllocator::Reference mem_reference = | 502 PersistentMemoryAllocator::Reference mem_reference = |
| 504 PersistentMemoryAllocator::kReferenceNull; | 503 PersistentMemoryAllocator::kReferenceNull; |
| 505 DCHECK(!mem_reference); // invalid_value should be checkable with ! | 504 DCHECK(!mem_reference); // invalid_value should be checkable with ! |
| 506 | 505 |
| 507 while (true) { | 506 while (true) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 const base::Process* process) | 704 const base::Process* process) |
| 706 : GlobalActivityTracker::ScopedThreadActivity( | 705 : GlobalActivityTracker::ScopedThreadActivity( |
| 707 nullptr, | 706 nullptr, |
| 708 Activity::ACT_PROCESS_WAIT, | 707 Activity::ACT_PROCESS_WAIT, |
| 709 ActivityData::ForProcess(process->Pid()), | 708 ActivityData::ForProcess(process->Pid()), |
| 710 /*lock_allowed=*/true) {} | 709 /*lock_allowed=*/true) {} |
| 711 #endif | 710 #endif |
| 712 | 711 |
| 713 } // namespace debug | 712 } // namespace debug |
| 714 } // namespace base | 713 } // namespace base |
| OLD | NEW |