| 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 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 | 2596 |
| 2597 // Get handle to the renderer process. Stop if there is none. | 2597 // Get handle to the renderer process. Stop if there is none. |
| 2598 base::ProcessHandle destination = GetHandle(); | 2598 base::ProcessHandle destination = GetHandle(); |
| 2599 if (destination == base::kNullProcessHandle) | 2599 if (destination == base::kNullProcessHandle) |
| 2600 return; | 2600 return; |
| 2601 | 2601 |
| 2602 // If a renderer crashes before completing startup and gets restarted, this | 2602 // If a renderer crashes before completing startup and gets restarted, this |
| 2603 // method will get called a second time meaning that a metrics-allocator | 2603 // method will get called a second time meaning that a metrics-allocator |
| 2604 // already exists. Don't recreate it. | 2604 // already exists. Don't recreate it. |
| 2605 if (!metrics_allocator_) { | 2605 if (!metrics_allocator_) { |
| 2606 // TODO(bcwhite): Update this with the correct memory size. | 2606 // Create persistent/shared memory and allow histograms to be stored in |
| 2607 // it. Memory that is not actualy used won't be physically mapped by the |
| 2608 // system. RendererMetrics usage, as reported in UMA, peaked around 0.7MiB |
| 2609 // as of 2016-12-20. |
| 2607 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 2610 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 2608 if (!shm->CreateAndMapAnonymous(2 << 20)) // 2 MiB | 2611 if (!shm->CreateAndMapAnonymous(2 << 20)) // 2 MiB |
| 2609 return; | 2612 return; |
| 2610 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( | 2613 metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( |
| 2611 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); | 2614 std::move(shm), GetID(), "RendererMetrics", /*readonly=*/false)); |
| 2612 } | 2615 } |
| 2613 | 2616 |
| 2614 base::SharedMemoryHandle shm_handle; | 2617 base::SharedMemoryHandle shm_handle; |
| 2615 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); | 2618 metrics_allocator_->shared_memory()->ShareToProcess(destination, &shm_handle); |
| 2616 Send(new ChildProcessMsg_SetHistogramMemory( | 2619 Send(new ChildProcessMsg_SetHistogramMemory( |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3006 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3004 | 3007 |
| 3005 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3008 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3006 // Capture the error message in a crash key value. | 3009 // Capture the error message in a crash key value. |
| 3007 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3010 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3008 bad_message::ReceivedBadMessage(render_process_id, | 3011 bad_message::ReceivedBadMessage(render_process_id, |
| 3009 bad_message::RPH_MOJO_PROCESS_ERROR); | 3012 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3010 } | 3013 } |
| 3011 | 3014 |
| 3012 } // namespace content | 3015 } // namespace content |
| OLD | NEW |