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> |
| 8 |
7 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
8 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
9 #include "mojo/common/url_type_converters.h" | 11 #include "mojo/common/url_type_converters.h" |
10 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" | 12 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 class WebConnectCallbacksImpl | 18 class WebConnectCallbacksImpl |
(...skipping 18 matching lines...) Expand all Loading... |
35 | 37 |
36 private: | 38 private: |
37 ServicePortDispatcher::ConnectCallback callback_; | 39 ServicePortDispatcher::ConnectCallback callback_; |
38 }; | 40 }; |
39 | 41 |
40 } // namespace | 42 } // namespace |
41 | 43 |
42 void ServicePortDispatcherImpl::Create( | 44 void ServicePortDispatcherImpl::Create( |
43 base::WeakPtr<blink::WebServiceWorkerContextProxy> proxy, | 45 base::WeakPtr<blink::WebServiceWorkerContextProxy> proxy, |
44 mojo::InterfaceRequest<ServicePortDispatcher> request) { | 46 mojo::InterfaceRequest<ServicePortDispatcher> request) { |
45 new ServicePortDispatcherImpl(proxy, request.Pass()); | 47 new ServicePortDispatcherImpl(proxy, std::move(request)); |
46 } | 48 } |
47 | 49 |
48 ServicePortDispatcherImpl::~ServicePortDispatcherImpl() { | 50 ServicePortDispatcherImpl::~ServicePortDispatcherImpl() { |
49 WorkerThread::RemoveObserver(this); | 51 WorkerThread::RemoveObserver(this); |
50 } | 52 } |
51 | 53 |
52 ServicePortDispatcherImpl::ServicePortDispatcherImpl( | 54 ServicePortDispatcherImpl::ServicePortDispatcherImpl( |
53 base::WeakPtr<blink::WebServiceWorkerContextProxy> proxy, | 55 base::WeakPtr<blink::WebServiceWorkerContextProxy> proxy, |
54 mojo::InterfaceRequest<ServicePortDispatcher> request) | 56 mojo::InterfaceRequest<ServicePortDispatcher> request) |
55 : binding_(this, request.Pass()), proxy_(proxy) { | 57 : binding_(this, std::move(request)), proxy_(proxy) { |
56 WorkerThread::AddObserver(this); | 58 WorkerThread::AddObserver(this); |
57 } | 59 } |
58 | 60 |
59 void ServicePortDispatcherImpl::WillStopCurrentWorkerThread() { | 61 void ServicePortDispatcherImpl::WillStopCurrentWorkerThread() { |
60 delete this; | 62 delete this; |
61 } | 63 } |
62 | 64 |
63 void ServicePortDispatcherImpl::Connect(const mojo::String& target_url, | 65 void ServicePortDispatcherImpl::Connect(const mojo::String& target_url, |
64 const mojo::String& origin, | 66 const mojo::String& origin, |
65 int32_t port_id, | 67 int32_t port_id, |
66 const ConnectCallback& callback) { | 68 const ConnectCallback& callback) { |
67 if (!proxy_) { | 69 if (!proxy_) { |
68 callback.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), | 70 callback.Run(SERVICE_PORT_CONNECT_RESULT_REJECT, mojo::String(""), |
69 mojo::String("")); | 71 mojo::String("")); |
70 return; | 72 return; |
71 } | 73 } |
72 TRACE_EVENT0("ServiceWorker", "ServicePortDispatcherImpl::Connect"); | 74 TRACE_EVENT0("ServiceWorker", "ServicePortDispatcherImpl::Connect"); |
73 proxy_->dispatchServicePortConnectEvent(new WebConnectCallbacksImpl(callback), | 75 proxy_->dispatchServicePortConnectEvent(new WebConnectCallbacksImpl(callback), |
74 target_url.To<GURL>(), | 76 target_url.To<GURL>(), |
75 origin.To<base::string16>(), port_id); | 77 origin.To<base::string16>(), port_id); |
76 } | 78 } |
77 | 79 |
78 } // namespace content | 80 } // namespace content |
OLD | NEW |