| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/gpu/client/command_buffer_metrics.h" | 5 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 enum CommandBufferContextLostReason { | 13 enum CommandBufferContextLostReason { |
| 14 // Don't add new values here. | 14 // Don't add new values here. |
| 15 CONTEXT_INIT_FAILED, | 15 CONTEXT_INIT_FAILED, |
| 16 CONTEXT_LOST_GPU_CHANNEL_ERROR, | 16 CONTEXT_LOST_GPU_CHANNEL_ERROR, |
| 17 CONTEXT_PARSE_ERROR_INVALID_SIZE, | 17 CONTEXT_PARSE_ERROR_INVALID_SIZE, |
| 18 CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS, | 18 CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS, |
| 19 CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND, | 19 CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND, |
| 20 CONTEXT_PARSE_ERROR_INVALID_ARGS, | 20 CONTEXT_PARSE_ERROR_INVALID_ARGS, |
| 21 CONTEXT_PARSE_ERROR_GENERIC_ERROR, | 21 CONTEXT_PARSE_ERROR_GENERIC_ERROR, |
| 22 CONTEXT_LOST_GUILTY, | 22 CONTEXT_LOST_GUILTY, |
| 23 CONTEXT_LOST_INNOCENT, | 23 CONTEXT_LOST_INNOCENT, |
| 24 CONTEXT_LOST_UNKNOWN, | 24 CONTEXT_LOST_UNKNOWN, |
| 25 CONTEXT_LOST_OUT_OF_MEMORY, | 25 CONTEXT_LOST_OUT_OF_MEMORY, |
| 26 CONTEXT_LOST_MAKECURRENT_FAILED, | 26 CONTEXT_LOST_MAKECURRENT_FAILED, |
| 27 CONTEXT_LOST_INVALID_GPU_MESSAGE, |
| 27 // Add new values here and update _MAX_ENUM. | 28 // Add new values here and update _MAX_ENUM. |
| 28 CONTEXT_LOST_REASON_MAX_ENUM = CONTEXT_LOST_MAKECURRENT_FAILED | 29 // Also update //tools/metrics/histograms/histograms.xml |
| 30 CONTEXT_LOST_REASON_MAX_ENUM = CONTEXT_LOST_INVALID_GPU_MESSAGE |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 CommandBufferContextLostReason GetContextLostReason( | 33 CommandBufferContextLostReason GetContextLostReason( |
| 32 gpu::error::Error error, | 34 gpu::error::Error error, |
| 33 gpu::error::ContextLostReason reason) { | 35 gpu::error::ContextLostReason reason) { |
| 34 if (error == gpu::error::kLostContext) { | 36 if (error == gpu::error::kLostContext) { |
| 35 switch (reason) { | 37 switch (reason) { |
| 36 case gpu::error::kGuilty: | 38 case gpu::error::kGuilty: |
| 37 return CONTEXT_LOST_GUILTY; | 39 return CONTEXT_LOST_GUILTY; |
| 38 case gpu::error::kInnocent: | 40 case gpu::error::kInnocent: |
| 39 return CONTEXT_LOST_INNOCENT; | 41 return CONTEXT_LOST_INNOCENT; |
| 40 case gpu::error::kUnknown: | 42 case gpu::error::kUnknown: |
| 41 return CONTEXT_LOST_UNKNOWN; | 43 return CONTEXT_LOST_UNKNOWN; |
| 42 case gpu::error::kOutOfMemory: | 44 case gpu::error::kOutOfMemory: |
| 43 return CONTEXT_LOST_OUT_OF_MEMORY; | 45 return CONTEXT_LOST_OUT_OF_MEMORY; |
| 44 case gpu::error::kMakeCurrentFailed: | 46 case gpu::error::kMakeCurrentFailed: |
| 45 return CONTEXT_LOST_MAKECURRENT_FAILED; | 47 return CONTEXT_LOST_MAKECURRENT_FAILED; |
| 46 case gpu::error::kGpuChannelLost: | 48 case gpu::error::kGpuChannelLost: |
| 47 return CONTEXT_LOST_GPU_CHANNEL_ERROR; | 49 return CONTEXT_LOST_GPU_CHANNEL_ERROR; |
| 50 case gpu::error::kInvalidGpuMessage: |
| 51 return CONTEXT_LOST_INVALID_GPU_MESSAGE; |
| 48 } | 52 } |
| 49 } | 53 } |
| 50 switch (error) { | 54 switch (error) { |
| 51 case gpu::error::kInvalidSize: | 55 case gpu::error::kInvalidSize: |
| 52 return CONTEXT_PARSE_ERROR_INVALID_SIZE; | 56 return CONTEXT_PARSE_ERROR_INVALID_SIZE; |
| 53 case gpu::error::kOutOfBounds: | 57 case gpu::error::kOutOfBounds: |
| 54 return CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS; | 58 return CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS; |
| 55 case gpu::error::kUnknownCommand: | 59 case gpu::error::kUnknownCommand: |
| 56 return CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND; | 60 return CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND; |
| 57 case gpu::error::kInvalidArguments: | 61 case gpu::error::kInvalidArguments: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 154 |
| 151 void UmaRecordContextLost(CommandBufferContextType type, | 155 void UmaRecordContextLost(CommandBufferContextType type, |
| 152 gpu::error::Error error, | 156 gpu::error::Error error, |
| 153 gpu::error::ContextLostReason reason) { | 157 gpu::error::ContextLostReason reason) { |
| 154 CommandBufferContextLostReason converted_reason = | 158 CommandBufferContextLostReason converted_reason = |
| 155 GetContextLostReason(error, reason); | 159 GetContextLostReason(error, reason); |
| 156 RecordContextLost(type, converted_reason); | 160 RecordContextLost(type, converted_reason); |
| 157 } | 161 } |
| 158 | 162 |
| 159 } // namespace content | 163 } // namespace content |
| OLD | NEW |