Home | History | Annotate | Download | only in crypto
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_SUPPORT_UMA_H_
      6 #define CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_SUPPORT_UMA_H_
      7 
      8 #include <string>
      9 
     10 #include "base/containers/scoped_ptr_hash_map.h"
     11 
     12 namespace content {
     13 
     14 // Key system support UMA statistics for queried key systems.
     15 // 1. The key system is queried (with or without a MIME type).
     16 // 2. The key system is queried with a MIME type.
     17 // 3. The queried key system is supported (with or without a MIME type). This is
     18 //    reported when the key system is supported when queried, regardless of
     19 //    whether a MIME type is specified.
     20 // 4. The queried key system is supported with a MIME type. This is reported
     21 //    when the key system is supported when queried without a MIME type
     22 //    specified.
     23 // Note: All 4 stats are only reported once per renderer process per key system.
     24 class KeySystemsSupportUMA {
     25  public:
     26   KeySystemsSupportUMA();
     27   ~KeySystemsSupportUMA();
     28 
     29   // Adds a |key_system| for which query/support statistics are reported.
     30   // If you use this function to add key system to report, make sure to update
     31   // AddKeySystemSupportActions() in tools/metrics/actions/extract_actions.py.
     32   void AddKeySystemToReport(const std::string& key_system);
     33 
     34   // Reports that the |key_system| is queried. When |has_type|, also reports
     35   // that the |key_system| with a MIME type is queried.
     36   void ReportKeySystemQuery(const std::string& key_system, bool has_type);
     37 
     38   // Reports that the queried |key_system| is supported. When |has_type| (a
     39   // a MIME type is specified in the query), also reports that the queried
     40   // |key_system| is supported with that MIME type.
     41   void ReportKeySystemSupport(const std::string& key_system, bool has_type);
     42 
     43  private:
     44   class Reporter;
     45 
     46   // Returns the Reporter for |key_system|. Returns NULL if |key_system| was not
     47   // added for UMA reporting.
     48   Reporter* GetReporter(const std::string& key_system);
     49 
     50   // Key system <-> Reporter map.
     51   typedef base::ScopedPtrHashMap<std::string, Reporter> Reporters;
     52   Reporters reporters_;
     53 };
     54 
     55 }  // namespace content
     56 
     57 #endif  // CONTENT_RENDERER_MEDIA_CRYPTO_KEY_SYSTEMS_SUPPORT_UMA_H_
     58