Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * libjingle | |
| 3 * Copyright 2015 Google Inc. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | |
| 9 * this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 * this list of conditions and the following disclaimer in the documentation | |
| 12 * and/or other materials provided with the distribution. | |
| 13 * 3. The name of the author may not be used to endorse or promote products | |
| 14 * derived from this software without specific prior written permission. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 */ | |
| 27 | |
| 28 #ifndef TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ | |
| 29 #define TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ | |
| 30 | |
| 31 #include <map> | |
| 32 #include <string> | |
| 33 | |
| 34 #include "talk/app/webrtc/peerconnectioninterface.h" | |
| 35 | |
| 36 namespace webrtc { | |
| 37 | |
| 38 class FakeMetricsObserver : public MetricsObserverInterface { | |
| 39 public: | |
| 40 FakeMetricsObserver() { Reset(); } | |
| 41 void Reset() { | |
|
tommi (sloooow) - chröme
2015/07/02 11:32:29
Is this method necessary? (can we just do this in
joachim
2015/07/02 22:06:06
Reset is used by the unittests, so this needs to s
| |
| 42 memset(counters_, 0, sizeof(counters_)); | |
| 43 memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_)); | |
| 44 for (std::string& type : string_histogram_samples_) { | |
| 45 type.clear(); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 void IncrementCounter(PeerConnectionMetricsCounter type) override { | |
| 50 counters_[type]++; | |
|
tommi (sloooow) - chröme
2015/07/02 11:32:29
nit: ++counters_[type];
It looks like this class
joachim
2015/07/02 22:06:06
Done.
| |
| 51 } | |
| 52 void AddHistogramSample(PeerConnectionMetricsName type, | |
| 53 int value) override { | |
| 54 ASSERT(int_histogram_samples_[type] == 0); | |
|
tommi (sloooow) - chröme
2015/07/02 11:32:29
can we use DCHECK instead of ASSERT (see checks.h)
joachim
2015/07/02 22:06:05
Done.
| |
| 55 int_histogram_samples_[type] = value; | |
| 56 } | |
| 57 void AddHistogramSample(PeerConnectionMetricsName type, | |
| 58 const std::string& value) override { | |
| 59 string_histogram_samples_[type].assign(value); | |
| 60 } | |
| 61 | |
| 62 // Accessors to be used by the tests. | |
| 63 int GetCounter(PeerConnectionMetricsCounter type) const { | |
| 64 return counters_[type]; | |
| 65 } | |
| 66 int GetIntHistogramSample(PeerConnectionMetricsName type) const { | |
| 67 return int_histogram_samples_[type]; | |
| 68 } | |
| 69 const std::string& GetStringHistogramSample( | |
| 70 PeerConnectionMetricsName type) const { | |
| 71 return string_histogram_samples_[type]; | |
| 72 } | |
| 73 | |
| 74 int AddRef() override { return 1; } | |
|
tommi (sloooow) - chröme
2015/07/02 11:32:29
why not implement proper reference counting? See
joachim
2015/07/02 22:06:05
I assume it was done like this because the class w
| |
| 75 int Release() override { return 1; } | |
| 76 | |
| 77 private: | |
| 78 int counters_[kPeerConnectionMetricsCounter_Max]; | |
| 79 int int_histogram_samples_[kPeerConnectionMetricsCounter_Max]; | |
| 80 std::string string_histogram_samples_[kPeerConnectionMetricsName_Max]; | |
| 81 }; | |
| 82 | |
| 83 } // namespace webrtc | |
| 84 | |
| 85 #endif // TALK_APP_WEBRTC_FAKEMETRICSOBSERVER_H_ | |
| OLD | NEW |