| 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/browser/navigator_connect/service_port_service_impl.h" | 5 #include "content/browser/navigator_connect/service_port_service_impl.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
| 8 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
| 9 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" | 11 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" |
| 10 #include "content/common/service_port_type_converters.h" | 12 #include "content/common/service_port_type_converters.h" |
| 11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/common/message_port_types.h" | 14 #include "content/public/common/message_port_types.h" |
| 13 #include "mojo/common/common_type_converters.h" | 15 #include "mojo/common/common_type_converters.h" |
| 14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 mojo::Array<int32_t>::From(new_routing_ids)); | 60 mojo::Array<int32_t>::From(new_routing_ids)); |
| 59 } | 61 } |
| 60 | 62 |
| 61 // static | 63 // static |
| 62 void ServicePortServiceImpl::CreateOnIOThread( | 64 void ServicePortServiceImpl::CreateOnIOThread( |
| 63 const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context, | 65 const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context, |
| 64 const scoped_refptr<MessagePortMessageFilter>& message_port_message_filter, | 66 const scoped_refptr<MessagePortMessageFilter>& message_port_message_filter, |
| 65 mojo::InterfaceRequest<ServicePortService> request) { | 67 mojo::InterfaceRequest<ServicePortService> request) { |
| 66 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 68 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 67 new ServicePortServiceImpl(navigator_connect_context, | 69 new ServicePortServiceImpl(navigator_connect_context, |
| 68 message_port_message_filter, request.Pass()); | 70 message_port_message_filter, std::move(request)); |
| 69 } | 71 } |
| 70 | 72 |
| 71 ServicePortServiceImpl::ServicePortServiceImpl( | 73 ServicePortServiceImpl::ServicePortServiceImpl( |
| 72 const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context, | 74 const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context, |
| 73 const scoped_refptr<MessagePortMessageFilter>& message_port_message_filter, | 75 const scoped_refptr<MessagePortMessageFilter>& message_port_message_filter, |
| 74 mojo::InterfaceRequest<ServicePortService> request) | 76 mojo::InterfaceRequest<ServicePortService> request) |
| 75 : binding_(this, request.Pass()), | 77 : binding_(this, std::move(request)), |
| 76 navigator_connect_context_(navigator_connect_context), | 78 navigator_connect_context_(navigator_connect_context), |
| 77 message_port_message_filter_(message_port_message_filter), | 79 message_port_message_filter_(message_port_message_filter), |
| 78 weak_ptr_factory_(this) { | 80 weak_ptr_factory_(this) { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 81 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void ServicePortServiceImpl::SetClient(ServicePortServiceClientPtr client) { | 84 void ServicePortServiceImpl::SetClient(ServicePortServiceClientPtr client) { |
| 83 DCHECK(!client_.get()); | 85 DCHECK(!client_.get()); |
| 84 // TODO(mek): Set ErrorHandler to listen for errors. | 86 // TODO(mek): Set ErrorHandler to listen for errors. |
| 85 client_ = client.Pass(); | 87 client_ = std::move(client); |
| 86 } | 88 } |
| 87 | 89 |
| 88 void ServicePortServiceImpl::Connect(const mojo::String& target_url, | 90 void ServicePortServiceImpl::Connect(const mojo::String& target_url, |
| 89 const mojo::String& origin, | 91 const mojo::String& origin, |
| 90 const ConnectCallback& callback) { | 92 const ConnectCallback& callback) { |
| 91 navigator_connect_context_->Connect( | 93 navigator_connect_context_->Connect( |
| 92 GURL(target_url), GURL(origin), this, | 94 GURL(target_url), GURL(origin), this, |
| 93 base::Bind(&ServicePortServiceImpl::OnConnectResult, | 95 base::Bind(&ServicePortServiceImpl::OnConnectResult, |
| 94 weak_ptr_factory_.GetWeakPtr(), callback)); | 96 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 95 } | 97 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 121 | 123 |
| 122 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, | 124 void ServicePortServiceImpl::OnConnectResult(const ConnectCallback& callback, |
| 123 int message_port_id, | 125 int message_port_id, |
| 124 bool success) { | 126 bool success) { |
| 125 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT | 127 callback.Run(success ? SERVICE_PORT_CONNECT_RESULT_ACCEPT |
| 126 : SERVICE_PORT_CONNECT_RESULT_REJECT, | 128 : SERVICE_PORT_CONNECT_RESULT_REJECT, |
| 127 message_port_id); | 129 message_port_id); |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace content | 132 } // namespace content |
| OLD | NEW |