1ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch/* 2ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * libjingle 3ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * Copyright 2015 Google Inc. 4ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 5ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * Redistribution and use in source and binary forms, with or without 6ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * modification, are permitted provided that the following conditions are met: 7ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 8ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 1. Redistributions of source code must retain the above copyright notice, 9ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * this list of conditions and the following disclaimer. 10ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 2. Redistributions in binary form must reproduce the above copyright notice, 11ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * this list of conditions and the following disclaimer in the documentation 12ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * and/or other materials provided with the distribution. 13ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 3. The name of the author may not be used to endorse or promote products 14ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * derived from this software without specific prior written permission. 15ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * 16ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch */ 27ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 28ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#ifndef TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ 29ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#define TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ 30ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 31ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#include <map> 32ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#include <string> 33ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 34ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#include "talk/app/webrtc/peerconnectioninterface.h" 35ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#include "webrtc/base/thread_checker.h" 36ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 37ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauchnamespace webrtc { 38ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 39ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauchclass FakeMetricsObserver : public MetricsObserverInterface { 40ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch public: 41ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch FakeMetricsObserver(); 42ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch void Reset(); 43ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 443d564c10157d7de1d2d4236f4e2a13ff1363d52bGuo-wei Shieh void IncrementEnumCounter(PeerConnectionEnumCounterType, 453d564c10157d7de1d2d4236f4e2a13ff1363d52bGuo-wei Shieh int counter, 463d564c10157d7de1d2d4236f4e2a13ff1363d52bGuo-wei Shieh int counter_max) override; 47ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch void AddHistogramSample(PeerConnectionMetricsName type, 48ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch int value) override; 49ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 50ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch // Accessors to be used by the tests. 513d564c10157d7de1d2d4236f4e2a13ff1363d52bGuo-wei Shieh int GetEnumCounter(PeerConnectionEnumCounterType type, int counter) const; 52456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh int GetHistogramSample(PeerConnectionMetricsName type) const; 53ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 54ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch protected: 55ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch ~FakeMetricsObserver() {} 56ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 57ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch private: 58ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch rtc::ThreadChecker thread_checker_; 59456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh // The vector contains maps for each counter type. In the map, it's a mapping 60456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh // from individual counter to its count, such that it's memory efficient when 61456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh // comes to sparse enum types, like the SSL ciphers in the IANA registry. 62456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh std::vector<std::map<int, int>> counters_; 63456696a9c1bbd586701dcca3e4b2695e419a10baGuo-wei Shieh int histogram_samples_[kPeerConnectionMetricsName_Max]; 64ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch}; 65ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 66ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch} // namespace webrtc 67ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch 68ac8869ec5a606e0a0ab71e70937c8fbf403630cejbauch#endif // TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ 69