Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: webrtc/sdk/objc/Framework/Classes/RTCMetric.mm

Issue 2036773003: Add ObjC API for getting native histograms. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/sdk/BUILD.gn ('k') | webrtc/sdk/objc/Framework/Classes/RTCMetric+Private.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/objc/Framework/Classes/RTCMetric.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCMetric.mm b/webrtc/sdk/objc/Framework/Classes/RTCMetric.mm
new file mode 100644
index 0000000000000000000000000000000000000000..741847d4b0f8960840f19ef8b04cc09c18ac426a
--- /dev/null
+++ b/webrtc/sdk/objc/Framework/Classes/RTCMetric.mm
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#import "RTCMetric+Private.h"
+
+#import "NSString+StdString.h"
+
+@implementation RTCMetric
+
+@synthesize name = _name;
+@synthesize min = _min;
+@synthesize max = _max;
+@synthesize bucketCount = _bucketCount;
+@synthesize samples = _samples;
+
++ (void)enable {
+ webrtc::metrics::Enable();
tkchin_webrtc 2016/06/03 23:55:44 Are there other metric classes that we are expecti
åsapersson 2016/06/06 10:57:36 Done.
+}
+
++ (NSArray<RTCMetric *> *)getAndReset {
tkchin_webrtc 2016/06/03 23:55:44 the "get" prefix is not used in ObjC style for obj
åsapersson 2016/06/06 10:57:36 Done.
+ std::map<std::string, std::unique_ptr<webrtc::metrics::SampleInfo>>
+ histograms;
+ webrtc::metrics::GetAndReset(&histograms);
+
+ NSMutableArray* metrics =
+ [NSMutableArray arrayWithCapacity:histograms.size()];
+ for (auto const& histogram : histograms) {
+ RTCMetric* metric =
+ [[RTCMetric alloc] initWithNativeSampleInfo:*histogram.second];
+ [metrics addObject:metric];
+ }
+ return metrics;
+}
+
+#pragma mark - Private
+
+- (instancetype)initWithNativeSampleInfo:
tkchin_webrtc 2016/06/03 23:55:44 This class sounds like the ObjC version of webrtc:
åsapersson 2016/06/06 10:57:36 Moved this to a separate file RTCMetricsSampleInfo
+ (const webrtc::metrics::SampleInfo&)info {
+ if (self = [super init]) {
+ _name = [NSString stringForStdString:info.name];
+ _min = info.min;
+ _max = info.max;
+ _bucketCount = info.bucket_count;
+
+ NSMutableDictionary* samples =
+ [NSMutableDictionary dictionaryWithCapacity:info.samples.size()];
+ for (auto const& sample : info.samples) {
+ NSNumber* key = [NSNumber numberWithInt:sample.first];
tkchin_webrtc 2016/06/03 23:55:44 this can be simplified to: samples[@(sample.first)
åsapersson 2016/06/06 10:57:36 fails to compile on mac bots..
+ NSNumber* value = [NSNumber numberWithInt:sample.second];
+ [samples setObject:value forKey:key];
+ }
+ _samples = samples;
+ }
+ return self;
+}
+
+@end
« no previous file with comments | « webrtc/sdk/BUILD.gn ('k') | webrtc/sdk/objc/Framework/Classes/RTCMetric+Private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698