Index: chrome/browser/media/webrtc/rtc_stats_dictionary.h |
diff --git a/chrome/browser/media/webrtc/rtc_stats_dictionary.h b/chrome/browser/media/webrtc/rtc_stats_dictionary.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f623f535889cbfdf709ce42bcbd03740d70ea17f |
--- /dev/null |
+++ b/chrome/browser/media/webrtc/rtc_stats_dictionary.h |
@@ -0,0 +1,78 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_MEDIA_WEBRTC_RTC_STATS_DICTIONARY_H_ |
+#define CHROME_BROWSER_MEDIA_WEBRTC_RTC_STATS_DICTIONARY_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/values.h" |
+ |
+namespace content { |
+ |
+class RTCStatsDictionary; |
+ |
+class RTCStatsReportDictionary |
+ : public base::RefCounted<RTCStatsReportDictionary> { |
+ public: |
+ explicit RTCStatsReportDictionary( |
+ std::unique_ptr<base::DictionaryValue> report); |
+ |
+ std::unique_ptr<RTCStatsDictionary> Get(const std::string id); |
+ std::vector<RTCStatsDictionary> Filter( |
+ bool(*filter)(const RTCStatsDictionary& dictionary)); |
+ |
+ private: |
+ friend class base::RefCounted<RTCStatsReportDictionary>; |
+ ~RTCStatsReportDictionary(); |
+ |
+ std::unique_ptr<base::DictionaryValue> report_; |
+}; |
+ |
+class RTCStatsDictionary { |
+ public: |
+ RTCStatsDictionary(RTCStatsReportDictionary* report, |
+ const base::DictionaryValue* stats); |
+ RTCStatsDictionary(const RTCStatsDictionary& other); |
+ ~RTCStatsDictionary(); |
+ |
+ bool IsBoolean(const std::string& key) const; |
+ bool GetBoolean(const std::string& key) const; |
+ |
+ bool IsNumber(const std::string& key) const; |
+ double GetNumber(const std::string& key) const; |
+ |
+ bool IsString(const std::string& key) const; |
+ std::string GetString(const std::string& key) const; |
+ |
+ bool IsSequenceBoolean(const std::string& key) const; |
+ std::vector<bool> GetSequenceBoolean(const std::string& key) const; |
+ |
+ bool IsSequenceNumber(const std::string& key) const; |
+ std::vector<double> GetSequenceNumber(const std::string& key) const; |
+ |
+ bool IsSequenceString(const std::string& key) const; |
+ std::vector<std::string> GetSequenceString(const std::string& key) const; |
+ |
+ private: |
+ bool GetBoolean(const std::string& key, bool* out) const; |
+ bool GetNumber(const std::string& key, double* out) const; |
+ bool GetString(const std::string& key, std::string* out) const; |
+ bool GetSequenceBoolean( |
+ const std::string& key, std::vector<bool>* out) const; |
+ bool GetSequenceNumber( |
+ const std::string& key, std::vector<double>* out) const; |
+ bool GetSequenceString( |
+ const std::string& key, std::vector<std::string>* out) const; |
+ |
+ // The reference keeps the report alive which indirectly owns |stats_|. |
+ scoped_refptr<RTCStatsReportDictionary> report_; |
+ const base::DictionaryValue* stats_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CHROME_BROWSER_MEDIA_WEBRTC_RTC_STATS_DICTIONARY_H_ |