diff --git a/WATCHLISTS b/WATCHLISTS index 389b34a84e033..053be53da212f 100644 --- a/WATCHLISTS +++ b/WATCHLISTS @@ -1153,7 +1153,6 @@ 'chrome/browser/notifications/|'\ 'chrome/test/data/notifications/|'\ 'content/browser/notifications/|'\ - 'content/child/notifications/|'\ 'content/common/platform_notification|'\ 'content/public/browser/platform_notification|'\ 'content/public/common/platform_notification|'\ diff --git a/content/browser/notifications/OWNERS b/content/browser/notifications/OWNERS index db7d72cb4b79b..2c095bca8ddbe 100644 --- a/content/browser/notifications/OWNERS +++ b/content/browser/notifications/OWNERS @@ -1,6 +1,6 @@ # This OWNERS file also covers: # -# //content/child/notifications/ +# //content/renderer/notifications/ # //content/test/mock_platform_notification_service.* mkwst@chromium.org diff --git a/content/child/BUILD.gn b/content/child/BUILD.gn index 71a29dee1cda7..bfd15b66325ea 100644 --- a/content/child/BUILD.gn +++ b/content/child/BUILD.gn @@ -119,12 +119,6 @@ target(link_target_type, "child") { "memory/child_memory_coordinator_impl.h", "memory/child_memory_coordinator_impl_android.cc", "memory/child_memory_coordinator_impl_android.h", - "notifications/notification_data_conversions.cc", - "notifications/notification_data_conversions.h", - "notifications/notification_dispatcher.cc", - "notifications/notification_dispatcher.h", - "notifications/notification_manager.cc", - "notifications/notification_manager.h", "quota_dispatcher.cc", "quota_dispatcher.h", "quota_message_filter.cc", diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc index 93c2af27e2b4a..980224ea573c8 100644 --- a/content/child/blink_platform_impl.cc +++ b/content/child/blink_platform_impl.cc @@ -40,9 +40,6 @@ #include "content/child/child_thread_impl.h" #include "content/child/content_child_helpers.h" #include "content/child/feature_policy/feature_policy_platform.h" -#include "content/child/notifications/notification_dispatcher.h" -#include "content/child/notifications/notification_manager.h" -#include "content/child/thread_safe_sender.h" #include "content/child/web_data_consumer_handle_impl.h" #include "content/child/web_url_loader_impl.h" #include "content/child/web_url_request_util.h" @@ -326,16 +323,6 @@ BlinkPlatformImpl::BlinkPlatformImpl( scoped_refptr main_thread_task_runner) : main_thread_task_runner_(main_thread_task_runner), compositor_thread_(nullptr) { - InternalInit(); -} - -void BlinkPlatformImpl::InternalInit() { - // ChildThread may not exist in some tests. - if (ChildThreadImpl::current()) { - thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); - notification_dispatcher_ = - ChildThreadImpl::current()->notification_dispatcher(); - } } void BlinkPlatformImpl::WaitUntilWebThreadTLSUpdate( @@ -657,15 +644,6 @@ const char* BlinkPlatformImpl::GetBrowserServiceName() const { return mojom::kBrowserServiceName; } -blink::WebNotificationManager* BlinkPlatformImpl::GetNotificationManager() { - if (!thread_safe_sender_.get() || !notification_dispatcher_.get()) - return nullptr; - - return NotificationManager::ThreadSpecificInstance( - thread_safe_sender_.get(), - notification_dispatcher_.get()); -} - blink::WebMediaCapabilitiesClient* BlinkPlatformImpl::MediaCapabilitiesClient() { return &media_capabilities_client_; diff --git a/content/child/blink_platform_impl.h b/content/child/blink_platform_impl.h index ba9d8735f25d2..d04c7a3fab70e 100644 --- a/content/child/blink_platform_impl.h +++ b/content/child/blink_platform_impl.h @@ -46,8 +46,6 @@ class WebThreadBase; namespace content { -class NotificationDispatcher; -class ThreadSafeSender; class WebCryptoImpl; class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform { @@ -110,7 +108,6 @@ class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform { const blink::WebURL& script_url) override; blink::WebCrypto* Crypto() override; const char* GetBrowserServiceName() const override; - blink::WebNotificationManager* GetNotificationManager() override; blink::WebMediaCapabilitiesClient* MediaCapabilitiesClient() override; blink::WebString DomCodeStringFromEnum(int dom_code) override; @@ -134,7 +131,6 @@ class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform { const blink::WebSecurityOrigin& new_origin) override; private: - void InternalInit(); void WaitUntilWebThreadTLSUpdate(blink::scheduler::WebThreadBase* thread); void UpdateWebThreadTLS(blink::WebThread* thread, base::WaitableEvent* event); @@ -147,9 +143,6 @@ class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform { webcrypto::WebCryptoImpl web_crypto_; media::WebMediaCapabilitiesClientImpl media_capabilities_client_; - scoped_refptr thread_safe_sender_; - scoped_refptr notification_dispatcher_; - blink::scheduler::WebThreadBase* compositor_thread_; }; diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index 2e3745206a38a..8c1c230a704b5 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc @@ -41,7 +41,6 @@ #include "content/child/child_resource_message_filter.h" #include "content/child/fileapi/file_system_dispatcher.h" #include "content/child/fileapi/webfilesystem_impl.h" -#include "content/child/notifications/notification_dispatcher.h" #include "content/child/quota_dispatcher.h" #include "content/child/quota_message_filter.h" #include "content/child/resource_dispatcher.h" @@ -498,12 +497,9 @@ void ChildThreadImpl::Init(const Options& options) { new QuotaMessageFilter(thread_safe_sender_.get()); quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), quota_message_filter_.get())); - notification_dispatcher_ = - new NotificationDispatcher(thread_safe_sender_.get()); channel_->AddFilter(resource_message_filter_.get()); channel_->AddFilter(quota_message_filter_->GetFilter()); - channel_->AddFilter(notification_dispatcher_->GetFilter()); channel_->AddFilter(service_worker_message_filter_->GetFilter()); InitTracing(); diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h index 9eb3eb0af256c..f2a84985bad1e 100644 --- a/content/child/child_thread_impl.h +++ b/content/child/child_thread_impl.h @@ -52,7 +52,6 @@ namespace content { class ChildResourceMessageFilter; class FileSystemDispatcher; class InProcessChildThreadParams; -class NotificationDispatcher; class ServiceWorkerMessageFilter; class QuotaDispatcher; class QuotaMessageFilter; @@ -132,10 +131,6 @@ class CONTENT_EXPORT ChildThreadImpl return quota_dispatcher_.get(); } - NotificationDispatcher* notification_dispatcher() const { - return notification_dispatcher_.get(); - } - IPC::SyncMessageFilter* sync_message_filter() const { return sync_message_filter_.get(); } @@ -276,8 +271,6 @@ class CONTENT_EXPORT ChildThreadImpl scoped_refptr quota_message_filter_; - scoped_refptr notification_dispatcher_; - std::unique_ptr power_monitor_; scoped_refptr browser_process_io_runner_; diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index 9b215ac4395a4..2d6310ac0a71b 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn @@ -281,6 +281,12 @@ target(link_target_type, "renderer") { "navigation_state_impl.h", "net_info_helper.cc", "net_info_helper.h", + "notifications/notification_data_conversions.cc", + "notifications/notification_data_conversions.h", + "notifications/notification_dispatcher.cc", + "notifications/notification_dispatcher.h", + "notifications/notification_manager.cc", + "notifications/notification_manager.h", "origin_trials/web_trial_token_validator_impl.cc", "origin_trials/web_trial_token_validator_impl.h", "p2p/network_list_manager.h", diff --git a/content/child/notifications/OWNERS b/content/renderer/notifications/OWNERS similarity index 100% rename from content/child/notifications/OWNERS rename to content/renderer/notifications/OWNERS diff --git a/content/child/notifications/notification_data_conversions.cc b/content/renderer/notifications/notification_data_conversions.cc similarity index 98% rename from content/child/notifications/notification_data_conversions.cc rename to content/renderer/notifications/notification_data_conversions.cc index f54985d4f7d96..6f611563fc331 100644 --- a/content/child/notifications/notification_data_conversions.cc +++ b/content/renderer/notifications/notification_data_conversions.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/child/notifications/notification_data_conversions.h" +#include "content/renderer/notifications/notification_data_conversions.h" #include diff --git a/content/child/notifications/notification_data_conversions.h b/content/renderer/notifications/notification_data_conversions.h similarity index 78% rename from content/child/notifications/notification_data_conversions.h rename to content/renderer/notifications/notification_data_conversions.h index 445ff60316d18..7adc1df192e7c 100644 --- a/content/child/notifications/notification_data_conversions.h +++ b/content/renderer/notifications/notification_data_conversions.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ -#define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ +#ifndef CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ +#define CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ #include "content/common/content_export.h" #include "content/public/common/platform_notification_data.h" @@ -21,4 +21,4 @@ CONTENT_EXPORT blink::WebNotificationData ToWebNotificationData( } // namespace content -#endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ +#endif // CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ diff --git a/content/child/notifications/notification_data_conversions_unittest.cc b/content/renderer/notifications/notification_data_conversions_unittest.cc similarity index 99% rename from content/child/notifications/notification_data_conversions_unittest.cc rename to content/renderer/notifications/notification_data_conversions_unittest.cc index c5955ac04728f..2edc32e5204d0 100644 --- a/content/child/notifications/notification_data_conversions_unittest.cc +++ b/content/renderer/notifications/notification_data_conversions_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/child/notifications/notification_data_conversions.h" +#include "content/renderer/notifications/notification_data_conversions.h" #include #include diff --git a/content/child/notifications/notification_dispatcher.cc b/content/renderer/notifications/notification_dispatcher.cc similarity index 92% rename from content/child/notifications/notification_dispatcher.cc rename to content/renderer/notifications/notification_dispatcher.cc index f840b40e37670..3bad7ebff2a33 100644 --- a/content/child/notifications/notification_dispatcher.cc +++ b/content/renderer/notifications/notification_dispatcher.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/child/notifications/notification_dispatcher.h" +#include "content/renderer/notifications/notification_dispatcher.h" #include -#include "content/child/notifications/notification_manager.h" +#include "content/renderer/notifications/notification_manager.h" namespace content { diff --git a/content/child/notifications/notification_dispatcher.h b/content/renderer/notifications/notification_dispatcher.h similarity index 86% rename from content/child/notifications/notification_dispatcher.h rename to content/renderer/notifications/notification_dispatcher.h index 2df766126e764..26862956e696b 100644 --- a/content/child/notifications/notification_dispatcher.h +++ b/content/renderer/notifications/notification_dispatcher.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ -#define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ +#ifndef CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ +#define CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ #include @@ -42,4 +42,4 @@ class NotificationDispatcher : public WorkerThreadMessageFilter { } // namespace content -#endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ +#endif // CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_ diff --git a/content/child/notifications/notification_manager.cc b/content/renderer/notifications/notification_manager.cc similarity index 98% rename from content/child/notifications/notification_manager.cc rename to content/renderer/notifications/notification_manager.cc index e92f560bb6668..f387d976f7b0a 100644 --- a/content/child/notifications/notification_manager.cc +++ b/content/renderer/notifications/notification_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/child/notifications/notification_manager.h" +#include "content/renderer/notifications/notification_manager.h" #include @@ -10,12 +10,12 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_local.h" -#include "content/child/notifications/notification_data_conversions.h" -#include "content/child/notifications/notification_dispatcher.h" #include "content/child/service_worker/web_service_worker_registration_impl.h" #include "content/child/thread_safe_sender.h" #include "content/public/common/notification_resources.h" #include "content/public/common/platform_notification_data.h" +#include "content/renderer/notifications/notification_data_conversions.h" +#include "content/renderer/notifications/notification_dispatcher.h" #include "third_party/WebKit/public/platform/URLConversion.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/modules/notifications/WebNotificationDelegate.h" diff --git a/content/child/notifications/notification_manager.h b/content/renderer/notifications/notification_manager.h similarity index 94% rename from content/child/notifications/notification_manager.h rename to content/renderer/notifications/notification_manager.h index 964c59894e650..66e080f9859d3 100644 --- a/content/child/notifications/notification_manager.h +++ b/content/renderer/notifications/notification_manager.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ -#define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ +#ifndef CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ +#define CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ #include #include @@ -16,9 +16,9 @@ #include "base/containers/id_map.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "content/child/notifications/notification_dispatcher.h" #include "content/common/platform_notification_messages.h" #include "content/public/child/worker_thread.h" +#include "content/renderer/notifications/notification_dispatcher.h" #include "third_party/WebKit/public/platform/modules/notifications/WebNotificationManager.h" #include "url/gurl.h" @@ -110,4 +110,4 @@ class NotificationManager : public blink::WebNotificationManager, } // namespace content -#endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ +#endif // CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 3770df66306cb..1c73d1cf6f4a4 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -123,6 +123,7 @@ #include "content/renderer/mus/render_widget_window_tree_client_factory.h" #include "content/renderer/mus/renderer_window_tree_client.h" #include "content/renderer/net_info_helper.h" +#include "content/renderer/notifications/notification_dispatcher.h" #include "content/renderer/p2p/socket_dispatcher.h" #include "content/renderer/render_frame_proxy.h" #include "content/renderer/render_process_impl.h" @@ -674,6 +675,10 @@ void RenderThreadImpl::Init( shared_bitmap_allocation_notifier_ptr.PassInterface(), GetChannel()->ipc_task_runner_refptr())); + notification_dispatcher_ = + new NotificationDispatcher(thread_safe_sender()); + AddFilter(notification_dispatcher_->GetFilter()); + InitializeWebKit(resource_task_queue); blink_initialized_time_ = base::TimeTicks::Now(); diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 5695809a51ee7..52467c0c393b5 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -136,6 +136,7 @@ class FrameSwapMessageQueue; class IndexedDBDispatcher; class InputHandlerManager; class MidiMessageFilter; +class NotificationDispatcher; class P2PSocketDispatcher; class PeerConnectionDependencyFactory; class PeerConnectionTracker; @@ -369,6 +370,10 @@ class CONTENT_EXPORT RenderThreadImpl return shared_bitmap_manager_.get(); } + NotificationDispatcher* notification_dispatcher() const { + return notification_dispatcher_.get(); + } + mojom::RenderFrameMessageFilter* render_frame_message_filter(); mojom::RenderMessageFilter* render_message_filter(); @@ -649,6 +654,8 @@ class CONTENT_EXPORT RenderThreadImpl std::unique_ptr shared_bitmap_manager_; + scoped_refptr notification_dispatcher_; + // The time Blink was initialized. Used for UMA. base::TimeTicks blink_initialized_time_; diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc index b4574f541ec7a..723a86d6de149 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc @@ -67,6 +67,8 @@ #include "content/renderer/media_capture_from_element/html_video_element_capturer_source.h" #include "content/renderer/media_recorder/media_recorder_handler.h" #include "content/renderer/mojo/blink_interface_provider_impl.h" +#include "content/renderer/notifications/notification_dispatcher.h" +#include "content/renderer/notifications/notification_manager.h" #include "content/renderer/push_messaging/push_provider.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/renderer_clipboard_delegate.h" @@ -293,6 +295,8 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl( web_idb_factory_.reset(new WebIDBFactoryImpl( sync_message_filter_, RenderThreadImpl::current()->GetIOTaskRunner().get())); + notification_dispatcher_ = + RenderThreadImpl::current()->notification_dispatcher(); } else { service_manager::mojom::ConnectorRequest request; connector_ = service_manager::Connector::Create(&request); @@ -1343,6 +1347,20 @@ RendererBlinkPlatformImpl::OriginTrialPolicy() { return std::make_unique(); } +//------------------------------------------------------------------------------ + +blink::WebNotificationManager* +RendererBlinkPlatformImpl::GetNotificationManager() { + if (!thread_safe_sender_.get() || !notification_dispatcher_.get()) + return nullptr; + + return NotificationManager::ThreadSpecificInstance( + thread_safe_sender_.get(), + notification_dispatcher_.get()); +} + +//------------------------------------------------------------------------------ + void RendererBlinkPlatformImpl::WorkerContextCreated( const v8::Local& worker) { GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h index ff49e52d31068..d3d3ef16fa8d3 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h @@ -62,6 +62,7 @@ namespace content { class BlinkInterfaceProviderImpl; class ChildURLLoaderFactoryGetter; class LocalStorageCachedAreas; +class NotificationDispatcher; class PlatformEventObserverBase; class QuotaMessageFilter; class RendererClipboardDelegate; @@ -214,6 +215,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { blink::WebPushProvider* PushProvider() override; std::unique_ptr TrialTokenValidator() override; std::unique_ptr OriginTrialPolicy() override; + blink::WebNotificationManager* GetNotificationManager() override; void WorkerContextCreated(const v8::Local& worker) override; // Set the PlatformEventObserverBase in |platform_event_observers_| associated @@ -338,6 +340,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { mojom::FileUtilitiesHostPtrInfo file_utilities_host_info_; + scoped_refptr notification_dispatcher_; + DISALLOW_COPY_AND_ASSIGN(RendererBlinkPlatformImpl); }; diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index 2efff37ad12b2..d9d8cb0c495a6 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc @@ -19,7 +19,6 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "content/child/background_sync/background_sync_type_converters.h" -#include "content/child/notifications/notification_data_conversions.h" #include "content/child/request_extra_data.h" #include "content/child/service_worker/service_worker_dispatcher.h" #include "content/child/service_worker/service_worker_handle_reference.h" @@ -45,6 +44,7 @@ #include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/document_state.h" #include "content/renderer/devtools/devtools_agent.h" +#include "content/renderer/notifications/notification_data_conversions.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/renderer_blink_platform_impl.h" #include "content/renderer/service_worker/controller_service_worker_impl.h" diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 5ff211a88d4b0..209ea8e138ade 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn @@ -1453,7 +1453,6 @@ test("content_unittests") { "../child/indexed_db/webidbdatabase_impl_unittest.cc", "../child/loader/cors_url_loader_unittest.cc", "../child/memory/child_memory_coordinator_impl_unittest.cc", - "../child/notifications/notification_data_conversions_unittest.cc", "../child/resource_dispatcher_unittest.cc", "../child/service_worker/service_worker_dispatcher_unittest.cc", "../child/service_worker/service_worker_provider_context_unittest.cc", @@ -1553,6 +1552,7 @@ test("content_unittests") { "../renderer/media/renderer_webaudiodevice_impl_unittest.cc", "../renderer/media/video_capture_impl_manager_unittest.cc", "../renderer/media/video_capture_impl_unittest.cc", + "../renderer/notifications/notification_data_conversions_unittest.cc", "../renderer/peripheral_content_heuristic_unittest.cc", "../renderer/presentation/presentation_dispatcher_unittest.cc", "../renderer/presentation/test_presentation_connection.cc",