Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / overrides / init_webrtc.cc
index ab89d58..041fb20 100644 (file)
@@ -9,6 +9,7 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/metrics/field_trial.h"
+#include "base/metrics/histogram.h"
 #include "base/native_library.h"
 #include "base/path_service.h"
 #include "webrtc/base/basictypes.h"
@@ -32,14 +33,40 @@ void AddTraceEvent(char phase,
                                   NULL, flags);
 }
 
-// Define webrtc:field_trial::FindFullName to provide webrtc with a field trial
-// implementation.
 namespace webrtc {
+// Define webrtc::field_trial::FindFullName to provide webrtc with a field trial
+// implementation.
 namespace field_trial {
 std::string FindFullName(const std::string& trial_name) {
   return base::FieldTrialList::FindFullName(trial_name);
 }
 }  // namespace field_trial
+
+// Define webrtc::metrics functions to provide webrtc with implementations.
+namespace metrics {
+Histogram* HistogramFactoryGetCounts(
+    const std::string& name, int min, int max, int bucket_count) {
+  return reinterpret_cast<Histogram*>(
+      base::Histogram::FactoryGet(name, min, max, bucket_count,
+          base::HistogramBase::kUmaTargetedHistogramFlag));
+}
+
+Histogram* HistogramFactoryGetEnumeration(
+    const std::string& name, int boundary) {
+  return reinterpret_cast<Histogram*>(
+      base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1,
+          base::HistogramBase::kUmaTargetedHistogramFlag));
+}
+
+void HistogramAdd(
+    Histogram* histogram_pointer, const std::string& name, int sample) {
+  base::HistogramBase* ptr =
+      reinterpret_cast<base::HistogramBase*>(histogram_pointer);
+  // The name should not vary.
+  DCHECK(ptr->histogram_name() == name);
+  ptr->Add(sample);
+}
+}  // namespace metrics
 }  // namespace webrtc
 
 #if defined(LIBPEERCONNECTION_LIB)
@@ -126,16 +153,19 @@ bool InitializeWebRtcModule() {
   InitDiagnosticLoggingDelegateFunctionFunction init_diagnostic_logging = NULL;
   bool init_ok = initialize_module(*CommandLine::ForCurrentProcess(),
 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
-                                   &Allocate,
-                                   &Dellocate,
+      &Allocate,
+      &Dellocate,
 #endif
-                                   &webrtc::field_trial::FindFullName,
-                                   logging::GetLogMessageHandler(),
-                                   &GetCategoryGroupEnabled,
-                                   &AddTraceEvent,
-                                   &g_create_webrtc_media_engine,
-                                   &g_destroy_webrtc_media_engine,
-                                   &init_diagnostic_logging);
+      &webrtc::field_trial::FindFullName,
+      &webrtc::metrics::HistogramFactoryGetCounts,
+      &webrtc::metrics::HistogramFactoryGetEnumeration,
+      &webrtc::metrics::HistogramAdd,
+      logging::GetLogMessageHandler(),
+      &GetCategoryGroupEnabled,
+      &AddTraceEvent,
+      &g_create_webrtc_media_engine,
+      &g_destroy_webrtc_media_engine,
+      &init_diagnostic_logging);
 
   if (init_ok)
     rtc::SetExtraLoggingInit(init_diagnostic_logging);