| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/media/media_internals.h" | 5 #include "content/browser/media/media_internals.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ~AudioLogImpl() override; | 95 ~AudioLogImpl() override; |
| 96 | 96 |
| 97 void OnCreated(int component_id, | 97 void OnCreated(int component_id, |
| 98 const media::AudioParameters& params, | 98 const media::AudioParameters& params, |
| 99 const std::string& device_id) override; | 99 const std::string& device_id) override; |
| 100 void OnStarted(int component_id) override; | 100 void OnStarted(int component_id) override; |
| 101 void OnStopped(int component_id) override; | 101 void OnStopped(int component_id) override; |
| 102 void OnClosed(int component_id) override; | 102 void OnClosed(int component_id) override; |
| 103 void OnError(int component_id) override; | 103 void OnError(int component_id) override; |
| 104 void OnSetVolume(int component_id, double volume) override; | 104 void OnSetVolume(int component_id, double volume) override; |
| 105 void OnSwitchOutputDevice(int component_id, |
| 106 const std::string& device_id) override; |
| 105 | 107 |
| 106 // Called by MediaInternals to update the WebContents title for a stream. | 108 // Called by MediaInternals to update the WebContents title for a stream. |
| 107 void SendWebContentsTitle(int component_id, | 109 void SendWebContentsTitle(int component_id, |
| 108 int render_process_id, | 110 int render_process_id, |
| 109 int render_frame_id); | 111 int render_frame_id); |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 void SendSingleStringUpdate(int component_id, | 114 void SendSingleStringUpdate(int component_id, |
| 113 const std::string& key, | 115 const std::string& key, |
| 114 const std::string& value); | 116 const std::string& value); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 182 |
| 181 void AudioLogImpl::OnSetVolume(int component_id, double volume) { | 183 void AudioLogImpl::OnSetVolume(int component_id, double volume) { |
| 182 base::DictionaryValue dict; | 184 base::DictionaryValue dict; |
| 183 StoreComponentMetadata(component_id, &dict); | 185 StoreComponentMetadata(component_id, &dict); |
| 184 dict.SetDouble("volume", volume); | 186 dict.SetDouble("volume", volume); |
| 185 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS, | 187 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS, |
| 186 FormatCacheKey(component_id), | 188 FormatCacheKey(component_id), |
| 187 kAudioLogUpdateFunction, &dict); | 189 kAudioLogUpdateFunction, &dict); |
| 188 } | 190 } |
| 189 | 191 |
| 192 void AudioLogImpl::OnSwitchOutputDevice(int component_id, |
| 193 const std::string& device_id) { |
| 194 base::DictionaryValue dict; |
| 195 StoreComponentMetadata(component_id, &dict); |
| 196 dict.SetString("device_id", device_id); |
| 197 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS, |
| 198 FormatCacheKey(component_id), |
| 199 kAudioLogUpdateFunction, &dict); |
| 200 } |
| 201 |
| 190 void AudioLogImpl::SendWebContentsTitle(int component_id, | 202 void AudioLogImpl::SendWebContentsTitle(int component_id, |
| 191 int render_process_id, | 203 int render_process_id, |
| 192 int render_frame_id) { | 204 int render_frame_id) { |
| 193 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 205 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 194 StoreComponentMetadata(component_id, dict.get()); | 206 StoreComponentMetadata(component_id, dict.get()); |
| 195 SendWebContentsTitleHelper(FormatCacheKey(component_id), dict.Pass(), | 207 SendWebContentsTitleHelper(FormatCacheKey(component_id), dict.Pass(), |
| 196 render_process_id, render_frame_id); | 208 render_process_id, render_frame_id); |
| 197 } | 209 } |
| 198 | 210 |
| 199 std::string AudioLogImpl::FormatCacheKey(int component_id) { | 211 std::string AudioLogImpl::FormatCacheKey(int component_id) { |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 CHECK( | 673 CHECK( |
| 662 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); | 674 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); |
| 663 existing_dict->MergeDictionary(value); | 675 existing_dict->MergeDictionary(value); |
| 664 } | 676 } |
| 665 } | 677 } |
| 666 | 678 |
| 667 SendUpdate(SerializeUpdate(function, value)); | 679 SendUpdate(SerializeUpdate(function, value)); |
| 668 } | 680 } |
| 669 | 681 |
| 670 } // namespace content | 682 } // namespace content |
| OLD | NEW |