Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / third_party / libjingle / overrides / init_webrtc.cc
blobb9a8901c9b7f1f260410284bda258326607beb45
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.
5 #include "init_webrtc.h"
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/field_trial.h"
12 #include "base/metrics/histogram.h"
13 #include "base/native_library.h"
14 #include "base/path_service.h"
15 #include "base/trace_event/trace_event.h"
16 #include "third_party/webrtc/overrides/webrtc/base/logging.h"
17 #include "third_party/webrtc/system_wrappers/interface/cpu_info.h"
18 #include "third_party/webrtc/system_wrappers/interface/event_tracer.h"
20 const unsigned char* GetCategoryGroupEnabled(const char* category_group) {
21 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
24 void AddTraceEvent(char phase,
25 const unsigned char* category_group_enabled,
26 const char* name,
27 unsigned long long id,
28 int num_args,
29 const char** arg_names,
30 const unsigned char* arg_types,
31 const unsigned long long* arg_values,
32 unsigned char flags) {
33 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, id,
34 num_args, arg_names, arg_types, arg_values,
35 NULL, flags);
38 namespace webrtc {
39 // Define webrtc::field_trial::FindFullName to provide webrtc with a field trial
40 // implementation.
41 namespace field_trial {
42 std::string FindFullName(const std::string& trial_name) {
43 return base::FieldTrialList::FindFullName(trial_name);
45 } // namespace field_trial
47 // Define webrtc::metrics functions to provide webrtc with implementations.
48 namespace metrics {
50 // This class doesn't actually exist, so don't go looking for it :)
51 // This type is just fwd declared here in order to use it as an opaque type
52 // between the Histogram functions in this file.
53 class Histogram;
55 Histogram* HistogramFactoryGetCounts(
56 const std::string& name, int min, int max, int bucket_count) {
57 return reinterpret_cast<Histogram*>(
58 base::Histogram::FactoryGet(name, min, max, bucket_count,
59 base::HistogramBase::kUmaTargetedHistogramFlag));
62 Histogram* HistogramFactoryGetEnumeration(
63 const std::string& name, int boundary) {
64 return reinterpret_cast<Histogram*>(
65 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1,
66 base::HistogramBase::kUmaTargetedHistogramFlag));
69 void HistogramAdd(
70 Histogram* histogram_pointer, const std::string& name, int sample) {
71 base::HistogramBase* ptr =
72 reinterpret_cast<base::HistogramBase*>(histogram_pointer);
73 // The name should not vary.
74 DCHECK(ptr->histogram_name() == name);
75 ptr->Add(sample);
77 } // namespace metrics
78 } // namespace webrtc
80 bool InitializeWebRtcModule() {
81 // Workaround for crbug.com/176522
82 // On Linux, we can't fetch the number of cores after the sandbox has been
83 // initialized, so we call DetectNumberOfCores() here, to cache the value.
84 webrtc::CpuInfo::DetectNumberOfCores();
85 webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent);
86 return true;