Åsa Persson | 352b2d7 | 2015-04-15 18:00:40 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2015 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 | #include "webrtc/test/histogram.h" |
| 12 | |
| 13 | #include <map> |
| 14 | |
| 15 | #include "webrtc/system_wrappers/interface/metrics.h" |
| 16 | |
| 17 | // Test implementation of histogram methods in |
| 18 | // webrtc/system_wrappers/interface/metrics.h. |
| 19 | |
| 20 | namespace webrtc { |
| 21 | namespace { |
| 22 | // Map holding the last added sample to a histogram (mapped by histogram name). |
| 23 | std::map<std::string, int> histograms_; |
| 24 | } // namespace |
| 25 | |
| 26 | namespace metrics { |
| 27 | Histogram* HistogramFactoryGetCounts(const std::string& name, int min, int max, |
| 28 | int bucket_count) { return NULL; } |
| 29 | |
| 30 | Histogram* HistogramFactoryGetEnumeration(const std::string& name, |
| 31 | int boundary) { return NULL; } |
| 32 | |
| 33 | void HistogramAdd( |
| 34 | Histogram* histogram_pointer, const std::string& name, int sample) { |
| 35 | histograms_[name] = sample; |
| 36 | } |
| 37 | } // namespace metrics |
| 38 | |
| 39 | namespace test { |
| 40 | int LastHistogramSample(const std::string& name) { |
| 41 | std::map<std::string, int>::const_iterator it = histograms_.find(name); |
| 42 | if (it == histograms_.end()) { |
| 43 | return -1; |
| 44 | } |
| 45 | return it->second; |
| 46 | } |
| 47 | } // namespace test |
| 48 | } // namespace webrtc |
| 49 | |