2015-07-03 01:36:14 -07:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
2015-07-03 01:36:14 -07:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* 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.
|
2015-07-03 01:36:14 -07:00
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef API_FAKEMETRICSOBSERVER_H_
|
|
|
|
|
#define API_FAKEMETRICSOBSERVER_H_
|
2015-07-03 01:36:14 -07:00
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2017-02-01 01:55:59 -08:00
|
|
|
#include <vector>
|
2015-07-03 01:36:14 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/peerconnectioninterface.h"
|
|
|
|
|
#include "rtc_base/thread_checker.h"
|
2015-07-03 01:36:14 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class FakeMetricsObserver : public MetricsObserverInterface {
|
|
|
|
|
public:
|
|
|
|
|
FakeMetricsObserver();
|
|
|
|
|
void Reset();
|
|
|
|
|
|
2015-08-19 16:51:15 -07:00
|
|
|
void IncrementEnumCounter(PeerConnectionEnumCounterType,
|
|
|
|
|
int counter,
|
|
|
|
|
int counter_max) override;
|
2015-07-03 01:36:14 -07:00
|
|
|
void AddHistogramSample(PeerConnectionMetricsName type,
|
|
|
|
|
int value) override;
|
|
|
|
|
|
|
|
|
|
// Accessors to be used by the tests.
|
2015-08-19 16:51:15 -07:00
|
|
|
int GetEnumCounter(PeerConnectionEnumCounterType type, int counter) const;
|
2015-09-30 21:48:54 -07:00
|
|
|
int GetHistogramSample(PeerConnectionMetricsName type) const;
|
2015-07-03 01:36:14 -07:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
~FakeMetricsObserver() {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
rtc::ThreadChecker thread_checker_;
|
2015-09-30 21:48:54 -07:00
|
|
|
// The vector contains maps for each counter type. In the map, it's a mapping
|
|
|
|
|
// from individual counter to its count, such that it's memory efficient when
|
|
|
|
|
// comes to sparse enum types, like the SSL ciphers in the IANA registry.
|
|
|
|
|
std::vector<std::map<int, int>> counters_;
|
|
|
|
|
int histogram_samples_[kPeerConnectionMetricsName_Max];
|
2015-07-03 01:36:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // API_FAKEMETRICSOBSERVER_H_
|