Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: content/browser/media/media_internals.cc

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 int status; 659 int status;
660 if (!event.params.GetInteger("pipeline_error", &status) || 660 if (!event.params.GetInteger("pipeline_error", &status) ||
661 status < static_cast<int>(media::PIPELINE_OK) || 661 status < static_cast<int>(media::PIPELINE_OK) ||
662 status > static_cast<int>(media::PIPELINE_STATUS_MAX)) { 662 status > static_cast<int>(media::PIPELINE_STATUS_MAX)) {
663 return false; 663 return false;
664 } 664 }
665 media::PipelineStatus error = static_cast<media::PipelineStatus>(status); 665 media::PipelineStatus error = static_cast<media::PipelineStatus>(status);
666 dict.SetString("params.pipeline_error", 666 dict.SetString("params.pipeline_error",
667 media::MediaLog::PipelineStatusToString(error)); 667 media::MediaLog::PipelineStatusToString(error));
668 } else { 668 } else {
669 dict.Set("params", event.params.DeepCopy()); 669 dict.Set("params", base::MakeUnique<base::Value>(event.params));
670 } 670 }
671 671
672 *update = SerializeUpdate("media.onMediaEvent", &dict); 672 *update = SerializeUpdate("media.onMediaEvent", &dict);
673 return true; 673 return true;
674 } 674 }
675 675
676 void MediaInternals::OnMediaEvents( 676 void MediaInternals::OnMediaEvents(
677 int render_process_id, const std::vector<media::MediaLogEvent>& events) { 677 int render_process_id, const std::vector<media::MediaLogEvent>& events) {
678 DCHECK_CURRENTLY_ON(BrowserThread::UI); 678 DCHECK_CURRENTLY_ON(BrowserThread::UI);
679 // Notify observers that |event| has occurred. 679 // Notify observers that |event| has occurred.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 } 751 }
752 752
753 void MediaInternals::UpdateVideoCaptureDeviceCapabilities( 753 void MediaInternals::UpdateVideoCaptureDeviceCapabilities(
754 const std::vector<std::tuple<media::VideoCaptureDeviceDescriptor, 754 const std::vector<std::tuple<media::VideoCaptureDeviceDescriptor,
755 media::VideoCaptureFormats>>& 755 media::VideoCaptureFormats>>&
756 descriptors_and_formats) { 756 descriptors_and_formats) {
757 DCHECK_CURRENTLY_ON(BrowserThread::IO); 757 DCHECK_CURRENTLY_ON(BrowserThread::IO);
758 video_capture_capabilities_cached_data_.Clear(); 758 video_capture_capabilities_cached_data_.Clear();
759 759
760 for (const auto& device_format_pair : descriptors_and_formats) { 760 for (const auto& device_format_pair : descriptors_and_formats) {
761 base::ListValue* format_list = new base::ListValue(); 761 auto format_list = base::MakeUnique<base::ListValue>();
762 // TODO(nisse): Representing format information as a string, to be 762 // TODO(nisse): Representing format information as a string, to be
763 // parsed by the javascript handler, is brittle. Consider passing 763 // parsed by the javascript handler, is brittle. Consider passing
764 // a list of mappings instead. 764 // a list of mappings instead.
765 765
766 const media::VideoCaptureDeviceDescriptor& descriptor = 766 const media::VideoCaptureDeviceDescriptor& descriptor =
767 std::get<0>(device_format_pair); 767 std::get<0>(device_format_pair);
768 const media::VideoCaptureFormats& supported_formats = 768 const media::VideoCaptureFormats& supported_formats =
769 std::get<1>(device_format_pair); 769 std::get<1>(device_format_pair);
770 for (const auto& format : supported_formats) 770 for (const auto& format : supported_formats)
771 format_list->AppendString(media::VideoCaptureFormat::ToString(format)); 771 format_list->AppendString(media::VideoCaptureFormat::ToString(format));
772 772
773 std::unique_ptr<base::DictionaryValue> device_dict( 773 std::unique_ptr<base::DictionaryValue> device_dict(
774 new base::DictionaryValue()); 774 new base::DictionaryValue());
775 device_dict->SetString("id", descriptor.device_id); 775 device_dict->SetString("id", descriptor.device_id);
776 device_dict->SetString("name", descriptor.GetNameAndModel()); 776 device_dict->SetString("name", descriptor.GetNameAndModel());
777 device_dict->Set("formats", format_list); 777 device_dict->Set("formats", std::move(format_list));
778 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ 778 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \
779 defined(OS_ANDROID) 779 defined(OS_ANDROID)
780 device_dict->SetString("captureApi", descriptor.GetCaptureApiTypeString()); 780 device_dict->SetString("captureApi", descriptor.GetCaptureApiTypeString());
781 #endif 781 #endif
782 video_capture_capabilities_cached_data_.Append(std::move(device_dict)); 782 video_capture_capabilities_cached_data_.Append(std::move(device_dict));
783 } 783 }
784 784
785 SendVideoCaptureDeviceCapabilities(); 785 SendVideoCaptureDeviceCapabilities();
786 } 786 }
787 787
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 const std::string& cache_key, 850 const std::string& cache_key,
851 const std::string& function, 851 const std::string& function,
852 const base::DictionaryValue* value) { 852 const base::DictionaryValue* value) {
853 { 853 {
854 base::AutoLock auto_lock(lock_); 854 base::AutoLock auto_lock(lock_);
855 const bool has_entry = audio_streams_cached_data_.HasKey(cache_key); 855 const bool has_entry = audio_streams_cached_data_.HasKey(cache_key);
856 if ((type == UPDATE_IF_EXISTS || type == UPDATE_AND_DELETE) && !has_entry) { 856 if ((type == UPDATE_IF_EXISTS || type == UPDATE_AND_DELETE) && !has_entry) {
857 return; 857 return;
858 } else if (!has_entry) { 858 } else if (!has_entry) {
859 DCHECK_EQ(type, CREATE); 859 DCHECK_EQ(type, CREATE);
860 audio_streams_cached_data_.Set(cache_key, value->DeepCopy()); 860 audio_streams_cached_data_.Set(cache_key,
861 base::MakeUnique<base::Value>(*value));
861 } else if (type == UPDATE_AND_DELETE) { 862 } else if (type == UPDATE_AND_DELETE) {
862 std::unique_ptr<base::Value> out_value; 863 std::unique_ptr<base::Value> out_value;
863 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); 864 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value));
864 } else { 865 } else {
865 base::DictionaryValue* existing_dict = NULL; 866 base::DictionaryValue* existing_dict = NULL;
866 CHECK( 867 CHECK(
867 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); 868 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict));
868 existing_dict->MergeDictionary(value); 869 existing_dict->MergeDictionary(value);
869 } 870 }
870 } 871 }
871 872
872 if (CanUpdate()) 873 if (CanUpdate())
873 SendUpdate(SerializeUpdate(function, value)); 874 SendUpdate(SerializeUpdate(function, value));
874 } 875 }
875 876
876 } // namespace content 877 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_context_impl.cc ('k') | content/browser/media/media_internals_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698