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/navigator_connect/service_port_provider.h" | 5 #include "content/child/navigator_connect/service_port_provider.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
9 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
10 #include "content/child/child_thread_impl.h" | 12 #include "content/child/child_thread_impl.h" |
11 #include "content/child/webmessageportchannel_impl.h" | 13 #include "content/child/webmessageportchannel_impl.h" |
12 #include "content/common/message_port_messages.h" | 14 #include "content/common/message_port_messages.h" |
13 #include "content/common/service_port_type_converters.h" | 15 #include "content/common/service_port_type_converters.h" |
14 #include "content/public/common/navigator_connect_client.h" | 16 #include "content/public/common/navigator_connect_client.h" |
15 #include "mojo/common/common_type_converters.h" | 17 #include "mojo/common/common_type_converters.h" |
16 #include "third_party/WebKit/public/platform/WebURL.h" | 18 #include "third_party/WebKit/public/platform/WebURL.h" |
17 #include "third_party/WebKit/public/platform/modules/navigator_services/WebServi
cePortProviderClient.h" | 19 #include "third_party/WebKit/public/platform/modules/navigator_services/WebServi
cePortProviderClient.h" |
18 | 20 |
19 namespace content { | 21 namespace content { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 void ConnectToServiceOnMainThread( | 25 void ConnectToServiceOnMainThread( |
24 mojo::InterfaceRequest<ServicePortService> ptr) { | 26 mojo::InterfaceRequest<ServicePortService> ptr) { |
25 ChildThreadImpl::current()->service_registry()->ConnectToRemoteService( | 27 ChildThreadImpl::current()->service_registry()->ConnectToRemoteService( |
26 ptr.Pass()); | 28 std::move(ptr)); |
27 } | 29 } |
28 | 30 |
29 } // namespace | 31 } // namespace |
30 | 32 |
31 ServicePortProvider::ServicePortProvider( | 33 ServicePortProvider::ServicePortProvider( |
32 blink::WebServicePortProviderClient* client, | 34 blink::WebServicePortProviderClient* client, |
33 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop) | 35 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop) |
34 : client_(client), binding_(this), main_loop_(main_loop) { | 36 : client_(client), binding_(this), main_loop_(main_loop) { |
35 DCHECK(client_); | 37 DCHECK(client_); |
36 AddRef(); | 38 AddRef(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 ServicePortServicePtr& ServicePortProvider::GetServicePortServicePtr() { | 119 ServicePortServicePtr& ServicePortProvider::GetServicePortServicePtr() { |
118 if (!service_port_service_.get()) { | 120 if (!service_port_service_.get()) { |
119 mojo::InterfaceRequest<ServicePortService> request = | 121 mojo::InterfaceRequest<ServicePortService> request = |
120 mojo::GetProxy(&service_port_service_); | 122 mojo::GetProxy(&service_port_service_); |
121 main_loop_->PostTask(FROM_HERE, base::Bind(&ConnectToServiceOnMainThread, | 123 main_loop_->PostTask(FROM_HERE, base::Bind(&ConnectToServiceOnMainThread, |
122 base::Passed(&request))); | 124 base::Passed(&request))); |
123 | 125 |
124 // Setup channel for browser to post events back to this class. | 126 // Setup channel for browser to post events back to this class. |
125 ServicePortServiceClientPtr client_ptr; | 127 ServicePortServiceClientPtr client_ptr; |
126 binding_.Bind(GetProxy(&client_ptr)); | 128 binding_.Bind(GetProxy(&client_ptr)); |
127 service_port_service_->SetClient(client_ptr.Pass()); | 129 service_port_service_->SetClient(std::move(client_ptr)); |
128 } | 130 } |
129 return service_port_service_; | 131 return service_port_service_; |
130 } | 132 } |
131 | 133 |
132 } // namespace content | 134 } // namespace content |
OLD | NEW |