OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/mojo/blink_service_registry_impl.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/bind.h" | |
10 #include "base/single_thread_task_runner.h" | |
11 #include "base/threading/thread_task_runner_handle.h" | |
12 #include "services/shell/public/cpp/interface_provider.h" | |
13 | |
14 namespace content { | |
15 | |
16 BlinkServiceRegistryImpl::BlinkServiceRegistryImpl( | |
17 base::WeakPtr<shell::InterfaceProvider> remote_interfaces) | |
18 : remote_interfaces_(remote_interfaces), | |
19 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | |
20 weak_ptr_factory_(this) {} | |
21 | |
22 BlinkServiceRegistryImpl::~BlinkServiceRegistryImpl() = default; | |
23 | |
24 void BlinkServiceRegistryImpl::connectToRemoteService( | |
25 const char* name, | |
26 mojo::ScopedMessagePipeHandle handle) { | |
27 if (!main_thread_task_runner_->BelongsToCurrentThread()) { | |
28 main_thread_task_runner_->PostTask( | |
29 FROM_HERE, base::Bind(&BlinkServiceRegistryImpl::connectToRemoteService, | |
30 weak_ptr_factory_.GetWeakPtr(), name, | |
31 base::Passed(&handle))); | |
32 return; | |
33 } | |
34 | |
35 if (!remote_interfaces_) | |
36 return; | |
37 | |
38 remote_interfaces_->GetInterface(name, std::move(handle)); | |
39 } | |
40 | |
41 } // namespace content | |
OLD | NEW |