Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: services/shell/public/cpp/lib/callback_binder.h

Issue 2079943002: Change RenderFrame to use InterfaceRegistry et al. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SHELL_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ 6 #define SERVICES_SHELL_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"
(...skipping 13 matching lines...) Expand all
24 explicit CallbackBinder( 24 explicit CallbackBinder(
25 const BindCallback& callback, 25 const BindCallback& callback,
26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) 26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
27 : callback_(callback), task_runner_(task_runner) {} 27 : callback_(callback), task_runner_(task_runner) {}
28 ~CallbackBinder() override {} 28 ~CallbackBinder() override {}
29 29
30 private: 30 private:
31 // InterfaceBinder: 31 // InterfaceBinder:
32 void BindInterface(Connection* connection, 32 void BindInterface(Connection* connection,
33 const std::string& interface_name, 33 const std::string& interface_name,
34 mojo::ScopedMessagePipeHandle client_handle) override { 34 mojo::ScopedMessagePipeHandle handle) override {
35 mojo::InterfaceRequest<Interface> request =
36 mojo::MakeRequest<Interface>(std::move(handle));
35 if (task_runner_) { 37 if (task_runner_) {
36 task_runner_->PostTask( 38 task_runner_->PostTask(
37 FROM_HERE, 39 FROM_HERE,
38 base::Bind(&CallbackBinder::RunCallbackOnTaskRunner, callback_, 40 base::Bind(&CallbackBinder::RunCallbackOnTaskRunner, callback_,
39 base::Passed(&client_handle))); 41 base::Passed(&request)));
40 return; 42 return;
41 } 43 }
42 callback_.Run(std::move(client_handle)); 44 callback_.Run(std::move(request));
43 } 45 }
44 46
45 static void RunCallbackOnTaskRunner( 47 static void RunCallbackOnTaskRunner(
46 const BindCallback& callback, 48 const BindCallback& callback,
47 mojo::ScopedMessagePipeHandle client_handle) { 49 mojo::InterfaceRequest<Interface> client) {
48 callback.Run(std::move(client_handle)); 50 callback.Run(std::move(client));
49 } 51 }
50 52
51 const BindCallback callback_; 53 const BindCallback callback_;
52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 54 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
53 DISALLOW_COPY_AND_ASSIGN(CallbackBinder); 55 DISALLOW_COPY_AND_ASSIGN(CallbackBinder);
54 }; 56 };
55 57
58 class GenericCallbackBinder : public InterfaceBinder {
59 public:
60 // Method that binds a request for Interface.
61 using BindCallback = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
62
63 explicit GenericCallbackBinder(
64 const BindCallback& callback,
65 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
66 ~GenericCallbackBinder() override;
67
68 private:
69 // InterfaceBinder:
70 void BindInterface(
71 Connection* connection,
72 const std::string& interface_name,
73 mojo::ScopedMessagePipeHandle handle) override;
74
75 static void RunCallbackOnTaskRunner(
76 const BindCallback& callback,
77 mojo::ScopedMessagePipeHandle client_handle);
78
79 const BindCallback callback_;
80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
81 DISALLOW_COPY_AND_ASSIGN(GenericCallbackBinder);
82 };
83
56 } // namespace internal 84 } // namespace internal
57 } // namespace shell 85 } // namespace shell
58 86
59 #endif // SERVICES_SHELL_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_ 87 #endif // SERVICES_SHELL_PUBLIC_CPP_LIB_CALLBACK_BINDER_H_
OLDNEW
« no previous file with comments | « services/shell/public/cpp/interface_registry.h ('k') | services/shell/public/cpp/lib/callback_binder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698