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