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

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

Issue 2702603002: Mojo C++ bindings: remove unnecessary getters/params of AssociatedGroup. (Closed)
Patch Set: . Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ASSOCIATED_GROUP_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
11 #include "mojo/public/cpp/bindings/associated_interface_request.h"
12 #include "mojo/public/cpp/bindings/bindings_export.h" 10 #include "mojo/public/cpp/bindings/bindings_export.h"
13 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 11 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
14 12
15 namespace mojo { 13 namespace mojo {
16 14
17 class AssociatedGroupController; 15 class AssociatedGroupController;
18 16
19 // AssociatedGroup refers to all the interface endpoints running at one end of a 17 // AssociatedGroup refers to all the interface endpoints running at one end of a
20 // message pipe. 18 // message pipe.
21 // It is thread safe and cheap to make copies. 19 // It is thread safe and cheap to make copies.
(...skipping 14 matching lines...) Expand all
36 // The return value of this getter if this object is initialized with a 34 // The return value of this getter if this object is initialized with a
37 // ScopedInterfaceEndpointHandle: 35 // ScopedInterfaceEndpointHandle:
38 // - If the handle is invalid, the return value will always be null. 36 // - If the handle is invalid, the return value will always be null.
39 // - If the handle is valid and non-pending, the return value will be 37 // - If the handle is valid and non-pending, the return value will be
40 // non-null and remain unchanged even if the handle is later reset. 38 // non-null and remain unchanged even if the handle is later reset.
41 // - If the handle is pending asssociation, the return value will initially 39 // - If the handle is pending asssociation, the return value will initially
42 // be null, change to non-null when/if the handle is associated, and 40 // be null, change to non-null when/if the handle is associated, and
43 // remain unchanged ever since. 41 // remain unchanged ever since.
44 AssociatedGroupController* GetController(); 42 AssociatedGroupController* GetController();
45 43
46 // TODO(yzshen): Remove the following public method. It is not needed anymore.
47 // Configuration used by CreateAssociatedInterface(). Please see the comments
48 // of that method for more details.
49 enum AssociatedInterfaceConfig { WILL_PASS_PTR, WILL_PASS_REQUEST };
50
51 // |config| indicates whether |ptr_info| or |request| will be sent to the
52 // remote side of the message pipe.
53 //
54 // NOTE: If |config| is |WILL_PASS_REQUEST|, you will want to bind |ptr_info|
55 // to a local AssociatedInterfacePtr to make calls. However, there is one
56 // restriction: the pointer should NOT be used to make calls before |request|
57 // is sent. Violating that will cause the message pipe to be closed. On the
58 // other hand, as soon as |request| is sent, the pointer is usable. There is
59 // no need to wait until |request| is bound to an implementation at the remote
60 // side.
61 template <typename T>
62 void CreateAssociatedInterface(AssociatedInterfaceConfig config,
63 AssociatedInterfacePtrInfo<T>* ptr_info,
64 AssociatedInterfaceRequest<T>* request) {
65 ScopedInterfaceEndpointHandle handle0;
66 ScopedInterfaceEndpointHandle handle1;
67 ScopedInterfaceEndpointHandle::CreatePairPendingAssociation(&handle0,
68 &handle1);
69
70 ptr_info->set_handle(std::move(handle0));
71 request->Bind(std::move(handle1));
72
73 if (config == WILL_PASS_PTR) {
74 // The implementation is local, therefore set the version according to
75 // the interface definition that this code is built against.
76 ptr_info->set_version(T::Version_);
77 } else {
78 // The implementation is remote, we don't know about its actual version
79 // yet.
80 ptr_info->set_version(0u);
81 }
82 }
83
84 private: 44 private:
85 base::Callback<AssociatedGroupController*()> controller_getter_; 45 base::Callback<AssociatedGroupController*()> controller_getter_;
86 scoped_refptr<AssociatedGroupController> controller_; 46 scoped_refptr<AssociatedGroupController> controller_;
87 }; 47 };
88 48
89 } // namespace mojo 49 } // namespace mojo
90 50
91 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ 51 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_binding.h ('k') | mojo/public/cpp/bindings/associated_interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698