summaryrefslogtreecommitdiffstats
path: root/mojo/services
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 22:35:51 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 22:35:51 +0000
commit5e1a832c8186ef29546b6b60f90d7974ca72d3c9 (patch)
tree41b3fd3eaf316e7353a566c2b8923566788dd446 /mojo/services
parent92028f1406eeb252247b55b8db63b1b8cdf69945 (diff)
downloadchromium_src-5e1a832c8186ef29546b6b60f90d7974ca72d3c9.zip
chromium_src-5e1a832c8186ef29546b6b60f90d7974ca72d3c9.tar.gz
chromium_src-5e1a832c8186ef29546b6b60f90d7974ca72d3c9.tar.bz2
Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl
Interfaces no longer have explicit Peer attributes. An interface may now optionally have a Client interface, in which case a SetClient method will be auto-generated. InterfacePtr is a proxy to a remote instance of an interface. InterfaceImpl is a base class used when implementing an interface. Both have facilities for binding to a pipe, etc. An InterfacePtr is movable but not copyable and looks a lot like RemotePtr save for how it gets initialized (via the Bind method now). I've added some new top-level functions: MakeProxy - makes it easy to initialize an InterfacePtr in say a member initializer list. BindToPipe - this is how you bind an InterfaceImpl to a pipe. once bound, they cannot be unbound until the object is destroyed or the pipe is closed. BindToProxy - builds on top of BindToPipe, however, it hides the details of the pipe. What you get back is an InterfacePtr. Generated C++ code now passes InterfacePtr instead of InterfaceHandle. As a result, we have far less need for typed subclasses of MessagePipeHandle, so I eliminated them. The code that needs to deal with raw handles generally has to deal with {Scoped}MessagePipeHandle, and adding strong typing to these handles doesn't seem helpful anymore. R=davemoore@chromium.org Review URL: https://codereview.chromium.org/265793015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/services')
-rw-r--r--mojo/services/dbus_echo/dbus_echo_service.cc5
-rw-r--r--mojo/services/dbus_echo/echo.mojom5
-rw-r--r--mojo/services/gles2/command_buffer.mojom4
-rw-r--r--mojo/services/gles2/command_buffer_impl.cc17
-rw-r--r--mojo/services/gles2/command_buffer_impl.h14
-rw-r--r--mojo/services/native_viewport/native_viewport.mojom3
-rw-r--r--mojo/services/native_viewport/native_viewport_service.cc39
-rw-r--r--mojo/services/native_viewport/native_viewport_service.h3
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc13
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h3
-rw-r--r--mojo/services/public/interfaces/view_manager/view_manager.mojom3
-rw-r--r--mojo/services/view_manager/main.cc8
-rw-r--r--mojo/services/view_manager/root_view_manager.cc10
-rw-r--r--mojo/services/view_manager/view_manager_connection.cc20
-rw-r--r--mojo/services/view_manager/view_manager_connection.h9
-rw-r--r--mojo/services/view_manager/view_manager_connection_unittest.cc20
16 files changed, 83 insertions, 93 deletions
diff --git a/mojo/services/dbus_echo/dbus_echo_service.cc b/mojo/services/dbus_echo/dbus_echo_service.cc
index 70762f6..f1f5ced 100644
--- a/mojo/services/dbus_echo/dbus_echo_service.cc
+++ b/mojo/services/dbus_echo/dbus_echo_service.cc
@@ -12,13 +12,12 @@
#include "mojo/common/channel_init.h"
#include "mojo/dbus/dbus_external_service.h"
#include "mojo/embedder/embedder.h"
-#include "mojo/public/cpp/bindings/interface.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/services/dbus_echo/echo.mojom.h"
namespace {
-class EchoServiceImpl : public mojo::ServiceConnection<mojo::EchoService,
- EchoServiceImpl> {
+class EchoServiceImpl
+ : public mojo::ServiceConnection<mojo::EchoService, EchoServiceImpl> {
public:
EchoServiceImpl() {}
virtual ~EchoServiceImpl() {}
diff --git a/mojo/services/dbus_echo/echo.mojom b/mojo/services/dbus_echo/echo.mojom
index c2ad42a..937737c 100644
--- a/mojo/services/dbus_echo/echo.mojom
+++ b/mojo/services/dbus_echo/echo.mojom
@@ -4,13 +4,8 @@
module mojo {
-[Peer=EchoClient]
interface EchoService {
Echo(string to_echo) => (string echoed);
};
-[Peer=EchoService]
-interface EchoClient {
-};
-
}
diff --git a/mojo/services/gles2/command_buffer.mojom b/mojo/services/gles2/command_buffer.mojom
index c10a9a3..1f91362 100644
--- a/mojo/services/gles2/command_buffer.mojom
+++ b/mojo/services/gles2/command_buffer.mojom
@@ -19,7 +19,7 @@ interface CommandBufferSyncClient {
DidMakeProgress(CommandBufferState state);
};
-[Peer=CommandBufferClient]
+[Client=CommandBufferClient]
interface CommandBuffer {
Initialize(CommandBufferSyncClient sync_client,
handle<shared_buffer> shared_state);
@@ -38,7 +38,6 @@ interface CommandBuffer {
// TODO(piman): sync points
};
-[Peer=CommandBuffer]
interface CommandBufferClient {
DidDestroy();
LostContext(int32 lost_reason); // TODO(piman): enum
@@ -48,4 +47,3 @@ interface CommandBufferClient {
};
}
-
diff --git a/mojo/services/gles2/command_buffer_impl.cc b/mojo/services/gles2/command_buffer_impl.cc
index bbeb393..0e39837 100644
--- a/mojo/services/gles2/command_buffer_impl.cc
+++ b/mojo/services/gles2/command_buffer_impl.cc
@@ -48,10 +48,9 @@ class MemoryTrackerStub : public gpu::gles2::MemoryTracker {
} // anonymous namespace
-CommandBufferImpl::CommandBufferImpl(ScopedCommandBufferClientHandle client,
- gfx::AcceleratedWidget widget,
+CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget,
const gfx::Size& size)
- : client_(client.Pass(), this), widget_(widget), size_(size) {}
+ : widget_(widget), size_(size) {}
CommandBufferImpl::~CommandBufferImpl() {
client_->DidDestroy();
@@ -61,10 +60,18 @@ CommandBufferImpl::~CommandBufferImpl() {
}
}
+void CommandBufferImpl::OnConnectionError() {
+ // TODO(darin): How should we handle this error?
+}
+
+void CommandBufferImpl::SetClient(CommandBufferClient* client) {
+ client_ = client;
+}
+
void CommandBufferImpl::Initialize(
- ScopedCommandBufferSyncClientHandle sync_client,
+ CommandBufferSyncClientPtr sync_client,
mojo::ScopedSharedBufferHandle shared_state) {
- sync_client_.reset(sync_client.Pass(), NULL);
+ sync_client_ = sync_client.Pass();
sync_client_->DidInitialize(DoInitialize(shared_state.Pass()));
}
diff --git a/mojo/services/gles2/command_buffer_impl.h b/mojo/services/gles2/command_buffer_impl.h
index 3a461e5..e76a3d2 100644
--- a/mojo/services/gles2/command_buffer_impl.h
+++ b/mojo/services/gles2/command_buffer_impl.h
@@ -7,7 +7,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/timer/timer.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/services/gles2/command_buffer.mojom.h"
#include "ui/gfx/native_widget_types.h"
@@ -25,14 +24,15 @@ class GLES2Decoder;
namespace mojo {
namespace services {
-class CommandBufferImpl : public CommandBuffer {
+class CommandBufferImpl : public InterfaceImpl<CommandBuffer> {
public:
- CommandBufferImpl(ScopedCommandBufferClientHandle client,
- gfx::AcceleratedWidget widget,
+ CommandBufferImpl(gfx::AcceleratedWidget widget,
const gfx::Size& size);
virtual ~CommandBufferImpl();
- virtual void Initialize(ScopedCommandBufferSyncClientHandle sync_client,
+ virtual void OnConnectionError() OVERRIDE;
+ virtual void SetClient(CommandBufferClient* client) OVERRIDE;
+ virtual void Initialize(CommandBufferSyncClientPtr sync_client,
mojo::ScopedSharedBufferHandle shared_state) OVERRIDE;
virtual void SetGetBuffer(int32_t buffer) OVERRIDE;
virtual void Flush(int32_t put_offset) OVERRIDE;
@@ -54,8 +54,8 @@ class CommandBufferImpl : public CommandBuffer {
void DrawAnimationFrame();
- RemotePtr<CommandBufferClient> client_;
- RemotePtr<CommandBufferSyncClient> sync_client_;
+ CommandBufferClient* client_;
+ CommandBufferSyncClientPtr sync_client_;
gfx::AcceleratedWidget widget_;
gfx::Size size_;
diff --git a/mojo/services/native_viewport/native_viewport.mojom b/mojo/services/native_viewport/native_viewport.mojom
index 189ba12..eef750c 100644
--- a/mojo/services/native_viewport/native_viewport.mojom
+++ b/mojo/services/native_viewport/native_viewport.mojom
@@ -37,7 +37,7 @@ struct Event {
TouchData touch_data;
};
-[Peer=NativeViewportClient]
+[Client=NativeViewportClient]
interface NativeViewport {
Create(Rect bounds);
Show();
@@ -47,7 +47,6 @@ interface NativeViewport {
CreateGLES2Context(handle<message_pipe> gles2_client);
};
-[Peer=NativeViewport]
interface NativeViewportClient {
OnCreated();
OnBoundsChanged(Rect bounds);
diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc
index 9585ae7..faba578 100644
--- a/mojo/services/native_viewport/native_viewport_service.cc
+++ b/mojo/services/native_viewport/native_viewport_service.cc
@@ -34,7 +34,8 @@ class NativeViewportImpl
public NativeViewportDelegate {
public:
NativeViewportImpl()
- : widget_(gfx::kNullAcceleratedWidget),
+ : client_(NULL),
+ widget_(gfx::kNullAcceleratedWidget),
waiting_for_event_ack_(false) {}
virtual ~NativeViewportImpl() {
// Destroy the NativeViewport early on as it may call us back during
@@ -42,11 +43,15 @@ class NativeViewportImpl
native_viewport_.reset();
}
+ virtual void SetClient(NativeViewportClient* client) OVERRIDE {
+ client_ = client;
+ }
+
virtual void Create(const Rect& bounds) OVERRIDE {
native_viewport_ =
services::NativeViewport::Create(context(), this);
native_viewport_->Init(bounds);
- client()->OnCreated();
+ client_->OnCreated();
OnBoundsChanged(bounds);
}
@@ -72,17 +77,13 @@ class NativeViewportImpl
virtual void CreateGLES2Context(ScopedMessagePipeHandle client_handle)
OVERRIDE {
- if (command_buffer_ || command_buffer_handle_.is_valid()) {
+ if (command_buffer_.get() || command_buffer_handle_.is_valid()) {
LOG(ERROR) << "Can't create multiple contexts on a NativeViewport";
return;
}
- // TODO(darin):
- // CreateGLES2Context should accept a ScopedCommandBufferClientHandle once
- // it is possible to import interface definitions from another module. For
- // now, we just kludge it.
- command_buffer_handle_.reset(
- InterfaceHandle<CommandBufferClient>(client_handle.release().value()));
+ // TODO(darin): CreateGLES2Context should accept a |CommandBufferPtr*|.
+ command_buffer_handle_ = client_handle.Pass();
CreateCommandBufferIfNeeded();
}
@@ -100,8 +101,9 @@ class NativeViewportImpl
gfx::Size size = native_viewport_->GetSize();
if (size.IsEmpty())
return;
- command_buffer_.reset(new CommandBufferImpl(
- command_buffer_handle_.Pass(), widget_, native_viewport_->GetSize()));
+ command_buffer_.reset(
+ BindToPipe(new CommandBufferImpl(widget_, native_viewport_->GetSize()),
+ command_buffer_handle_.Pass()));
}
virtual bool OnEvent(ui::Event* ui_event) OVERRIDE {
@@ -151,9 +153,9 @@ class NativeViewportImpl
event.set_key_data(key_data.Finish());
}
- client()->OnEvent(event.Finish(),
- base::Bind(&NativeViewportImpl::AckEvent,
- base::Unretained(this)));
+ client_->OnEvent(event.Finish(),
+ base::Bind(&NativeViewportImpl::AckEvent,
+ base::Unretained(this)));
waiting_for_event_ack_ = true;
return false;
}
@@ -167,19 +169,20 @@ class NativeViewportImpl
virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE {
CreateCommandBufferIfNeeded();
AllocationScope scope;
- client()->OnBoundsChanged(bounds);
+ client_->OnBoundsChanged(bounds);
}
virtual void OnDestroyed() OVERRIDE {
command_buffer_.reset();
- client()->OnDestroyed();
+ client_->OnDestroyed();
base::MessageLoop::current()->Quit();
}
private:
+ NativeViewportClient* client_;
gfx::AcceleratedWidget widget_;
scoped_ptr<services::NativeViewport> native_viewport_;
- ScopedCommandBufferClientHandle command_buffer_handle_;
+ ScopedMessagePipeHandle command_buffer_handle_;
scoped_ptr<CommandBufferImpl> command_buffer_;
bool waiting_for_event_ack_;
};
@@ -190,7 +193,7 @@ class NativeViewportImpl
MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application*
CreateNativeViewportService(mojo::shell::Context* context,
- mojo::ScopedShellHandle shell_handle) {
+ mojo::ScopedMessagePipeHandle shell_handle) {
mojo::Application* app = new mojo::Application(shell_handle.Pass());
app->AddServiceConnector(
new mojo::ServiceConnector<mojo::services::NativeViewportImpl,
diff --git a/mojo/services/native_viewport/native_viewport_service.h b/mojo/services/native_viewport/native_viewport_service.h
index e56935c..d2a71eb 100644
--- a/mojo/services/native_viewport/native_viewport_service.h
+++ b/mojo/services/native_viewport/native_viewport_service.h
@@ -6,13 +6,12 @@
#define MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_
#include "base/memory/scoped_vector.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
#include "mojo/public/cpp/shell/application.h"
#include "mojo/services/native_viewport/native_viewport_export.h"
#include "mojo/shell/context.h"
MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application*
CreateNativeViewportService(mojo::shell::Context* context,
- mojo::ScopedShellHandle shell_handle);
+ mojo::ScopedMessagePipeHandle shell_handle);
#endif // MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
index 793255c..886b5fd 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
+#include "mojo/public/cpp/shell/service.h"
#include "mojo/public/interfaces/shell/shell.mojom.h"
#include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
#include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h"
@@ -187,17 +187,16 @@ ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager)
next_change_id_(0),
sync_factory_(this),
init_loop_(NULL) {
- InterfacePipe<services::view_manager::IViewManager, AnyInterface>
- view_manager_pipe;
+ ConnectTo(ViewManagerPrivate(view_manager_).shell(), "mojo:mojo_view_manager",
+ &service_);
+ service_->SetClient(this);
+
AllocationScope scope;
- MessagePipeHandle client_handle = view_manager_pipe.handle_to_peer.get();
- ViewManagerPrivate(view_manager_).shell()->Connect(
- "mojo:mojo_view_manager", view_manager_pipe.handle_to_peer.Pass());
- service_.reset(view_manager_pipe.handle_to_self.Pass(), this);
service_->GetNodeTree(
1,
base::Bind(&ViewManagerSynchronizer::OnRootTreeReceived,
base::Unretained(this)));
+
base::RunLoop loop;
init_loop_ = &loop;
init_loop_->Run();
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h
index 78ae300..7540d1b 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h
@@ -8,7 +8,6 @@
#include "base/basictypes.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
#include "mojo/services/public/cpp/view_manager/view_manager_types.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
@@ -94,7 +93,7 @@ class ViewManagerSynchronizer : public IViewManagerClient {
// construction.
base::RunLoop* init_loop_;
- RemotePtr<IViewManager> service_;
+ IViewManagerPtr service_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer);
};
diff --git a/mojo/services/public/interfaces/view_manager/view_manager.mojom b/mojo/services/public/interfaces/view_manager/view_manager.mojom
index ebc82cb..bbe577b 100644
--- a/mojo/services/public/interfaces/view_manager/view_manager.mojom
+++ b/mojo/services/public/interfaces/view_manager/view_manager.mojom
@@ -21,7 +21,7 @@ struct INode {
// uint16 as the connection id of the originating connection is used.
//
// The root node is identified with a connection id of 0, and value of 1.
-[Peer=IViewManagerClient]
+[Client=IViewManagerClient]
interface IViewManager {
// Creates a new node with the specified id. It is up to the client to ensure
// the id is unique to the connection (the id need not be globally unique).
@@ -60,7 +60,6 @@ interface IViewManager {
uint32 buffer_size);
};
-[Peer=IViewManager]
interface IViewManagerClient {
// Invoked once the connection has been established. |connection_id| is the id
// used to uniquely identify the connection.
diff --git a/mojo/services/view_manager/main.cc b/mojo/services/view_manager/main.cc
index 1fd4528..7754a1e 100644
--- a/mojo/services/view_manager/main.cc
+++ b/mojo/services/view_manager/main.cc
@@ -26,10 +26,10 @@ extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain(
base::MessageLoop loop;
mojo::Application app(shell_handle);
mojo::services::view_manager::RootNodeManager root_node_manager(app.shell());
- app.AddServiceConnector(new mojo::ServiceConnector
- <mojo::services::view_manager::ViewManagerConnection,
- mojo::services::view_manager::RootNodeManager>(
- &root_node_manager));
+ app.AddServiceConnector(
+ new mojo::ServiceConnector<
+ mojo::services::view_manager::ViewManagerConnection,
+ mojo::services::view_manager::RootNodeManager>(&root_node_manager));
loop.Run();
return MOJO_RESULT_OK;
diff --git a/mojo/services/view_manager/root_view_manager.cc b/mojo/services/view_manager/root_view_manager.cc
index 791d1b9..2721fed 100644
--- a/mojo/services/view_manager/root_view_manager.cc
+++ b/mojo/services/view_manager/root_view_manager.cc
@@ -7,7 +7,7 @@
#include "base/auto_reset.h"
#include "mojo/aura/screen_mojo.h"
#include "mojo/aura/window_tree_host_mojo.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
+#include "mojo/public/cpp/shell/service.h"
#include "mojo/public/interfaces/shell/shell.mojom.h"
#include "mojo/services/view_manager/root_node_manager.h"
#include "ui/aura/client/default_capture_client.h"
@@ -53,12 +53,10 @@ RootViewManager::RootViewManager(Shell* shell, RootNodeManager* root_node)
in_setup_(false) {
screen_.reset(ScreenMojo::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
- InterfacePipe<NativeViewport, AnyInterface> pipe;
- mojo::AllocationScope scope;
- shell_->Connect("mojo:mojo_native_viewport_service",
- pipe.handle_to_peer.Pass());
+ NativeViewportPtr viewport;
+ ConnectTo(shell, "mojo:mojo_native_viewport_service", &viewport);
window_tree_host_.reset(new WindowTreeHostMojo(
- pipe.handle_to_self.Pass(),
+ viewport.Pass(),
gfx::Rect(800, 600),
base::Bind(&RootViewManager::OnCompositorCreated,
base::Unretained(this))));
diff --git a/mojo/services/view_manager/view_manager_connection.cc b/mojo/services/view_manager/view_manager_connection.cc
index e1a4650..6b92323 100644
--- a/mojo/services/view_manager/view_manager_connection.cc
+++ b/mojo/services/view_manager/view_manager_connection.cc
@@ -58,7 +58,7 @@ void NodeToINode(Node* node,
} // namespace
-ViewManagerConnection::ViewManagerConnection() : id_(0) {
+ViewManagerConnection::ViewManagerConnection() : client_(NULL), id_(0) {
}
ViewManagerConnection::~ViewManagerConnection() {
@@ -80,15 +80,11 @@ ViewManagerConnection::~ViewManagerConnection() {
context()->RemoveConnection(this);
}
-void ViewManagerConnection::Initialize(
- ServiceConnector<ViewManagerConnection, RootNodeManager>* service_factory,
- ScopedMessagePipeHandle client_handle) {
+void ViewManagerConnection::Initialize() {
DCHECK_EQ(0, id_); // Should only get Initialize() once.
- ServiceConnection<IViewManager, ViewManagerConnection, RootNodeManager>::
- Initialize(service_factory, client_handle.Pass());
id_ = context()->GetAndAdvanceNextConnectionId();
context()->AddConnection(this);
- client()->OnConnectionEstablished(id_);
+ client_->OnConnectionEstablished(id_);
}
Node* ViewManagerConnection::GetNode(const NodeId& id) {
@@ -112,7 +108,7 @@ void ViewManagerConnection::NotifyNodeHierarchyChanged(
const NodeId& new_parent,
const NodeId& old_parent,
TransportChangeId change_id) {
- client()->OnNodeHierarchyChanged(NodeIdToTransportId(node),
+ client_->OnNodeHierarchyChanged(NodeIdToTransportId(node),
NodeIdToTransportId(new_parent),
NodeIdToTransportId(old_parent),
change_id);
@@ -123,7 +119,7 @@ void ViewManagerConnection::NotifyNodeViewReplaced(
const ViewId& new_view_id,
const ViewId& old_view_id,
TransportChangeId change_id) {
- client()->OnNodeViewReplaced(NodeIdToTransportId(node),
+ client_->OnNodeViewReplaced(NodeIdToTransportId(node),
ViewIdToTransportId(new_view_id),
ViewIdToTransportId(old_view_id),
change_id);
@@ -131,7 +127,7 @@ void ViewManagerConnection::NotifyNodeViewReplaced(
void ViewManagerConnection::NotifyNodeDeleted(const NodeId& node,
TransportChangeId change_id) {
- client()->OnNodeDeleted(NodeIdToTransportId(node), change_id);
+ client_->OnNodeDeleted(NodeIdToTransportId(node), change_id);
}
bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source,
@@ -183,6 +179,10 @@ bool ViewManagerConnection::SetViewImpl(const NodeId& node_id,
return true;
}
+void ViewManagerConnection::SetClient(IViewManagerClient* client) {
+ client_ = client;
+}
+
void ViewManagerConnection::CreateNode(
TransportConnectionSpecificNodeId node_id,
const Callback<void(bool)>& callback) {
diff --git a/mojo/services/view_manager/view_manager_connection.h b/mojo/services/view_manager/view_manager_connection.h
index 2dc31d8..51f1642 100644
--- a/mojo/services/view_manager/view_manager_connection.h
+++ b/mojo/services/view_manager/view_manager_connection.h
@@ -33,10 +33,8 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
TransportConnectionId id() const { return id_; }
- // Invoked from Service when connection is established.
- void Initialize(
- ServiceConnector<ViewManagerConnection, RootNodeManager>* service_factory,
- ScopedMessagePipeHandle client_handle);
+ // Invoked when connection is established.
+ void Initialize();
// Returns the Node with the specified id.
Node* GetNode(const NodeId& id);
@@ -77,6 +75,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
TransportChangeId change_id);
// Overridden from IViewManager:
+ virtual void SetClient(IViewManagerClient* client) OVERRIDE;
virtual void CreateNode(TransportConnectionSpecificNodeId node_id,
const Callback<void(bool)>& callback) OVERRIDE;
virtual void DeleteNode(TransportNodeId transport_node_id,
@@ -114,6 +113,8 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
const ViewId& new_view_id,
const ViewId& old_view_id) OVERRIDE;
+ IViewManagerClient* client_;
+
// Id of this connection as assigned by RootNodeManager. Assigned in
// Initialize().
TransportConnectionId id_;
diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc
index 48c520d..6c71f39 100644
--- a/mojo/services/view_manager/view_manager_connection_unittest.cc
+++ b/mojo/services/view_manager/view_manager_connection_unittest.cc
@@ -12,6 +12,7 @@
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/public/cpp/environment/environment.h"
+#include "mojo/public/cpp/shell/service.h"
#include "mojo/services/public/cpp/view_manager/util.h"
#include "mojo/services/public/cpp/view_manager/view_manager_types.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
@@ -252,14 +253,10 @@ class ViewManagerConnectionTest : public testing::Test {
ViewManagerConnectionTest() {}
virtual void SetUp() OVERRIDE {
- AllocationScope allocation_scope;
-
test_helper_.Init();
- InterfacePipe<IViewManager, AnyInterface> pipe;
- test_helper_.shell()->Connect("mojo:mojo_view_manager",
- pipe.handle_to_peer.Pass());
- view_manager_.reset(pipe.handle_to_self.Pass(), &client_);
+ ConnectTo(test_helper_.shell(), "mojo:mojo_view_manager", &view_manager_);
+ view_manager_->SetClient(&client_);
client_.WaitForId();
}
@@ -267,11 +264,8 @@ class ViewManagerConnectionTest : public testing::Test {
protected:
// Creates a second connection to the viewmanager.
void EstablishSecondConnection() {
- AllocationScope allocation_scope;
- InterfacePipe<IViewManager, AnyInterface> pipe;
- test_helper_.shell()->Connect("mojo:mojo_view_manager",
- pipe.handle_to_peer.Pass());
- view_manager2_.reset(pipe.handle_to_self.Pass(), &client2_);
+ ConnectTo(test_helper_.shell(), "mojo:mojo_view_manager", &view_manager2_);
+ view_manager2_->SetClient(&client2_);
client2_.WaitForId();
}
@@ -284,10 +278,10 @@ class ViewManagerConnectionTest : public testing::Test {
shell::ShellTestHelper test_helper_;
ViewManagerClientImpl client_;
- RemotePtr<IViewManager> view_manager_;
+ IViewManagerPtr view_manager_;
ViewManagerClientImpl client2_;
- RemotePtr<IViewManager> view_manager2_;
+ IViewManagerPtr view_manager2_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerConnectionTest);
};