| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/blink/webencryptedmediaclient_impl.h" | 5 #include "media/blink/webencryptedmediaclient_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( | 166 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( |
| 167 const blink::WebString& key_system) { | 167 const blink::WebString& key_system) { |
| 168 // Assumes that empty will not be found by GetKeySystemNameForUMA(). | 168 // Assumes that empty will not be found by GetKeySystemNameForUMA(). |
| 169 // TODO(sandersd): Avoid doing ASCII conversion more than once. | 169 // TODO(sandersd): Avoid doing ASCII conversion more than once. |
| 170 std::string key_system_ascii; | 170 std::string key_system_ascii; |
| 171 if (key_system.containsOnlyASCII()) | 171 if (key_system.containsOnlyASCII()) |
| 172 key_system_ascii = key_system.ascii(); | 172 key_system_ascii = key_system.ascii(); |
| 173 | 173 |
| 174 // Return a per-frame singleton so that UMA reports will be once-per-frame. | 174 // Return a per-frame singleton so that UMA reports will be once-per-frame. |
| 175 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); | 175 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); |
| 176 Reporter* reporter = reporters_.get(uma_name); | 176 std::unique_ptr<Reporter>& reporter = reporters_[uma_name]; |
| 177 if (!reporter) { | 177 if (!reporter) |
| 178 reporter = new Reporter(uma_name); | 178 reporter = base::MakeUnique<Reporter>(uma_name); |
| 179 reporters_.add(uma_name, base::WrapUnique(reporter)); | 179 return reporter.get(); |
| 180 } | |
| 181 return reporter; | |
| 182 } | 180 } |
| 183 | 181 |
| 184 } // namespace media | 182 } // namespace media |
| OLD | NEW |