| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "components/metrics/call_stack_profile_encoding.h" |
| |
| namespace metrics { |
| |
| Process ToExecutionContextProcess(CallStackProfileParams::Process process) { |
| switch (process) { |
| case CallStackProfileParams::UNKNOWN_PROCESS: |
| return UNKNOWN_PROCESS; |
| case CallStackProfileParams::BROWSER_PROCESS: |
| return BROWSER_PROCESS; |
| case CallStackProfileParams::RENDERER_PROCESS: |
| return RENDERER_PROCESS; |
| case CallStackProfileParams::GPU_PROCESS: |
| return GPU_PROCESS; |
| case CallStackProfileParams::UTILITY_PROCESS: |
| return UTILITY_PROCESS; |
| case CallStackProfileParams::ZYGOTE_PROCESS: |
| return ZYGOTE_PROCESS; |
| case CallStackProfileParams::SANDBOX_HELPER_PROCESS: |
| return SANDBOX_HELPER_PROCESS; |
| case CallStackProfileParams::PPAPI_PLUGIN_PROCESS: |
| return PPAPI_PLUGIN_PROCESS; |
| case CallStackProfileParams::PPAPI_BROKER_PROCESS: |
| return PPAPI_BROKER_PROCESS; |
| } |
| NOTREACHED(); |
| return UNKNOWN_PROCESS; |
| } |
| |
| Thread ToExecutionContextThread(CallStackProfileParams::Thread thread) { |
| switch (thread) { |
| case CallStackProfileParams::UNKNOWN_THREAD: |
| return UNKNOWN_THREAD; |
| case CallStackProfileParams::MAIN_THREAD: |
| return MAIN_THREAD; |
| case CallStackProfileParams::IO_THREAD: |
| return IO_THREAD; |
| case CallStackProfileParams::COMPOSITOR_THREAD: |
| return COMPOSITOR_THREAD; |
| } |
| NOTREACHED(); |
| return UNKNOWN_THREAD; |
| } |
| |
| SampledProfile::TriggerEvent ToSampledProfileTriggerEvent( |
| CallStackProfileParams::Trigger trigger) { |
| switch (trigger) { |
| case CallStackProfileParams::UNKNOWN: |
| return SampledProfile::UNKNOWN_TRIGGER_EVENT; |
| case CallStackProfileParams::PROCESS_STARTUP: |
| return SampledProfile::PROCESS_STARTUP; |
| case CallStackProfileParams::JANKY_TASK: |
| return SampledProfile::JANKY_TASK; |
| case CallStackProfileParams::THREAD_HUNG: |
| return SampledProfile::THREAD_HUNG; |
| case CallStackProfileParams::PERIODIC_COLLECTION: |
| return SampledProfile::PERIODIC_COLLECTION; |
| } |
| NOTREACHED(); |
| return SampledProfile::UNKNOWN_TRIGGER_EVENT; |
| } |
| |
| } // namespace metrics |