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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #import "RTCMetric+Private.h"
12
13 #import "NSString+StdString.h"
14
15 @implementation RTCMetric
16
17 @synthesize name = _name;
18 @synthesize min = _min;
19 @synthesize max = _max;
20 @synthesize bucketCount = _bucketCount;
21 @synthesize samples = _samples;
22
23 + (void)enable {
24 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.
25 }
26
27 + (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.
28 std::map<std::string, std::unique_ptr<webrtc::metrics::SampleInfo>>
29 histograms;
30 webrtc::metrics::GetAndReset(&histograms);
31
32 NSMutableArray* metrics =
33 [NSMutableArray arrayWithCapacity:histograms.size()];
34 for (auto const& histogram : histograms) {
35 RTCMetric* metric =
36 [[RTCMetric alloc] initWithNativeSampleInfo:*histogram.second];
37 [metrics addObject:metric];
38 }
39 return metrics;
40 }
41
42 #pragma mark - Private
43
44 - (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
45 (const webrtc::metrics::SampleInfo&)info {
46 if (self = [super init]) {
47 _name = [NSString stringForStdString:info.name];
48 _min = info.min;
49 _max = info.max;
50 _bucketCount = info.bucket_count;
51
52 NSMutableDictionary* samples =
53 [NSMutableDictionary dictionaryWithCapacity:info.samples.size()];
54 for (auto const& sample : info.samples) {
55 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..
56 NSNumber* value = [NSNumber numberWithInt:sample.second];
57 [samples setObject:value forKey:key];
58 }
59 _samples = samples;
60 }
61 return self;
62 }
63
64 @end
OLDNEW
« 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