| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "init_webrtc.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/files/file_path.h" | |
| 9 #include "base/files/file_util.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/metrics/histogram.h" | |
| 12 #include "base/native_library.h" | |
| 13 #include "base/path_service.h" | |
| 14 #include "base/trace_event/trace_event.h" | |
| 15 #include "third_party/webrtc/base/event_tracer.h" | |
| 16 #include "third_party/webrtc/system_wrappers/include/cpu_info.h" | |
| 17 #include "third_party/webrtc_overrides/webrtc/base/logging.h" | |
| 18 | |
| 19 const unsigned char* GetCategoryGroupEnabled(const char* category_group) { | |
| 20 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); | |
| 21 } | |
| 22 | |
| 23 void AddTraceEvent(char phase, | |
| 24 const unsigned char* category_group_enabled, | |
| 25 const char* name, | |
| 26 unsigned long long id, | |
| 27 int num_args, | |
| 28 const char** arg_names, | |
| 29 const unsigned char* arg_types, | |
| 30 const unsigned long long* arg_values, | |
| 31 unsigned char flags) { | |
| 32 TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 33 phase, category_group_enabled, name, trace_event_internal::kGlobalScope, | |
| 34 id, num_args, arg_names, arg_types, arg_values, NULL, flags); | |
| 35 } | |
| 36 | |
| 37 namespace webrtc { | |
| 38 | |
| 39 // Define webrtc::metrics functions to provide webrtc with implementations. | |
| 40 namespace metrics { | |
| 41 | |
| 42 // This class doesn't actually exist, so don't go looking for it :) | |
| 43 // This type is just fwd declared here in order to use it as an opaque type | |
| 44 // between the Histogram functions in this file. | |
| 45 class Histogram; | |
| 46 | |
| 47 Histogram* HistogramFactoryGetCounts( | |
| 48 const std::string& name, int min, int max, int bucket_count) { | |
| 49 return reinterpret_cast<Histogram*>( | |
| 50 base::Histogram::FactoryGet(name, min, max, bucket_count, | |
| 51 base::HistogramBase::kUmaTargetedHistogramFlag)); | |
| 52 } | |
| 53 | |
| 54 Histogram* HistogramFactoryGetEnumeration( | |
| 55 const std::string& name, int boundary) { | |
| 56 return reinterpret_cast<Histogram*>( | |
| 57 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, | |
| 58 base::HistogramBase::kUmaTargetedHistogramFlag)); | |
| 59 } | |
| 60 | |
| 61 void HistogramAdd( | |
| 62 Histogram* histogram_pointer, const std::string& name, int sample) { | |
| 63 base::HistogramBase* ptr = | |
| 64 reinterpret_cast<base::HistogramBase*>(histogram_pointer); | |
| 65 // The name should not vary. | |
| 66 DCHECK(ptr->histogram_name() == name); | |
| 67 ptr->Add(sample); | |
| 68 } | |
| 69 } // namespace metrics | |
| 70 } // namespace webrtc | |
| 71 | |
| 72 bool InitializeWebRtcModule() { | |
| 73 // Workaround for crbug.com/176522 | |
| 74 // On Linux, we can't fetch the number of cores after the sandbox has been | |
| 75 // initialized, so we call DetectNumberOfCores() here, to cache the value. | |
| 76 webrtc::CpuInfo::DetectNumberOfCores(); | |
| 77 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent); | |
| 78 return true; | |
| 79 } | |
| OLD | NEW |