OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ |
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
12 #include "services/service_manager/public/cpp/interface_binder.h" | 12 #include "services/service_manager/public/cpp/interface_binder.h" |
13 | 13 |
14 namespace shell { | 14 namespace service_manager { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 template <typename Interface> | 17 template <typename Interface> |
18 class CallbackBinder : public InterfaceBinder { | 18 class CallbackBinder : public InterfaceBinder { |
19 public: | 19 public: |
20 // Method that binds a request for Interface. | 20 // Method that binds a request for Interface. |
21 using BindCallback = | 21 using BindCallback = |
22 base::Callback<void(mojo::InterfaceRequest<Interface>)>; | 22 base::Callback<void(mojo::InterfaceRequest<Interface>)>; |
23 | 23 |
24 explicit CallbackBinder( | 24 explicit CallbackBinder( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 public: | 60 public: |
61 using BindCallback = base::Callback<void(mojo::ScopedMessagePipeHandle)>; | 61 using BindCallback = base::Callback<void(mojo::ScopedMessagePipeHandle)>; |
62 | 62 |
63 explicit GenericCallbackBinder( | 63 explicit GenericCallbackBinder( |
64 const BindCallback& callback, | 64 const BindCallback& callback, |
65 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 65 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
66 ~GenericCallbackBinder() override; | 66 ~GenericCallbackBinder() override; |
67 | 67 |
68 private: | 68 private: |
69 // InterfaceBinder: | 69 // InterfaceBinder: |
70 void BindInterface(const shell::Identity& remote_identity, | 70 void BindInterface(const service_manager::Identity& remote_identity, |
71 const std::string& interface_name, | 71 const std::string& interface_name, |
72 mojo::ScopedMessagePipeHandle handle) override; | 72 mojo::ScopedMessagePipeHandle handle) override; |
73 | 73 |
74 static void RunCallbackOnTaskRunner( | 74 static void RunCallbackOnTaskRunner( |
75 const BindCallback& callback, | 75 const BindCallback& callback, |
76 mojo::ScopedMessagePipeHandle client_handle); | 76 mojo::ScopedMessagePipeHandle client_handle); |
77 | 77 |
78 const BindCallback callback_; | 78 const BindCallback callback_; |
79 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 79 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
80 DISALLOW_COPY_AND_ASSIGN(GenericCallbackBinder); | 80 DISALLOW_COPY_AND_ASSIGN(GenericCallbackBinder); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace internal | 83 } // namespace internal |
84 } // namespace shell | 84 } // namespace service_manager |
85 | 85 |
86 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ | 86 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ |
OLD | NEW |