Skip to content

Commit

Permalink
Move notifications from content/child to content/renderer.
Browse files Browse the repository at this point in the history
BUG=777007
[email protected]

Change-Id: Ic9350cf31b9ec4a13089577521a8772da5db6241
Reviewed-on: https://chromium-review.googlesource.com/730878
Commit-Queue: John Abd-El-Malek <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#510669}
  • Loading branch information
John Abd-El-Malek authored and Commit Bot committed Oct 21, 2017
1 parent d61d91d commit f9f86c1
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 67 deletions.
1 change: 0 additions & 1 deletion WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -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|'\
Expand Down
2 changes: 1 addition & 1 deletion content/browser/notifications/OWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This OWNERS file also covers:
#
# //content/child/notifications/
# //content/renderer/notifications/
# //content/test/mock_platform_notification_service.*

[email protected]
Expand Down
6 changes: 0 additions & 6 deletions content/child/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 0 additions & 22 deletions content/child/blink_platform_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -326,16 +323,6 @@ BlinkPlatformImpl::BlinkPlatformImpl(
scoped_refptr<base::SingleThreadTaskRunner> 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(
Expand Down Expand Up @@ -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_;
Expand Down
7 changes: 0 additions & 7 deletions content/child/blink_platform_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class WebThreadBase;

namespace content {

class NotificationDispatcher;
class ThreadSafeSender;
class WebCryptoImpl;

class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform {
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -147,9 +143,6 @@ class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform {
webcrypto::WebCryptoImpl web_crypto_;
media::WebMediaCapabilitiesClientImpl media_capabilities_client_;

scoped_refptr<ThreadSafeSender> thread_safe_sender_;
scoped_refptr<NotificationDispatcher> notification_dispatcher_;

blink::scheduler::WebThreadBase* compositor_thread_;
};

Expand Down
4 changes: 0 additions & 4 deletions content/child/child_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 0 additions & 7 deletions content/child/child_thread_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ namespace content {
class ChildResourceMessageFilter;
class FileSystemDispatcher;
class InProcessChildThreadParams;
class NotificationDispatcher;
class ServiceWorkerMessageFilter;
class QuotaDispatcher;
class QuotaMessageFilter;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -276,8 +271,6 @@ class CONTENT_EXPORT ChildThreadImpl

scoped_refptr<QuotaMessageFilter> quota_message_filter_;

scoped_refptr<NotificationDispatcher> notification_dispatcher_;

std::unique_ptr<base::PowerMonitor> power_monitor_;

scoped_refptr<base::SingleThreadTaskRunner> browser_process_io_runner_;
Expand Down
6 changes: 6 additions & 0 deletions content/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
#include <stdint.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <limits>

#include "content/child/notifications/notification_manager.h"
#include "content/renderer/notifications/notification_manager.h"

namespace content {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <map>

Expand Down Expand Up @@ -42,4 +42,4 @@ class NotificationDispatcher : public WorkerThreadMessageFilter {

} // namespace content

#endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_
#endif // CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// 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 <utility>

#include "base/lazy_instance.h"
#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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
#include <stdint.h>
Expand All @@ -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"

Expand Down Expand Up @@ -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_
5 changes: 5 additions & 0 deletions content/renderer/render_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();

Expand Down
7 changes: 7 additions & 0 deletions content/renderer/render_thread_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class FrameSwapMessageQueue;
class IndexedDBDispatcher;
class InputHandlerManager;
class MidiMessageFilter;
class NotificationDispatcher;
class P2PSocketDispatcher;
class PeerConnectionDependencyFactory;
class PeerConnectionTracker;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -649,6 +654,8 @@ class CONTENT_EXPORT RenderThreadImpl

std::unique_ptr<viz::ClientSharedBitmapManager> shared_bitmap_manager_;

scoped_refptr<NotificationDispatcher> notification_dispatcher_;

// The time Blink was initialized. Used for UMA.
base::TimeTicks blink_initialized_time_;

Expand Down
18 changes: 18 additions & 0 deletions content/renderer/renderer_blink_platform_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1343,6 +1347,20 @@ RendererBlinkPlatformImpl::OriginTrialPolicy() {
return std::make_unique<TrialPolicyImpl>();
}

//------------------------------------------------------------------------------

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<v8::Context>& worker) {
GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
Expand Down
4 changes: 4 additions & 0 deletions content/renderer/renderer_blink_platform_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace content {
class BlinkInterfaceProviderImpl;
class ChildURLLoaderFactoryGetter;
class LocalStorageCachedAreas;
class NotificationDispatcher;
class PlatformEventObserverBase;
class QuotaMessageFilter;
class RendererClipboardDelegate;
Expand Down Expand Up @@ -214,6 +215,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
blink::WebPushProvider* PushProvider() override;
std::unique_ptr<blink::WebTrialTokenValidator> TrialTokenValidator() override;
std::unique_ptr<blink::TrialPolicy> OriginTrialPolicy() override;
blink::WebNotificationManager* GetNotificationManager() override;
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;

// Set the PlatformEventObserverBase in |platform_event_observers_| associated
Expand Down Expand Up @@ -338,6 +340,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {

mojom::FileUtilitiesHostPtrInfo file_utilities_host_info_;

scoped_refptr<NotificationDispatcher> notification_dispatcher_;

DISALLOW_COPY_AND_ASSIGN(RendererBlinkPlatformImpl);
};

Expand Down
Loading

0 comments on commit f9f86c1

Please sign in to comment.