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 "services/service_manager/public/cpp/lib/callback_binder.h" | |
6 | |
7 namespace service_manager { | |
8 namespace internal { | |
9 | |
10 GenericCallbackBinder::GenericCallbackBinder( | |
11 const BindCallback& callback, | |
12 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | |
13 : callback_(callback), task_runner_(task_runner) {} | |
14 | |
15 GenericCallbackBinder::~GenericCallbackBinder() {} | |
16 | |
17 void GenericCallbackBinder::BindInterface( | |
18 const BindSourceInfo& source_info, | |
19 const std::string& interface_name, | |
20 mojo::ScopedMessagePipeHandle handle) { | |
21 if (task_runner_) { | |
22 task_runner_->PostTask( | |
23 FROM_HERE, base::Bind(&GenericCallbackBinder::RunCallback, callback_, | |
24 base::Passed(&handle))); | |
25 return; | |
26 } | |
27 RunCallback(callback_, std::move(handle)); | |
28 } | |
29 | |
30 // static | |
31 void GenericCallbackBinder::RunCallback(const BindCallback& callback, | |
32 mojo::ScopedMessagePipeHandle handle) { | |
33 callback.Run(std::move(handle)); | |
34 } | |
35 | |
36 } // namespace internal | |
37 } // namespace service_manager | |
OLD | NEW |