| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/navigator_connect/service_port_dispatcher_impl.h" | 5 #include "content/child/navigator_connect/service_port_dispatcher_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| 11 #include "mojo/common/url_type_converters.h" | 11 #include "mojo/common/url_type_converters.h" |
| 12 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" | 12 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class WebConnectCallbacksImpl | 18 class WebConnectCallbacksImpl |
| 19 : public blink::WebServicePortConnectEventCallbacks { | 19 : public blink::WebServicePortConnectEventCallbacks { |
| 20 public: | 20 public: |
| 21 WebConnectCallbacksImpl( | 21 WebConnectCallbacksImpl( |
| 22 const ServicePortDispatcher::ConnectCallback& callback) | 22 const ServicePortDispatcher::ConnectCallback& callback) |
| 23 : callback_(callback) {} | 23 : callback_(callback) {} |
| 24 | 24 |
| 25 ~WebConnectCallbacksImpl() override {} | 25 ~WebConnectCallbacksImpl() override {} |
| 26 | 26 |
| 27 void onSuccess(const blink::WebServicePort& port) override { | 27 void onSuccess(const blink::WebServicePort& port) override { |
| 28 callback_.Run(SERVICE_PORT_CONNECT_RESULT_ACCEPT, | 28 callback_.Run(ServicePortConnectResult::ACCEPT, |
| 29 mojo::String::From<base::string16>(port.name), | 29 mojo::String::From<base::string16>(port.name), |
| 30 mojo::String::From<base::string16>(port.data)); | 30 mojo::String::From<base::string16>(port.data)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void onError() override { | 33 void onError() override { |
| 34 callback_.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), | 34 callback_.Run(ServicePortConnectResult::REJECT, mojo::String(""), |
| 35 mojo::String("")); | 35 mojo::String("")); |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 ServicePortDispatcher::ConnectCallback callback_; | 39 ServicePortDispatcher::ConnectCallback callback_; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 void ServicePortDispatcherImpl::Create( | 44 void ServicePortDispatcherImpl::Create( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 | 60 |
| 61 void ServicePortDispatcherImpl::WillStopCurrentWorkerThread() { | 61 void ServicePortDispatcherImpl::WillStopCurrentWorkerThread() { |
| 62 delete this; | 62 delete this; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ServicePortDispatcherImpl::Connect(const mojo::String& target_url, | 65 void ServicePortDispatcherImpl::Connect(const mojo::String& target_url, |
| 66 const mojo::String& origin, | 66 const mojo::String& origin, |
| 67 int32_t port_id, | 67 int32_t port_id, |
| 68 const ConnectCallback& callback) { | 68 const ConnectCallback& callback) { |
| 69 if (!proxy_) { | 69 if (!proxy_) { |
| 70 callback.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), | 70 callback.Run(ServicePortConnectResult::REJECT, mojo::String(""), |
| 71 mojo::String("")); | 71 mojo::String("")); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 TRACE_EVENT0("ServiceWorker", "ServicePortDispatcherImpl::Connect"); | 74 TRACE_EVENT0("ServiceWorker", "ServicePortDispatcherImpl::Connect"); |
| 75 proxy_->dispatchServicePortConnectEvent(new WebConnectCallbacksImpl(callback), | 75 proxy_->dispatchServicePortConnectEvent(new WebConnectCallbacksImpl(callback), |
| 76 target_url.To<GURL>(), | 76 target_url.To<GURL>(), |
| 77 origin.To<base::string16>(), port_id); | 77 origin.To<base::string16>(), port_id); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace content | 80 } // namespace content |
| OLD | NEW |