init_webrtc.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include "init_webrtc.h"
  5. #include "base/command_line.h"
  6. #include "base/files/file_path.h"
  7. #include "base/files/file_util.h"
  8. #include "base/native_library.h"
  9. #include "base/path_service.h"
  10. #include "base/trace_event/trace_event.h"
  11. #include "third_party/webrtc/rtc_base/event_tracer.h"
  12. #include "third_party/webrtc/system_wrappers/include/cpu_info.h"
  13. #include "third_party/webrtc_overrides/rtc_base/logging.h"
  14. const unsigned char* GetCategoryGroupEnabled(const char* category_group) {
  15. return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
  16. }
  17. void AddTraceEvent(char phase,
  18. const unsigned char* category_group_enabled,
  19. const char* name,
  20. unsigned long long id,
  21. int num_args,
  22. const char** arg_names,
  23. const unsigned char* arg_types,
  24. const unsigned long long* arg_values,
  25. unsigned char flags) {
  26. base::trace_event::TraceArguments args(num_args, arg_names, arg_types,
  27. arg_values);
  28. TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name,
  29. trace_event_internal::kGlobalScope, id, &args,
  30. flags);
  31. }
  32. bool InitializeWebRtcModule() {
  33. // Workaround for crbug.com/176522
  34. // On Linux, we can't fetch the number of cores after the sandbox has been
  35. // initialized, so we call DetectNumberOfCores() here, to cache the value.
  36. webrtc::CpuInfo::DetectNumberOfCores();
  37. webrtc::SetupEventTracer(&GetCategoryGroupEnabled, &AddTraceEvent);
  38. return true;
  39. }