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

Side by Side Diff: mojo/public/cpp/bindings/interface_impl.h

Issue 289063015: Mojo: Remove SetClient from generated interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_
7 7
8 #include "mojo/public/cpp/bindings/lib/interface_impl_internal.h" 8 #include "mojo/public/cpp/bindings/lib/interface_impl_internal.h"
9 #include "mojo/public/cpp/system/macros.h" 9 #include "mojo/public/cpp/system/macros.h"
10 10
(...skipping 23 matching lines...) Expand all
34 // is called. After this method is called, any method calls made on client() 34 // is called. After this method is called, any method calls made on client()
35 // will be silently ignored. 35 // will be silently ignored.
36 virtual void OnConnectionError() {} 36 virtual void OnConnectionError() {}
37 37
38 // DO NOT USE. Exposed only for internal use and for testing. 38 // DO NOT USE. Exposed only for internal use and for testing.
39 internal::InterfaceImplState<Interface>* internal_state() { 39 internal::InterfaceImplState<Interface>* internal_state() {
40 return &internal_state_; 40 return &internal_state_;
41 } 41 }
42 42
43 private: 43 private:
44 virtual void SetClient(Client* client) MOJO_OVERRIDE {
45 internal_state_.set_client(client);
46 }
47 internal::InterfaceImplState<Interface> internal_state_; 44 internal::InterfaceImplState<Interface> internal_state_;
48 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImpl); 45 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImpl);
49 }; 46 };
50 47
51 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given 48 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given
52 // MessagePipe. The instance is returned for convenience in member initializer 49 // MessagePipe. The instance is returned for convenience in member initializer
53 // lists, etc. If the pipe is closed, the instance's OnConnectionError method 50 // lists, etc. If the pipe is closed, the instance's OnConnectionError method
54 // will be called. 51 // will be called.
55 // 52 //
56 // The instance is also bound to the current thread. Its methods will only be 53 // The instance is also bound to the current thread. Its methods will only be
57 // called on the current thread, and if the current thread exits, then it will 54 // called on the current thread, and if the current thread exits, then it will
58 // also be deleted, and along with it, its end point of the pipe will be closed. 55 // also be deleted, and along with it, its end point of the pipe will be closed.
59 // 56 //
60 // Before returning, the instance will receive a SetClient call, providing it 57 // Before returning, the instance's OnConnectionEstablished method is called.
61 // with a proxy to the client on the other end of the pipe.
62 template <typename Impl> 58 template <typename Impl>
63 Impl* BindToPipe(Impl* instance, 59 Impl* BindToPipe(Impl* instance,
64 ScopedMessagePipeHandle handle, 60 ScopedMessagePipeHandle handle,
65 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { 61 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) {
66 instance->internal_state()->Bind(handle.Pass(), waiter); 62 instance->internal_state()->Bind(handle.Pass(), waiter);
67 return instance; 63 return instance;
68 } 64 }
69 65
70 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given 66 // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given
71 // InterfacePtr<..>. The instance is returned for convenience in member 67 // InterfacePtr<..>. The instance is returned for convenience in member
72 // initializer lists, etc. If the pipe is closed, the instance's 68 // initializer lists, etc. If the pipe is closed, the instance's
73 // OnConnectionError method will be called. 69 // OnConnectionError method will be called.
74 // 70 //
75 // The instance is also bound to the current thread. Its methods will only be 71 // The instance is also bound to the current thread. Its methods will only be
76 // called on the current thread, and if the current thread exits, then it will 72 // called on the current thread, and if the current thread exits, then it will
77 // also be deleted, and along with it, its end point of the pipe will be closed. 73 // also be deleted, and along with it, its end point of the pipe will be closed.
78 // 74 //
79 // Before returning, the instance will receive a SetClient call, providing it 75 // Before returning, the instance's OnConnectionEstablished method is called.
80 // with a proxy to the client on the other end of the pipe.
81 template <typename Impl, typename Interface> 76 template <typename Impl, typename Interface>
82 Impl* BindToProxy(Impl* instance, 77 Impl* BindToProxy(Impl* instance,
83 InterfacePtr<Interface>* ptr, 78 InterfacePtr<Interface>* ptr,
84 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { 79 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) {
85 instance->internal_state()->BindProxy(ptr, waiter); 80 instance->internal_state()->BindProxy(ptr, waiter);
86 return instance; 81 return instance;
87 } 82 }
88 83
89 } // namespace mojo 84 } // namespace mojo
90 85
91 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_ 86 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698