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

Unified Diff: mojo/public/bindings/lib/remote_ptr.h

Issue 109103003: Mojo: abstract interface implementation from generated Stub classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + fix build Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/bindings/lib/remote_ptr.h
diff --git a/mojo/public/bindings/lib/remote_ptr.h b/mojo/public/bindings/lib/remote_ptr.h
index 3b57594e23ef0ddf722990d892673ba04ea60c7c..a0c42e33c64dabd946f2f0e8e7e479e8538d4983 100644
--- a/mojo/public/bindings/lib/remote_ptr.h
+++ b/mojo/public/bindings/lib/remote_ptr.h
@@ -22,8 +22,7 @@ namespace mojo {
// class FooClientImpl : public FooClientStub {
// public:
// explicit FooClientImpl(const mojo::MessagePipeHandle& message_pipe)
-// : foo_(message_pipe) {
-// foo_.SetPeer(this);
+// : foo_(message_pipe, this) {
// foo_.Ping();
// }
// virtual void Pong() {
@@ -38,8 +37,7 @@ namespace mojo {
// class FooImpl : public FooStub {
// public:
// explicit FooImpl(const mojo::MessagePipeHandle& message_pipe)
-// : client_(message_pipe) {
-// client_.SetPeer(this);
+// : client_(message_pipe, this) {
// }
// virtual void Ping() {
// client_->Pong();
@@ -54,8 +52,9 @@ class RemotePtr {
public:
RemotePtr() : state_(NULL) {}
- explicit RemotePtr(ScopedMessagePipeHandle message_pipe)
- : state_(new State(message_pipe.Pass())) {
+ explicit RemotePtr(ScopedMessagePipeHandle message_pipe,
+ typename S::_Peer* peer = NULL)
+ : state_(new State(message_pipe.Pass(), peer)) {
}
// Move-only constructor and operator=.
@@ -87,9 +86,10 @@ class RemotePtr {
state_ = NULL;
}
- void reset(ScopedMessagePipeHandle message_pipe) {
+ void reset(ScopedMessagePipeHandle message_pipe,
+ typename S::_Peer* peer = NULL) {
delete state_;
- state_ = new State(message_pipe.Pass());
+ state_ = new State(message_pipe.Pass(), peer);
}
bool encountered_error() const {
@@ -97,19 +97,18 @@ class RemotePtr {
return state_->connector.encountered_error();
}
- void SetPeer(typename S::_Peer::_Stub* peer) {
- assert(state_);
- state_->connector.SetIncomingReceiver(peer);
- }
-
private:
struct State {
- State(ScopedMessagePipeHandle message_pipe)
+ State(ScopedMessagePipeHandle message_pipe, typename S::_Peer* peer)
: connector(message_pipe.Pass()),
- proxy(&connector) {
+ proxy(&connector),
+ stub(peer) {
+ if (peer)
+ connector.SetIncomingReceiver(&stub);
}
internal::Connector connector;
typename S::_Proxy proxy;
+ typename S::_Peer::_Stub stub;
};
State* release() {

Powered by Google App Engine
This is Rietveld 408576698