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/shell/public/cpp/lib/callback_binder.h" | |
6 | |
7 namespace shell { | |
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 Identity& remote_identity, | |
19 const std::string& interface_name, | |
20 mojo::ScopedMessagePipeHandle handle) { | |
21 if (task_runner_) { | |
22 task_runner_->PostTask( | |
23 FROM_HERE, | |
24 base::Bind(&GenericCallbackBinder::RunCallbackOnTaskRunner, callback_, | |
25 base::Passed(&handle))); | |
26 return; | |
27 } | |
28 callback_.Run(std::move(handle)); | |
29 } | |
30 | |
31 // static | |
32 void GenericCallbackBinder::RunCallbackOnTaskRunner( | |
33 const BindCallback& callback, | |
34 mojo::ScopedMessagePipeHandle client_handle) { | |
35 callback.Run(std::move(client_handle)); | |
36 } | |
37 | |
38 } // namespace internal | |
39 } // namespace shell | |
OLD | NEW |