| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/push_messaging/push_provider.h" | 5 #include "content/child/push_messaging/push_provider.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
| 14 #include "content/child/child_thread_impl.h" | 14 #include "content/child/child_thread_impl.h" |
| 15 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 15 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 16 #include "content/public/common/child_process_host.h" | 16 #include "content/public/common/child_process_host.h" |
| 17 #include "content/public/common/push_subscription_options.h" | 17 #include "content/public/common/push_subscription_options.h" |
| 18 #include "services/service_manager/public/cpp/interface_provider.h" | 18 #include "content/public/common/service_names.mojom.h" |
| 19 #include "services/service_manager/public/cpp/connector.h" |
| 19 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
| 20 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
ription.h" | 21 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
ription.h" |
| 21 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
riptionOptions.h" | 22 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc
riptionOptions.h" |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 int CurrentWorkerId() { | 27 int CurrentWorkerId() { |
| 27 return WorkerThread::GetCurrentId(); | 28 return WorkerThread::GetCurrentId(); |
| 28 } | 29 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 100 |
| 100 PushProvider* provider = new PushProvider(main_thread_task_runner); | 101 PushProvider* provider = new PushProvider(main_thread_task_runner); |
| 101 if (CurrentWorkerId()) | 102 if (CurrentWorkerId()) |
| 102 WorkerThread::AddObserver(provider); | 103 WorkerThread::AddObserver(provider); |
| 103 return provider; | 104 return provider; |
| 104 } | 105 } |
| 105 | 106 |
| 106 // static | 107 // static |
| 107 void PushProvider::GetInterface(mojom::PushMessagingRequest request) { | 108 void PushProvider::GetInterface(mojom::PushMessagingRequest request) { |
| 108 if (ChildThreadImpl::current()) { | 109 if (ChildThreadImpl::current()) { |
| 109 ChildThreadImpl::current()->GetRemoteInterfaces()->GetInterface( | 110 ChildThreadImpl::current()->GetConnector()->BindInterface( |
| 110 std::move(request)); | 111 mojom::kBrowserServiceName, std::move(request)); |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 void PushProvider::WillStopCurrentWorkerThread() { | 115 void PushProvider::WillStopCurrentWorkerThread() { |
| 115 delete this; | 116 delete this; |
| 116 } | 117 } |
| 117 | 118 |
| 118 void PushProvider::subscribe( | 119 void PushProvider::subscribe( |
| 119 blink::WebServiceWorkerRegistration* service_worker_registration, | 120 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 120 const blink::WebPushSubscriptionOptions& options, | 121 const blink::WebPushSubscriptionOptions& options, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 error_message = | 273 error_message = |
| 273 "Push subscriptions that don't enable userVisibleOnly are not " | 274 "Push subscriptions that don't enable userVisibleOnly are not " |
| 274 "supported."; | 275 "supported."; |
| 275 } | 276 } |
| 276 callbacks->onError(blink::WebPushError( | 277 callbacks->onError(blink::WebPushError( |
| 277 error_type, blink::WebString::fromUTF8(error_message))); | 278 error_type, blink::WebString::fromUTF8(error_message))); |
| 278 } | 279 } |
| 279 } | 280 } |
| 280 | 281 |
| 281 } // namespace content | 282 } // namespace content |
| OLD | NEW |