| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 | 2590 |
| 2591 // Get handle to the renderer process. Stop if there is none. | 2591 // Get handle to the renderer process. Stop if there is none. |
| 2592 base::ProcessHandle destination = GetHandle(); | 2592 base::ProcessHandle destination = GetHandle(); |
| 2593 if (destination == base::kNullProcessHandle) | 2593 if (destination == base::kNullProcessHandle) |
| 2594 return; | 2594 return; |
| 2595 | 2595 |
| 2596 // If a renderer crashes before completing startup and gets restarted, this | 2596 // If a renderer crashes before completing startup and gets restarted, this |
| 2597 // method will get called a second time meaning that a metrics-allocator | 2597 // method will get called a second time meaning that a metrics-allocator |
| 2598 // already exists. Don't recreate it. | 2598 // already exists. Don't recreate it. |
| 2599 if (!metrics_allocator_) { | 2599 if (!metrics_allocator_) { |
| 2600 // TODO(bcwhite): Update this with the correct memory size. | 2600 // Create persistent/shared memory and allow histograms to be stored in |
| 2601 // it. Memory that is not actualy used won't be physically mapped by the |
| 2602 // system. RendererMetrics usage, as reported in UMA, peaked around 0.7MiB |
| 2603 // as of 2016-12-20. |
| 2601 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 2604 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 2602 if (!shm->CreateAndMapAnonymous(2 << 20)) // 2 MiB | 2605 if (!shm->CreateAndMapAnonymous(2 << 20)) // 2 MiB |
| 2603 return; | 2606 return; |
| 2604 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( | 2607 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( |
| 2605 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); | 2608 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); |
| 2606 } | 2609 } |
| 2607 | 2610 |
| 2608 base::SharedMemoryHandle shm_handle; | 2611 base::SharedMemoryHandle shm_handle; |
| 2609 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); | 2612 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); |
| 2610 Send(new ChildProcessMsg_SetHistogramMemory( | 2613 Send(new ChildProcessMsg_SetHistogramMemory( |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3000 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2998 | 3001 |
| 2999 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 3002 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 3000 // enough information here so that we can determine what the bad message was. | 3003 // enough information here so that we can determine what the bad message was. |
| 3001 base::debug::Alias(&error); | 3004 base::debug::Alias(&error); |
| 3002 bad_message::ReceivedBadMessage(render_process_id, | 3005 bad_message::ReceivedBadMessage(render_process_id, |
| 3003 bad_message::RPH_MOJO_PROCESS_ERROR); | 3006 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3004 } | 3007 } |
| 3005 | 3008 |
| 3006 } // namespace content | 3009 } // namespace content |
| OLD | NEW |