| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Defines StructTraits specializations for translating between mojo types and | 5 // Defines StructTraits specializations for translating between mojo types and |
| 6 // base::StackSamplingProfiler types, with data validity checks. | 6 // base::StackSamplingProfiler types, with data validity checks. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ | 8 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ |
| 9 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ | 9 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const base::StackSamplingProfiler::Module& module) { | 27 const base::StackSamplingProfiler::Module& module) { |
| 28 return module.id; | 28 return module.id; |
| 29 } | 29 } |
| 30 static const base::FilePath& filename( | 30 static const base::FilePath& filename( |
| 31 const base::StackSamplingProfiler::Module& module) { | 31 const base::StackSamplingProfiler::Module& module) { |
| 32 return module.filename; | 32 return module.filename; |
| 33 } | 33 } |
| 34 | 34 |
| 35 static bool Read(metrics::mojom::CallStackModuleDataView data, | 35 static bool Read(metrics::mojom::CallStackModuleDataView data, |
| 36 base::StackSamplingProfiler::Module* out) { | 36 base::StackSamplingProfiler::Module* out) { |
| 37 // Linux has the longest build id at 40 bytes. | |
| 38 static const size_t kMaxIDSize = 40; | |
| 39 | |
| 40 std::string id; | 37 std::string id; |
| 41 base::FilePath filename; | 38 base::FilePath filename; |
| 42 if (!data.ReadId(&id) || id.size() > kMaxIDSize || | 39 if (!data.ReadId(&id) || !data.ReadFilename(&filename)) |
| 43 !data.ReadFilename(&filename)) | |
| 44 return false; | 40 return false; |
| 45 | 41 |
| 46 *out = | 42 *out = |
| 47 base::StackSamplingProfiler::Module(data.base_address(), id, filename); | 43 base::StackSamplingProfiler::Module(data.base_address(), id, filename); |
| 48 return true; | 44 return true; |
| 49 } | 45 } |
| 50 }; | 46 }; |
| 51 | 47 |
| 52 template <> | 48 template <> |
| 53 struct StructTraits<metrics::mojom::CallStackFrameDataView, | 49 struct StructTraits<metrics::mojom::CallStackFrameDataView, |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 metrics::CallStackProfileParams::SampleOrderingSpec::PRESERVE_ORDER; | 360 metrics::CallStackProfileParams::SampleOrderingSpec::PRESERVE_ORDER; |
| 365 return true; | 361 return true; |
| 366 } | 362 } |
| 367 return false; | 363 return false; |
| 368 } | 364 } |
| 369 }; | 365 }; |
| 370 | 366 |
| 371 } // mojo | 367 } // mojo |
| 372 | 368 |
| 373 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ | 369 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ |
| OLD | NEW |