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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_ptr_internal.h

Issue 339403003: Mojo: Make GetDefault{AsyncWaiter,Logger} static methods of Environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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_LIB_INTERFACE_PTR_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 10
11 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 11 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
12 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 12 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
13 #include "mojo/public/cpp/bindings/lib/router.h" 13 #include "mojo/public/cpp/bindings/lib/router.h"
14 #include "mojo/public/cpp/environment/environment.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace internal { 17 namespace internal {
17 18
18 template <typename Interface> 19 template <typename Interface>
19 class InterfacePtrState { 20 class InterfacePtrState {
20 public: 21 public:
21 InterfacePtrState() : proxy_(NULL), router_(NULL) {} 22 InterfacePtrState() : proxy_(NULL), router_(NULL) {}
22 23
23 ~InterfacePtrState() { 24 ~InterfacePtrState() {
24 // Destruction order matters here. We delete |proxy_| first, even though 25 // Destruction order matters here. We delete |proxy_| first, even though
25 // |router_| may have a reference to it, so that |~Interface| may have a 26 // |router_| may have a reference to it, so that |~Interface| may have a
26 // shot at generating new outbound messages (ie, invoking client methods). 27 // shot at generating new outbound messages (ie, invoking client methods).
27 delete proxy_; 28 delete proxy_;
28 delete router_; 29 delete router_;
29 } 30 }
30 31
31 Interface* instance() const { return proxy_; } 32 Interface* instance() const { return proxy_; }
32 33
33 Router* router() const { return router_; } 34 Router* router() const { return router_; }
34 35
35 void Swap(InterfacePtrState* other) { 36 void Swap(InterfacePtrState* other) {
36 std::swap(other->proxy_, proxy_); 37 std::swap(other->proxy_, proxy_);
37 std::swap(other->router_, router_); 38 std::swap(other->router_, router_);
38 } 39 }
39 40
40 void ConfigureProxy(ScopedMessagePipeHandle handle, 41 void ConfigureProxy(
41 const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { 42 ScopedMessagePipeHandle handle,
43 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
42 assert(!proxy_); 44 assert(!proxy_);
43 assert(!router_); 45 assert(!router_);
44 46
45 FilterChain filters; 47 FilterChain filters;
46 filters.Append<MessageHeaderValidator>(); 48 filters.Append<MessageHeaderValidator>();
47 filters.Append<typename Interface::Client::RequestValidator_>(); 49 filters.Append<typename Interface::Client::RequestValidator_>();
48 filters.Append<typename Interface::ResponseValidator_>(); 50 filters.Append<typename Interface::ResponseValidator_>();
49 51
50 router_ = new Router(handle.Pass(), filters.Pass(), waiter); 52 router_ = new Router(handle.Pass(), filters.Pass(), waiter);
51 ProxyWithStub* proxy = new ProxyWithStub(router_); 53 ProxyWithStub* proxy = new ProxyWithStub(router_);
(...skipping 21 matching lines...) Expand all
73 ProxyWithStub* proxy_; 75 ProxyWithStub* proxy_;
74 Router* router_; 76 Router* router_;
75 77
76 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 78 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
77 }; 79 };
78 80
79 } // namespace internal 81 } // namespace internal
80 } // namespace mojo 82 } // namespace mojo
81 83
82 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_ 84 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_impl_internal.h ('k') | mojo/public/cpp/bindings/lib/router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698