OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/browser_child_process_host_impl.h" | 5 #include "content/browser/browser_child_process_host_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 505 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
506 if (!shm->CreateAndMapAnonymous(memory_size)) | 506 if (!shm->CreateAndMapAnonymous(memory_size)) |
507 return; | 507 return; |
508 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( | 508 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( |
509 std::move(shm), static_cast<uint64_t>(data_.id), metrics_name, | 509 std::move(shm), static_cast<uint64_t>(data_.id), metrics_name, |
510 /*readonly=*/false)); | 510 /*readonly=*/false)); |
511 } | 511 } |
512 | 512 |
513 void BrowserChildProcessHostImpl::ShareMetricsAllocatorToProcess() { | 513 void BrowserChildProcessHostImpl::ShareMetricsAllocatorToProcess() { |
514 if (metrics_allocator_) { | 514 if (metrics_allocator_) { |
515 base::SharedMemoryHandle shm_handle; | 515 base::SharedMemoryHandle shm_handle = |
516 metrics_allocator_->shared_memory()->ShareToProcess(data_.handle, | 516 metrics_allocator_->shared_memory()->handle().Duplicate(); |
517 &shm_handle); | |
518 Send(new ChildProcessMsg_SetHistogramMemory( | 517 Send(new ChildProcessMsg_SetHistogramMemory( |
Nico
2017/05/02 16:06:12
Does sending a SharedMemoryHandle consume it? If n
erikchen
2017/05/02 19:00:51
Yes, I've updated the documentation for Duplicate(
| |
519 shm_handle, metrics_allocator_->shared_memory()->mapped_size())); | 518 shm_handle, metrics_allocator_->shared_memory()->mapped_size())); |
520 } | 519 } |
521 } | 520 } |
522 | 521 |
523 void BrowserChildProcessHostImpl::OnProcessLaunchFailed(int error_code) { | 522 void BrowserChildProcessHostImpl::OnProcessLaunchFailed(int error_code) { |
524 delegate_->OnProcessLaunchFailed(error_code); | 523 delegate_->OnProcessLaunchFailed(error_code); |
525 notify_child_disconnected_ = false; | 524 notify_child_disconnected_ = false; |
526 delete delegate_; // Will delete us | 525 delete delegate_; // Will delete us |
527 } | 526 } |
528 | 527 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 | 591 |
593 #if defined(OS_WIN) | 592 #if defined(OS_WIN) |
594 | 593 |
595 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 594 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
596 OnChildDisconnected(); | 595 OnChildDisconnected(); |
597 } | 596 } |
598 | 597 |
599 #endif | 598 #endif |
600 | 599 |
601 } // namespace content | 600 } // namespace content |
OLD | NEW |