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/renderer/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #include "third_party/WebKit/public/platform/BlameContext.h" | 87 #include "third_party/WebKit/public/platform/BlameContext.h" |
88 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 88 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
89 #include "third_party/WebKit/public/platform/URLConversion.h" | 89 #include "third_party/WebKit/public/platform/URLConversion.h" |
90 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" | 90 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" |
91 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 91 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
92 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 92 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
93 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 93 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
94 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 94 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
95 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 95 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
96 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 96 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 97 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h" |
97 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 98 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
98 #include "third_party/WebKit/public/platform/WebThread.h" | 99 #include "third_party/WebKit/public/platform/WebThread.h" |
99 #include "third_party/WebKit/public/platform/WebURL.h" | 100 #include "third_party/WebKit/public/platform/WebURL.h" |
100 #include "third_party/WebKit/public/platform/WebVector.h" | 101 #include "third_party/WebKit/public/platform/WebVector.h" |
101 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" | 102 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" |
102 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationListener.h" | 103 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationListener.h" |
| 104 #include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessor.h" |
103 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 105 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
104 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 106 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
105 #include "url/gurl.h" | 107 #include "url/gurl.h" |
106 | 108 |
107 #if defined(OS_MACOSX) | 109 #if defined(OS_MACOSX) |
108 #include "content/common/mac/font_descriptor.h" | 110 #include "content/common/mac/font_descriptor.h" |
109 #include "content/common/mac/font_loader.h" | 111 #include "content/common/mac/font_loader.h" |
110 #include "content/renderer/webscrollbarbehavior_impl_mac.h" | 112 #include "content/renderer/webscrollbarbehavior_impl_mac.h" |
111 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" | 113 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" |
112 #endif | 114 #endif |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 using blink::Platform; | 146 using blink::Platform; |
145 using blink::WebAudioDevice; | 147 using blink::WebAudioDevice; |
146 using blink::WebAudioLatencyHint; | 148 using blink::WebAudioLatencyHint; |
147 using blink::WebBlobRegistry; | 149 using blink::WebBlobRegistry; |
148 using blink::WebCanvasCaptureHandler; | 150 using blink::WebCanvasCaptureHandler; |
149 using blink::WebDatabaseObserver; | 151 using blink::WebDatabaseObserver; |
150 using blink::WebFileInfo; | 152 using blink::WebFileInfo; |
151 using blink::WebFileSystem; | 153 using blink::WebFileSystem; |
152 using blink::WebIDBFactory; | 154 using blink::WebIDBFactory; |
153 using blink::WebImageCaptureFrameGrabber; | 155 using blink::WebImageCaptureFrameGrabber; |
154 using blink::WebMIDIAccessor; | |
155 using blink::WebMediaPlayer; | 156 using blink::WebMediaPlayer; |
156 using blink::WebMediaRecorderHandler; | 157 using blink::WebMediaRecorderHandler; |
157 using blink::WebMediaStream; | 158 using blink::WebMediaStream; |
158 using blink::WebMediaStreamCenter; | 159 using blink::WebMediaStreamCenter; |
159 using blink::WebMediaStreamCenterClient; | 160 using blink::WebMediaStreamCenterClient; |
160 using blink::WebMediaStreamTrack; | 161 using blink::WebMediaStreamTrack; |
161 using blink::WebRTCPeerConnectionHandler; | 162 using blink::WebRTCPeerConnectionHandler; |
162 using blink::WebRTCPeerConnectionHandlerClient; | 163 using blink::WebRTCPeerConnectionHandlerClient; |
163 using blink::WebStorageNamespace; | 164 using blink::WebStorageNamespace; |
164 using blink::WebSize; | 165 using blink::WebSize; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 sudden_termination_disables_++; | 460 sudden_termination_disables_++; |
460 if (sudden_termination_disables_ != 1) | 461 if (sudden_termination_disables_ != 1) |
461 return; | 462 return; |
462 } | 463 } |
463 | 464 |
464 RenderThread* thread = RenderThread::Get(); | 465 RenderThread* thread = RenderThread::Get(); |
465 if (thread) // NULL in unittests. | 466 if (thread) // NULL in unittests. |
466 thread->Send(new RenderProcessHostMsg_SuddenTerminationChanged(enabled)); | 467 thread->Send(new RenderProcessHostMsg_SuddenTerminationChanged(enabled)); |
467 } | 468 } |
468 | 469 |
469 WebStorageNamespace* RendererBlinkPlatformImpl::CreateLocalStorageNamespace() { | 470 std::unique_ptr<WebStorageNamespace> |
| 471 RendererBlinkPlatformImpl::CreateLocalStorageNamespace() { |
470 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 472 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
471 switches::kMojoLocalStorage)) { | 473 switches::kMojoLocalStorage)) { |
472 if (!local_storage_cached_areas_) { | 474 if (!local_storage_cached_areas_) { |
473 local_storage_cached_areas_.reset(new LocalStorageCachedAreas( | 475 local_storage_cached_areas_.reset(new LocalStorageCachedAreas( |
474 RenderThreadImpl::current()->GetStoragePartitionService())); | 476 RenderThreadImpl::current()->GetStoragePartitionService())); |
475 } | 477 } |
476 return new LocalStorageNamespace(local_storage_cached_areas_.get()); | 478 return base::MakeUnique<LocalStorageNamespace>( |
| 479 local_storage_cached_areas_.get()); |
477 } | 480 } |
478 | 481 |
479 return new WebStorageNamespaceImpl(); | 482 return base::MakeUnique<WebStorageNamespaceImpl>(); |
480 } | 483 } |
481 | 484 |
482 | 485 |
483 //------------------------------------------------------------------------------ | 486 //------------------------------------------------------------------------------ |
484 | 487 |
485 WebIDBFactory* RendererBlinkPlatformImpl::IdbFactory() { | 488 WebIDBFactory* RendererBlinkPlatformImpl::IdbFactory() { |
486 return web_idb_factory_.get(); | 489 return web_idb_factory_.get(); |
487 } | 490 } |
488 | 491 |
489 //------------------------------------------------------------------------------ | 492 //------------------------------------------------------------------------------ |
490 | 493 |
491 blink::WebServiceWorkerCacheStorage* RendererBlinkPlatformImpl::CacheStorage( | 494 std::unique_ptr<blink::WebServiceWorkerCacheStorage> |
| 495 RendererBlinkPlatformImpl::CreateCacheStorage( |
492 const blink::WebSecurityOrigin& security_origin) { | 496 const blink::WebSecurityOrigin& security_origin) { |
493 return new WebServiceWorkerCacheStorageImpl(thread_safe_sender_.get(), | 497 return base::MakeUnique<WebServiceWorkerCacheStorageImpl>( |
494 security_origin); | 498 thread_safe_sender_.get(), security_origin); |
495 } | 499 } |
496 | 500 |
497 //------------------------------------------------------------------------------ | 501 //------------------------------------------------------------------------------ |
498 | 502 |
499 WebFileSystem* RendererBlinkPlatformImpl::FileSystem() { | 503 WebFileSystem* RendererBlinkPlatformImpl::FileSystem() { |
500 return WebFileSystemImpl::ThreadSpecificInstance(default_task_runner_); | 504 return WebFileSystemImpl::ThreadSpecificInstance(default_task_runner_); |
501 } | 505 } |
502 | 506 |
503 WebString RendererBlinkPlatformImpl::FileSystemCreateOriginIdentifier( | 507 WebString RendererBlinkPlatformImpl::FileSystemCreateOriginIdentifier( |
504 const blink::WebSecurityOrigin& origin) { | 508 const blink::WebSecurityOrigin& origin) { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 681 } |
678 | 682 |
679 unsigned RendererBlinkPlatformImpl::AudioHardwareOutputChannels() { | 683 unsigned RendererBlinkPlatformImpl::AudioHardwareOutputChannels() { |
680 return GetAudioHardwareParams().channels(); | 684 return GetAudioHardwareParams().channels(); |
681 } | 685 } |
682 | 686 |
683 WebDatabaseObserver* RendererBlinkPlatformImpl::DatabaseObserver() { | 687 WebDatabaseObserver* RendererBlinkPlatformImpl::DatabaseObserver() { |
684 return web_database_observer_impl_.get(); | 688 return web_database_observer_impl_.get(); |
685 } | 689 } |
686 | 690 |
687 WebAudioDevice* RendererBlinkPlatformImpl::CreateAudioDevice( | 691 std::unique_ptr<WebAudioDevice> RendererBlinkPlatformImpl::CreateAudioDevice( |
688 unsigned input_channels, | 692 unsigned input_channels, |
689 unsigned channels, | 693 unsigned channels, |
690 const blink::WebAudioLatencyHint& latency_hint, | 694 const blink::WebAudioLatencyHint& latency_hint, |
691 WebAudioDevice::RenderCallback* callback, | 695 WebAudioDevice::RenderCallback* callback, |
692 const blink::WebString& input_device_id, | 696 const blink::WebString& input_device_id, |
693 const blink::WebSecurityOrigin& security_origin) { | 697 const blink::WebSecurityOrigin& security_origin) { |
694 // Use a mock for testing. | 698 // Use a mock for testing. |
695 blink::WebAudioDevice* mock_device = | 699 std::unique_ptr<blink::WebAudioDevice> mock_device = |
696 GetContentClient()->renderer()->OverrideCreateAudioDevice(latency_hint); | 700 GetContentClient()->renderer()->OverrideCreateAudioDevice(latency_hint); |
697 if (mock_device) | 701 if (mock_device) |
698 return mock_device; | 702 return mock_device; |
699 | 703 |
700 // The |channels| does not exactly identify the channel layout of the | 704 // The |channels| does not exactly identify the channel layout of the |
701 // device. The switch statement below assigns a best guess to the channel | 705 // device. The switch statement below assigns a best guess to the channel |
702 // layout based on number of channels. | 706 // layout based on number of channels. |
703 media::ChannelLayout layout = media::GuessChannelLayout(channels); | 707 media::ChannelLayout layout = media::GuessChannelLayout(channels); |
704 if (layout == media::CHANNEL_LAYOUT_UNSUPPORTED) | 708 if (layout == media::CHANNEL_LAYOUT_UNSUPPORTED) |
705 layout = media::CHANNEL_LAYOUT_DISCRETE; | 709 layout = media::CHANNEL_LAYOUT_DISCRETE; |
(...skipping 12 matching lines...) Expand all Loading... |
718 bool RendererBlinkPlatformImpl::LoadAudioResource( | 722 bool RendererBlinkPlatformImpl::LoadAudioResource( |
719 blink::WebAudioBus* destination_bus, | 723 blink::WebAudioBus* destination_bus, |
720 const char* audio_file_data, | 724 const char* audio_file_data, |
721 size_t data_size) { | 725 size_t data_size) { |
722 return DecodeAudioFileData( | 726 return DecodeAudioFileData( |
723 destination_bus, audio_file_data, data_size); | 727 destination_bus, audio_file_data, data_size); |
724 } | 728 } |
725 | 729 |
726 //------------------------------------------------------------------------------ | 730 //------------------------------------------------------------------------------ |
727 | 731 |
728 blink::WebMIDIAccessor* RendererBlinkPlatformImpl::CreateMIDIAccessor( | 732 std::unique_ptr<blink::WebMIDIAccessor> |
| 733 RendererBlinkPlatformImpl::CreateMIDIAccessor( |
729 blink::WebMIDIAccessorClient* client) { | 734 blink::WebMIDIAccessorClient* client) { |
730 blink::WebMIDIAccessor* accessor = | 735 std::unique_ptr<blink::WebMIDIAccessor> accessor = |
731 GetContentClient()->renderer()->OverrideCreateMIDIAccessor(client); | 736 GetContentClient()->renderer()->OverrideCreateMIDIAccessor(client); |
732 if (accessor) | 737 if (accessor) |
733 return accessor; | 738 return accessor; |
734 | 739 |
735 return new RendererWebMIDIAccessorImpl(client); | 740 return base::MakeUnique<RendererWebMIDIAccessorImpl>(client); |
736 } | 741 } |
737 | 742 |
738 void RendererBlinkPlatformImpl::GetPluginList( | 743 void RendererBlinkPlatformImpl::GetPluginList( |
739 bool refresh, | 744 bool refresh, |
740 const blink::WebSecurityOrigin& mainFrameOrigin, | 745 const blink::WebSecurityOrigin& mainFrameOrigin, |
741 blink::WebPluginListBuilder* builder) { | 746 blink::WebPluginListBuilder* builder) { |
742 #if BUILDFLAG(ENABLE_PLUGINS) | 747 #if BUILDFLAG(ENABLE_PLUGINS) |
743 std::vector<WebPluginInfo> plugins; | 748 std::vector<WebPluginInfo> plugins; |
744 if (!plugin_refresh_allowed_) | 749 if (!plugin_refresh_allowed_) |
745 refresh = false; | 750 refresh = false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 void RendererBlinkPlatformImpl::SampleGamepads(device::Gamepads& gamepads) { | 793 void RendererBlinkPlatformImpl::SampleGamepads(device::Gamepads& gamepads) { |
789 PlatformEventObserverBase* observer = | 794 PlatformEventObserverBase* observer = |
790 platform_event_observers_.Lookup(blink::kWebPlatformEventTypeGamepad); | 795 platform_event_observers_.Lookup(blink::kWebPlatformEventTypeGamepad); |
791 if (!observer) | 796 if (!observer) |
792 return; | 797 return; |
793 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads); | 798 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads); |
794 } | 799 } |
795 | 800 |
796 //------------------------------------------------------------------------------ | 801 //------------------------------------------------------------------------------ |
797 | 802 |
798 WebMediaRecorderHandler* | 803 std::unique_ptr<WebMediaRecorderHandler> |
799 RendererBlinkPlatformImpl::CreateMediaRecorderHandler() { | 804 RendererBlinkPlatformImpl::CreateMediaRecorderHandler() { |
800 #if BUILDFLAG(ENABLE_WEBRTC) | 805 #if BUILDFLAG(ENABLE_WEBRTC) |
801 return new content::MediaRecorderHandler(); | 806 return base::MakeUnique<content::MediaRecorderHandler>(); |
802 #else | 807 #else |
803 return nullptr; | 808 return nullptr; |
804 #endif | 809 #endif |
805 } | 810 } |
806 | 811 |
807 //------------------------------------------------------------------------------ | 812 //------------------------------------------------------------------------------ |
808 | 813 |
809 WebRTCPeerConnectionHandler* | 814 std::unique_ptr<WebRTCPeerConnectionHandler> |
810 RendererBlinkPlatformImpl::CreateRTCPeerConnectionHandler( | 815 RendererBlinkPlatformImpl::CreateRTCPeerConnectionHandler( |
811 WebRTCPeerConnectionHandlerClient* client) { | 816 WebRTCPeerConnectionHandlerClient* client) { |
812 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 817 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
813 DCHECK(render_thread); | 818 DCHECK(render_thread); |
814 if (!render_thread) | 819 if (!render_thread) |
815 return NULL; | 820 return nullptr; |
816 | 821 |
817 #if BUILDFLAG(ENABLE_WEBRTC) | 822 #if BUILDFLAG(ENABLE_WEBRTC) |
818 WebRTCPeerConnectionHandler* peer_connection_handler = | 823 std::unique_ptr<WebRTCPeerConnectionHandler> peer_connection_handler = |
819 GetContentClient()->renderer()->OverrideCreateWebRTCPeerConnectionHandler( | 824 GetContentClient()->renderer()->OverrideCreateWebRTCPeerConnectionHandler( |
820 client); | 825 client); |
821 if (peer_connection_handler) | 826 if (peer_connection_handler) |
822 return peer_connection_handler; | 827 return peer_connection_handler; |
823 | 828 |
824 PeerConnectionDependencyFactory* rtc_dependency_factory = | 829 PeerConnectionDependencyFactory* rtc_dependency_factory = |
825 render_thread->GetPeerConnectionDependencyFactory(); | 830 render_thread->GetPeerConnectionDependencyFactory(); |
826 return rtc_dependency_factory->CreateRTCPeerConnectionHandler(client); | 831 return rtc_dependency_factory->CreateRTCPeerConnectionHandler(client); |
827 #else | 832 #else |
828 return NULL; | 833 return nullptr; |
829 #endif // BUILDFLAG(ENABLE_WEBRTC) | 834 #endif // BUILDFLAG(ENABLE_WEBRTC) |
830 } | 835 } |
831 | 836 |
832 //------------------------------------------------------------------------------ | 837 //------------------------------------------------------------------------------ |
833 | 838 |
834 blink::WebRTCCertificateGenerator* | 839 std::unique_ptr<blink::WebRTCCertificateGenerator> |
835 RendererBlinkPlatformImpl::CreateRTCCertificateGenerator() { | 840 RendererBlinkPlatformImpl::CreateRTCCertificateGenerator() { |
836 #if BUILDFLAG(ENABLE_WEBRTC) | 841 #if BUILDFLAG(ENABLE_WEBRTC) |
837 return new RTCCertificateGenerator(); | 842 return base::MakeUnique<RTCCertificateGenerator>(); |
838 #else | 843 #else |
839 return nullptr; | 844 return nullptr; |
840 #endif // BUILDFLAG(ENABLE_WEBRTC) | 845 #endif // BUILDFLAG(ENABLE_WEBRTC) |
841 } | 846 } |
842 | 847 |
843 //------------------------------------------------------------------------------ | 848 //------------------------------------------------------------------------------ |
844 | 849 |
845 WebMediaStreamCenter* RendererBlinkPlatformImpl::CreateMediaStreamCenter( | 850 std::unique_ptr<WebMediaStreamCenter> |
| 851 RendererBlinkPlatformImpl::CreateMediaStreamCenter( |
846 WebMediaStreamCenterClient* client) { | 852 WebMediaStreamCenterClient* client) { |
847 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 853 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
848 DCHECK(render_thread); | 854 DCHECK(render_thread); |
849 if (!render_thread) | 855 if (!render_thread) |
850 return NULL; | 856 return nullptr; |
851 return render_thread->CreateMediaStreamCenter(client); | 857 return render_thread->CreateMediaStreamCenter(client); |
852 } | 858 } |
853 | 859 |
854 // static | 860 // static |
855 bool RendererBlinkPlatformImpl::SetSandboxEnabledForTesting(bool enable) { | 861 bool RendererBlinkPlatformImpl::SetSandboxEnabledForTesting(bool enable) { |
856 bool was_enabled = g_sandbox_enabled; | 862 bool was_enabled = g_sandbox_enabled; |
857 g_sandbox_enabled = enable; | 863 g_sandbox_enabled = enable; |
858 return was_enabled; | 864 return was_enabled; |
859 } | 865 } |
860 | 866 |
861 //------------------------------------------------------------------------------ | 867 //------------------------------------------------------------------------------ |
862 | 868 |
863 WebCanvasCaptureHandler* RendererBlinkPlatformImpl::CreateCanvasCaptureHandler( | 869 std::unique_ptr<WebCanvasCaptureHandler> |
| 870 RendererBlinkPlatformImpl::CreateCanvasCaptureHandler( |
864 const WebSize& size, | 871 const WebSize& size, |
865 double frame_rate, | 872 double frame_rate, |
866 WebMediaStreamTrack* track) { | 873 WebMediaStreamTrack* track) { |
867 #if BUILDFLAG(ENABLE_WEBRTC) | 874 #if BUILDFLAG(ENABLE_WEBRTC) |
868 return CanvasCaptureHandler::CreateCanvasCaptureHandler( | 875 return CanvasCaptureHandler::CreateCanvasCaptureHandler( |
869 size, frame_rate, RenderThread::Get()->GetIOTaskRunner(), track); | 876 size, frame_rate, RenderThread::Get()->GetIOTaskRunner(), track); |
870 #else | 877 #else |
871 return nullptr; | 878 return nullptr; |
872 #endif // BUILDFLAG(ENABLE_WEBRTC) | 879 #endif // BUILDFLAG(ENABLE_WEBRTC) |
873 } | 880 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 // Takes ownership of |media_stream_source|. | 918 // Takes ownership of |media_stream_source|. |
912 web_media_stream_source.SetExtraData(media_stream_source); | 919 web_media_stream_source.SetExtraData(media_stream_source); |
913 | 920 |
914 media_stream_source->ConnectToTrack(web_media_stream_track); | 921 media_stream_source->ConnectToTrack(web_media_stream_track); |
915 web_media_stream->AddTrack(web_media_stream_track); | 922 web_media_stream->AddTrack(web_media_stream_track); |
916 #endif | 923 #endif |
917 } | 924 } |
918 | 925 |
919 //------------------------------------------------------------------------------ | 926 //------------------------------------------------------------------------------ |
920 | 927 |
921 WebImageCaptureFrameGrabber* | 928 std::unique_ptr<WebImageCaptureFrameGrabber> |
922 RendererBlinkPlatformImpl::CreateImageCaptureFrameGrabber() { | 929 RendererBlinkPlatformImpl::CreateImageCaptureFrameGrabber() { |
923 #if BUILDFLAG(ENABLE_WEBRTC) | 930 #if BUILDFLAG(ENABLE_WEBRTC) |
924 return new ImageCaptureFrameGrabber(); | 931 return base::MakeUnique<ImageCaptureFrameGrabber>(); |
925 #else | 932 #else |
926 return nullptr; | 933 return nullptr; |
927 #endif // BUILDFLAG(ENABLE_WEBRTC) | 934 #endif // BUILDFLAG(ENABLE_WEBRTC) |
928 } | 935 } |
929 | 936 |
930 //------------------------------------------------------------------------------ | 937 //------------------------------------------------------------------------------ |
931 | 938 |
932 blink::WebSpeechSynthesizer* RendererBlinkPlatformImpl::CreateSpeechSynthesizer( | 939 std::unique_ptr<blink::WebSpeechSynthesizer> |
| 940 RendererBlinkPlatformImpl::CreateSpeechSynthesizer( |
933 blink::WebSpeechSynthesizerClient* client) { | 941 blink::WebSpeechSynthesizerClient* client) { |
934 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); | 942 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); |
935 } | 943 } |
936 | 944 |
937 //------------------------------------------------------------------------------ | 945 //------------------------------------------------------------------------------ |
938 | 946 |
939 static void Collect3DContextInformation( | 947 static void Collect3DContextInformation( |
940 blink::Platform::GraphicsInfo* gl_info, | 948 blink::Platform::GraphicsInfo* gl_info, |
941 const gpu::GPUInfo& gpu_info) { | 949 const gpu::GPUInfo& gpu_info) { |
942 DCHECK(gl_info); | 950 DCHECK(gl_info); |
(...skipping 14 matching lines...) Expand all Loading... |
957 break; | 965 break; |
958 case gpu::kCollectInfoFatalFailure: | 966 case gpu::kCollectInfoFatalFailure: |
959 case gpu::kCollectInfoNone: | 967 case gpu::kCollectInfoNone: |
960 gl_info->error_message = WebString::FromUTF8( | 968 gl_info->error_message = WebString::FromUTF8( |
961 "Failed to collect gpu information, GLSurface or GLContext " | 969 "Failed to collect gpu information, GLSurface or GLContext " |
962 "creation failed"); | 970 "creation failed"); |
963 break; | 971 break; |
964 } | 972 } |
965 } | 973 } |
966 | 974 |
967 blink::WebGraphicsContext3DProvider* | 975 std::unique_ptr<blink::WebGraphicsContext3DProvider> |
968 RendererBlinkPlatformImpl::CreateOffscreenGraphicsContext3DProvider( | 976 RendererBlinkPlatformImpl::CreateOffscreenGraphicsContext3DProvider( |
969 const blink::Platform::ContextAttributes& web_attributes, | 977 const blink::Platform::ContextAttributes& web_attributes, |
970 const blink::WebURL& top_document_web_url, | 978 const blink::WebURL& top_document_web_url, |
971 blink::WebGraphicsContext3DProvider* share_provider, | 979 blink::WebGraphicsContext3DProvider* share_provider, |
972 blink::Platform::GraphicsInfo* gl_info) { | 980 blink::Platform::GraphicsInfo* gl_info) { |
973 DCHECK(gl_info); | 981 DCHECK(gl_info); |
974 if (!RenderThreadImpl::current()) { | 982 if (!RenderThreadImpl::current()) { |
975 std::string error_message("Failed to run in Current RenderThreadImpl"); | 983 std::string error_message("Failed to run in Current RenderThreadImpl"); |
976 gl_info->error_message = WebString::FromUTF8(error_message); | 984 gl_info->error_message = WebString::FromUTF8(error_message); |
977 return nullptr; | 985 return nullptr; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 constexpr bool automatic_flushes = true; | 1043 constexpr bool automatic_flushes = true; |
1036 constexpr bool support_locking = false; | 1044 constexpr bool support_locking = false; |
1037 | 1045 |
1038 scoped_refptr<ui::ContextProviderCommandBuffer> provider( | 1046 scoped_refptr<ui::ContextProviderCommandBuffer> provider( |
1039 new ui::ContextProviderCommandBuffer( | 1047 new ui::ContextProviderCommandBuffer( |
1040 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 1048 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
1041 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 1049 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
1042 GURL(top_document_web_url), automatic_flushes, support_locking, | 1050 GURL(top_document_web_url), automatic_flushes, support_locking, |
1043 gpu::SharedMemoryLimits(), attributes, share_context, | 1051 gpu::SharedMemoryLimits(), attributes, share_context, |
1044 ui::command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); | 1052 ui::command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); |
1045 return new WebGraphicsContext3DProviderImpl(std::move(provider), | 1053 return base::MakeUnique<WebGraphicsContext3DProviderImpl>( |
1046 is_software_rendering); | 1054 std::move(provider), is_software_rendering); |
1047 } | 1055 } |
1048 | 1056 |
1049 //------------------------------------------------------------------------------ | 1057 //------------------------------------------------------------------------------ |
1050 | 1058 |
1051 blink::WebGraphicsContext3DProvider* | 1059 std::unique_ptr<blink::WebGraphicsContext3DProvider> |
1052 RendererBlinkPlatformImpl::CreateSharedOffscreenGraphicsContext3DProvider() { | 1060 RendererBlinkPlatformImpl::CreateSharedOffscreenGraphicsContext3DProvider() { |
1053 auto* thread = RenderThreadImpl::current(); | 1061 auto* thread = RenderThreadImpl::current(); |
1054 | 1062 |
1055 scoped_refptr<ui::ContextProviderCommandBuffer> provider = | 1063 scoped_refptr<ui::ContextProviderCommandBuffer> provider = |
1056 thread->SharedMainThreadContextProvider(); | 1064 thread->SharedMainThreadContextProvider(); |
1057 if (!provider) | 1065 if (!provider) |
1058 return nullptr; | 1066 return nullptr; |
1059 | 1067 |
1060 scoped_refptr<gpu::GpuChannelHost> host = thread->EstablishGpuChannelSync(); | 1068 scoped_refptr<gpu::GpuChannelHost> host = thread->EstablishGpuChannelSync(); |
1061 // This shouldn't normally fail because we just got |provider|. But the | 1069 // This shouldn't normally fail because we just got |provider|. But the |
1062 // channel can become lost on the IO thread since then. It is important that | 1070 // channel can become lost on the IO thread since then. It is important that |
1063 // this happens after getting |provider|. In the case that this GpuChannelHost | 1071 // this happens after getting |provider|. In the case that this GpuChannelHost |
1064 // is not the same one backing |provider|, the context behind the |provider| | 1072 // is not the same one backing |provider|, the context behind the |provider| |
1065 // will be already lost/dead on arrival, so the value we get for | 1073 // will be already lost/dead on arrival, so the value we get for |
1066 // |is_software_rendering| will never be wrong. | 1074 // |is_software_rendering| will never be wrong. |
1067 if (!host) | 1075 if (!host) |
1068 return nullptr; | 1076 return nullptr; |
1069 | 1077 |
1070 bool is_software_rendering = host->gpu_info().software_rendering; | 1078 bool is_software_rendering = host->gpu_info().software_rendering; |
1071 | 1079 |
1072 return new WebGraphicsContext3DProviderImpl(std::move(provider), | 1080 return base::MakeUnique<WebGraphicsContext3DProviderImpl>( |
1073 is_software_rendering); | 1081 std::move(provider), is_software_rendering); |
1074 } | 1082 } |
1075 | 1083 |
1076 //------------------------------------------------------------------------------ | 1084 //------------------------------------------------------------------------------ |
1077 | 1085 |
1078 gpu::GpuMemoryBufferManager* | 1086 gpu::GpuMemoryBufferManager* |
1079 RendererBlinkPlatformImpl::GetGpuMemoryBufferManager() { | 1087 RendererBlinkPlatformImpl::GetGpuMemoryBufferManager() { |
1080 RenderThreadImpl* thread = RenderThreadImpl::current(); | 1088 RenderThreadImpl* thread = RenderThreadImpl::current(); |
1081 return thread ? thread->GetGpuMemoryBufferManager() : nullptr; | 1089 return thread ? thread->GetGpuMemoryBufferManager() : nullptr; |
1082 } | 1090 } |
1083 | 1091 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 //------------------------------------------------------------------------------ | 1299 //------------------------------------------------------------------------------ |
1292 void RendererBlinkPlatformImpl::RequestPurgeMemory() { | 1300 void RendererBlinkPlatformImpl::RequestPurgeMemory() { |
1293 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but | 1301 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but |
1294 // ChildMemoryCoordinator isn't always available as it's only initialized | 1302 // ChildMemoryCoordinator isn't always available as it's only initialized |
1295 // when kMemoryCoordinatorV0 is enabled. | 1303 // when kMemoryCoordinatorV0 is enabled. |
1296 // Use ChildMemoryCoordinator when memory coordinator is always enabled. | 1304 // Use ChildMemoryCoordinator when memory coordinator is always enabled. |
1297 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); | 1305 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
1298 } | 1306 } |
1299 | 1307 |
1300 } // namespace content | 1308 } // namespace content |
OLD | NEW |