Commit 972aadda authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[DevTools] Enable PushMessaging & Notifications in handler.

Allows the Background Services handler to receive push & notification
calls from the frontend.

Bug: 927726
Change-Id: Iaaca0205890f940d187f3b6e145e57fb1d3fdcb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609705
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarAlexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660806}
parent 39c1fb7f
...@@ -60,8 +60,7 @@ DevToolsBackgroundServicesContextImpl::DevToolsBackgroundServicesContextImpl( ...@@ -60,8 +60,7 @@ DevToolsBackgroundServicesContextImpl::DevToolsBackgroundServicesContextImpl(
BrowserContext* browser_context, BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
: browser_context_(browser_context), : browser_context_(browser_context),
service_worker_context_(std::move(service_worker_context)), service_worker_context_(std::move(service_worker_context)) {
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto expiration_times = auto expiration_times =
...@@ -148,7 +147,7 @@ void DevToolsBackgroundServicesContextImpl::GetLoggedBackgroundServiceEvents( ...@@ -148,7 +147,7 @@ void DevToolsBackgroundServicesContextImpl::GetLoggedBackgroundServiceEvents(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::BindOnce(&DevToolsBackgroundServicesContextImpl:: base::BindOnce(&DevToolsBackgroundServicesContextImpl::
GetLoggedBackgroundServiceEventsOnIO, GetLoggedBackgroundServiceEventsOnIO,
weak_ptr_factory_.GetWeakPtr(), service, weak_ptr_factory_io_.GetWeakPtr(), service,
std::move(callback))); std::move(callback)));
} }
...@@ -161,7 +160,7 @@ void DevToolsBackgroundServicesContextImpl:: ...@@ -161,7 +160,7 @@ void DevToolsBackgroundServicesContextImpl::
service_worker_context_->GetUserDataForAllRegistrationsByKeyPrefix( service_worker_context_->GetUserDataForAllRegistrationsByKeyPrefix(
CreateEntryKeyPrefix(service), CreateEntryKeyPrefix(service),
base::BindOnce(&DevToolsBackgroundServicesContextImpl::DidGetUserData, base::BindOnce(&DevToolsBackgroundServicesContextImpl::DidGetUserData,
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_io_.GetWeakPtr(), std::move(callback)));
} }
void DevToolsBackgroundServicesContextImpl::DidGetUserData( void DevToolsBackgroundServicesContextImpl::DidGetUserData(
...@@ -209,7 +208,7 @@ void DevToolsBackgroundServicesContextImpl::ClearLoggedBackgroundServiceEvents( ...@@ -209,7 +208,7 @@ void DevToolsBackgroundServicesContextImpl::ClearLoggedBackgroundServiceEvents(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::BindOnce(&DevToolsBackgroundServicesContextImpl:: base::BindOnce(&DevToolsBackgroundServicesContextImpl::
ClearLoggedBackgroundServiceEventsOnIO, ClearLoggedBackgroundServiceEventsOnIO,
weak_ptr_factory_.GetWeakPtr(), service)); weak_ptr_factory_io_.GetWeakPtr(), service));
} }
void DevToolsBackgroundServicesContextImpl:: void DevToolsBackgroundServicesContextImpl::
...@@ -234,7 +233,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEvent( ...@@ -234,7 +233,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEvent(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::BindOnce( base::BindOnce(
&DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO, &DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO,
weak_ptr_factory_.GetWeakPtr(), service_worker_registration_id, weak_ptr_factory_io_.GetWeakPtr(), service_worker_registration_id,
origin, service, event_name, instance_id, event_metadata)); origin, service, event_name, instance_id, event_metadata));
} }
...@@ -257,7 +256,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO( ...@@ -257,7 +256,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce( base::BindOnce(
&DevToolsBackgroundServicesContextImpl::OnRecordingTimeExpired, &DevToolsBackgroundServicesContextImpl::OnRecordingTimeExpired,
weak_ptr_factory_.GetWeakPtr(), ServiceToProtoEnum(service))); weak_ptr_factory_ui_.GetWeakPtr(), ServiceToProtoEnum(service)));
return; return;
} }
...@@ -281,7 +280,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO( ...@@ -281,7 +280,7 @@ void DevToolsBackgroundServicesContextImpl::LogBackgroundServiceEventOnIO(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce( base::BindOnce(
&DevToolsBackgroundServicesContextImpl::NotifyEventObservers, &DevToolsBackgroundServicesContextImpl::NotifyEventObservers,
weak_ptr_factory_.GetWeakPtr(), std::move(event))); weak_ptr_factory_ui_.GetWeakPtr(), std::move(event)));
} }
void DevToolsBackgroundServicesContextImpl::NotifyEventObservers( void DevToolsBackgroundServicesContextImpl::NotifyEventObservers(
......
...@@ -136,7 +136,10 @@ class CONTENT_EXPORT DevToolsBackgroundServicesContextImpl ...@@ -136,7 +136,10 @@ class CONTENT_EXPORT DevToolsBackgroundServicesContextImpl
base::ObserverList<EventObserver> observers_; base::ObserverList<EventObserver> observers_;
base::WeakPtrFactory<DevToolsBackgroundServicesContextImpl> weak_ptr_factory_; base::WeakPtrFactory<DevToolsBackgroundServicesContextImpl>
weak_ptr_factory_ui_{this};
base::WeakPtrFactory<DevToolsBackgroundServicesContextImpl>
weak_ptr_factory_io_{this};
DISALLOW_COPY_AND_ASSIGN(DevToolsBackgroundServicesContextImpl); DISALLOW_COPY_AND_ASSIGN(DevToolsBackgroundServicesContextImpl);
}; };
......
...@@ -22,6 +22,12 @@ devtools::proto::BackgroundService ServiceNameToEnum( ...@@ -22,6 +22,12 @@ devtools::proto::BackgroundService ServiceNameToEnum(
} else if (service_name == } else if (service_name ==
BackgroundService::ServiceNameEnum::BackgroundSync) { BackgroundService::ServiceNameEnum::BackgroundSync) {
return devtools::proto::BackgroundService::BACKGROUND_SYNC; return devtools::proto::BackgroundService::BACKGROUND_SYNC;
} else if (service_name ==
BackgroundService::ServiceNameEnum::PushMessaging) {
return devtools::proto::BackgroundService::PUSH_MESSAGING;
} else if (service_name ==
BackgroundService::ServiceNameEnum::Notifications) {
return devtools::proto::BackgroundService::NOTIFICATIONS;
} }
return devtools::proto::BackgroundService::UNKNOWN; return devtools::proto::BackgroundService::UNKNOWN;
} }
...@@ -32,6 +38,10 @@ std::string ServiceEnumToName(devtools::proto::BackgroundService service_enum) { ...@@ -32,6 +38,10 @@ std::string ServiceEnumToName(devtools::proto::BackgroundService service_enum) {
return BackgroundService::ServiceNameEnum::BackgroundFetch; return BackgroundService::ServiceNameEnum::BackgroundFetch;
case devtools::proto::BackgroundService::BACKGROUND_SYNC: case devtools::proto::BackgroundService::BACKGROUND_SYNC:
return BackgroundService::ServiceNameEnum::BackgroundSync; return BackgroundService::ServiceNameEnum::BackgroundSync;
case devtools::proto::BackgroundService::PUSH_MESSAGING:
return BackgroundService::ServiceNameEnum::PushMessaging;
case devtools::proto::BackgroundService::NOTIFICATIONS:
return BackgroundService::ServiceNameEnum::Notifications;
default: default:
NOTREACHED(); NOTREACHED();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment