summaryrefslogtreecommitdiffstats
path: root/mojo/services
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 05:26:15 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 05:26:15 +0000
commit8b50cb02853c09f910b00bb420d6c68725fd70ee (patch)
treec58fc073244aaf3e4c27da410638917f6b813cf8 /mojo/services
parent3b49a30c927958d6a09ad7a7ba3f595f188ceaa8 (diff)
downloadchromium_src-8b50cb02853c09f910b00bb420d6c68725fd70ee.zip
chromium_src-8b50cb02853c09f910b00bb420d6c68725fd70ee.tar.gz
chromium_src-8b50cb02853c09f910b00bb420d6c68725fd70ee.tar.bz2
Revert 265180 "Start of server side of viewmanager"
Don't know how this got past the CQ (davemoore renamed Service and ServiceFactory on Friday, r264879). > Start of server side of viewmanager > > I'll figure out tests then notifications next. > > BUG=365012 > TEST=none > R=ben@chromium.org > > Review URL: https://codereview.chromium.org/245663002 TBR=sky@chromium.org Review URL: https://codereview.chromium.org/246753002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/services')
-rw-r--r--mojo/services/public/interfaces/view_manager/view_manager.mojom37
-rw-r--r--mojo/services/view_manager/DEPS6
-rw-r--r--mojo/services/view_manager/root_view_manager.cc64
-rw-r--r--mojo/services/view_manager/root_view_manager.h65
-rw-r--r--mojo/services/view_manager/view.cc41
-rw-r--r--mojo/services/view_manager/view.h38
-rw-r--r--mojo/services/view_manager/view_manager.cc32
-rw-r--r--mojo/services/view_manager/view_manager_connection.cc85
-rw-r--r--mojo/services/view_manager/view_manager_connection.h67
9 files changed, 0 insertions, 435 deletions
diff --git a/mojo/services/public/interfaces/view_manager/view_manager.mojom b/mojo/services/public/interfaces/view_manager/view_manager.mojom
deleted file mode 100644
index 45a7e69..0000000
--- a/mojo/services/public/interfaces/view_manager/view_manager.mojom
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-module mojo.services.view_manager {
-
-// Each View is identified by the following pair. The |manager_id| is assigned
-// by the server and uniquely identifies the ViewManager. A value of 0 can be
-// used to indicate 'this' manager. The |view_id| is assigned by the client.
-// Non-negative values may be used. Server uses negative to identify special
-// values. For example, -1 is the root.
-struct ViewId {
- int32 manager_id;
- int32 view_id;
-};
-
-[Peer=ViewManagerClient]
-interface ViewManager {
- // Creates a new view 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).
- CreateView(int32 view_id) => (bool success);
-
- // Reparents a view.
- AddView(ViewId parent, ViewId child) => (bool success);
-
- // Removes a view from its current parent.
- RemoveFromParent(ViewId view) => (bool success);
-};
-
-[Peer=ViewManager]
-interface ViewManagerClient {
- // Invoked once the connection has been established. |manager_id| is the id
- // used to uniquely identify the ViewManager.
- OnConnectionEstablished(int32 manager_id);
-};
-
-}
diff --git a/mojo/services/view_manager/DEPS b/mojo/services/view_manager/DEPS
deleted file mode 100644
index 05af088..0000000
--- a/mojo/services/view_manager/DEPS
+++ /dev/null
@@ -1,6 +0,0 @@
-include_rules = [
- "+mojo/services",
- "+ui/aura",
- "+ui/events",
- "+ui/gfx",
-]
diff --git a/mojo/services/view_manager/root_view_manager.cc b/mojo/services/view_manager/root_view_manager.cc
deleted file mode 100644
index d791cb3..0000000
--- a/mojo/services/view_manager/root_view_manager.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/view_manager/root_view_manager.h"
-
-#include "base/logging.h"
-#include "mojo/services/view_manager/view_manager_connection.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-namespace {
-
-// Identifies the root of the view hierarchy.
-const int32_t kRootId = -1;
-
-} // namespace
-
-RootViewManager::RootViewManager()
- : next_connection_id_(1),
- root_(kRootId) {
-}
-
-RootViewManager::~RootViewManager() {
-}
-
-int32_t RootViewManager::GetAndAdvanceNextConnectionId() {
- return next_connection_id_++;
-}
-
-void RootViewManager::AddConnection(ViewManagerConnection* connection) {
- DCHECK_EQ(0u, connection_map_.count(connection->id()));
- connection_map_[connection->id()] = connection;
-}
-
-void RootViewManager::RemoveConnection(ViewManagerConnection* connection) {
- connection_map_.erase(connection->id());
-}
-
-View* RootViewManager::GetView(int32_t manager_id, int32_t view_id) {
- if (view_id == kRootId)
- return &root_;
- ConnectionMap::iterator i = connection_map_.find(manager_id);
- return i == connection_map_.end() ? NULL : i->second->GetView(view_id);
-}
-
-void RootViewManager::OnCreated() {
-}
-
-void RootViewManager::OnDestroyed() {
-}
-
-void RootViewManager::OnBoundsChanged(const Rect& bounds) {
-}
-
-void RootViewManager::OnEvent(const Event& event,
- const mojo::Callback<void()>& callback) {
- callback.Run();
-}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/view_manager/root_view_manager.h b/mojo/services/view_manager/root_view_manager.h
deleted file mode 100644
index 65376ce..0000000
--- a/mojo/services/view_manager/root_view_manager.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_ROOT_VIEW_MANAGER_H_
-#define MOJO_SERVICES_VIEW_MANAGER_ROOT_VIEW_MANAGER_H_
-
-#include <map>
-
-#include "base/basictypes.h"
-#include "mojo/services/native_viewport/native_viewport.mojom.h"
-#include "mojo/services/view_manager/view.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class View;
-class ViewId;
-class ViewManagerConnection;
-
-// RootViewManager is responsible for managing the set of ViewManagerConnections
-// as well as providing the root of the View hierarchy.
-class RootViewManager : public NativeViewportClient {
- public:
- RootViewManager();
- virtual ~RootViewManager();
-
- // Returns the id for the next view manager.
- int32_t GetAndAdvanceNextConnectionId();
-
- void AddConnection(ViewManagerConnection* connection);
- void RemoveConnection(ViewManagerConnection* connection);
-
- // Returns the View identified by the specified pair, or NULL if there isn't
- // one.
- View* GetView(int32_t manager_id, int32_t view_id);
-
- private:
- typedef std::map<int32_t, ViewManagerConnection*> ConnectionMap;
-
- // Overridden from NativeViewportClient:
- virtual void OnCreated() OVERRIDE;
- virtual void OnDestroyed() OVERRIDE;
- virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE;
- virtual void OnEvent(const Event& event,
- const mojo::Callback<void()>& callback) OVERRIDE;
-
- // ID to use for next ViewManagerConnection.
- int32_t next_connection_id_;
-
- // Set of ViewManagerConnections.
- ConnectionMap connection_map_;
-
- // Root of Views that are displayed.
- View root_;
-
- DISALLOW_COPY_AND_ASSIGN(RootViewManager);
-};
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_VIEW_MANAGER_H_
diff --git a/mojo/services/view_manager/view.cc b/mojo/services/view_manager/view.cc
deleted file mode 100644
index 6215854..0000000
--- a/mojo/services/view_manager/view.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/view_manager/view.h"
-
-#include "ui/aura/window_property.h"
-
-DECLARE_WINDOW_PROPERTY_TYPE(mojo::services::view_manager::View*);
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-DEFINE_WINDOW_PROPERTY_KEY(View*, kViewKey, NULL);
-
-// TODO(sky): figure out window delegate.
-View::View(int32_t id) : id_(id), window_(NULL) {
- window_.set_owned_by_parent(false);
-}
-
-View::~View() {
-}
-
-View* View::GetParent() {
- if (!window_.parent())
- return NULL;
- return window_.parent()->GetProperty(kViewKey);
-}
-
-void View::Add(View* child) {
- window_.AddChild(&child->window_);
-}
-
-void View::Remove(View* child) {
- window_.RemoveChild(&child->window_);
-}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/view_manager/view.h b/mojo/services/view_manager/view.h
deleted file mode 100644
index 1815f7f..0000000
--- a/mojo/services/view_manager/view.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_H_
-#define MOJO_SERVICES_VIEW_MANAGER_VIEW_H_
-
-#include "base/logging.h"
-#include "ui/aura/window.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class View {
- public:
- View(int32_t view_id);
- ~View();
-
- int32 id() const { return id_; }
-
- void Add(View* child);
- void Remove(View* child);
-
- View* GetParent();
-
- private:
- const int32_t id_;
- aura::Window window_;
-
- DISALLOW_COPY_AND_ASSIGN(View);
-};
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_H_
diff --git a/mojo/services/view_manager/view_manager.cc b/mojo/services/view_manager/view_manager.cc
deleted file mode 100644
index 80835da..0000000
--- a/mojo/services/view_manager/view_manager.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/message_loop/message_loop.h"
-#include "mojo/public/cpp/shell/application.h"
-#include "mojo/services/view_manager/root_view_manager.h"
-#include "mojo/services/view_manager/view_manager_connection.h"
-
-#if defined(WIN32)
-#if !defined(CDECL)
-#define CDECL __cdecl)
-#endif
-#define VIEW_MANAGER_EXPORT __declspec(dllexport)
-#else
-#define CDECL
-#define VIEW_MANAGER_EXPORT __attribute__((visibility("default")))
-#endif
-
-extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain(
- MojoHandle shell_handle) {
- base::MessageLoop loop;
- mojo::Application app(shell_handle);
- mojo::services::view_manager::RootViewManager root_view_manager;
- app.AddServiceFactory(new mojo::ServiceFactory
- <mojo::services::view_manager::ViewManagerConnection,
- mojo::services::view_manager::RootViewManager>(
- &root_view_manager));
- loop.Run();
-
- return MOJO_RESULT_OK;
-}
diff --git a/mojo/services/view_manager/view_manager_connection.cc b/mojo/services/view_manager/view_manager_connection.cc
deleted file mode 100644
index d714b7a..0000000
--- a/mojo/services/view_manager/view_manager_connection.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/view_manager/view_manager_connection.h"
-
-#include "base/stl_util.h"
-#include "mojo/services/view_manager/root_view_manager.h"
-#include "mojo/services/view_manager/view.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-ViewManagerConnection::ViewManagerConnection() : id_(0) {
-}
-
-ViewManagerConnection::~ViewManagerConnection() {
- STLDeleteContainerPairSecondPointers(view_map_.begin(), view_map_.end());
- context()->RemoveConnection(this);
-}
-
-void ViewManagerConnection::Initialize(
- ServiceFactory<ViewManagerConnection, RootViewManager>* service_factory,
- ScopedMessagePipeHandle client_handle) {
- DCHECK_EQ(0, id_); // Should only get Initialize() once.
- Service<ViewManager, ViewManagerConnection, RootViewManager>::Initialize(
- service_factory, client_handle.Pass());
- context()->AddConnection(this);
- id_ = context()->GetAndAdvanceNextConnectionId();
- client()->OnConnectionEstablished(id_);
-}
-
-View* ViewManagerConnection::GetView(int32_t id) {
- ViewMap::iterator i = view_map_.find(id);
- return i == view_map_.end() ? NULL : i->second;
-}
-
-View* ViewManagerConnection::GetViewById(const ViewId& view_id) {
- const int32_t manager_id =
- view_id.manager_id() == 0 ? id_ : view_id.manager_id();
- return context()->GetView(manager_id, view_id.view_id());
-}
-
-void ViewManagerConnection::CreateView(
- int32_t view_id,
- const mojo::Callback<void(bool)>& callback) {
- // Negative values are reserved.
- if (view_map_.find(view_id) != view_map_.end() || view_id < 0) {
- callback.Run(false);
- return;
- }
- view_map_[view_id] = new View(view_id);
- callback.Run(true);
-}
-
-void ViewManagerConnection::AddView(
- const ViewId& parent_id,
- const ViewId& child_id,
- const mojo::Callback<void(bool)>& callback) {
- View* parent_view = GetViewById(parent_id);
- View* child_view = GetViewById(child_id);
- bool success = false;
- if (parent_view && child_view && parent_view != child_view) {
- parent_view->Add(child_view);
- success = true;
- }
- callback.Run(success);
-}
-
-void ViewManagerConnection::RemoveFromParent(
- const ViewId& view_id,
- const mojo::Callback<void(bool)>& callback) {
- View* view = GetViewById(view_id);
- bool success = false;
- if (view && view->GetParent()) {
- view->GetParent()->Add(view);
- success = true;
- }
- callback.Run(success);
-}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/view_manager/view_manager_connection.h b/mojo/services/view_manager/view_manager_connection.h
deleted file mode 100644
index b028ec6..0000000
--- a/mojo/services/view_manager/view_manager_connection.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_
-#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_
-
-#include <set>
-
-#include "base/basictypes.h"
-#include "mojo/public/cpp/shell/service.h"
-#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class RootViewManager;
-class View;
-
-// Manages a connection from the client.
-class ViewManagerConnection : public Service<ViewManager, ViewManagerConnection,
- RootViewManager> {
- public:
- ViewManagerConnection();
- virtual ~ViewManagerConnection();
-
- int32_t id() const { return id_; }
-
- // Invoked from Service when connection is established.
- void Initialize(
- ServiceFactory<ViewManagerConnection, RootViewManager>* service_factory,
- ScopedMessagePipeHandle client_handle);
-
- // Returns the View by id.
- View* GetView(int32_t id);
-
- private:
- typedef std::map<int32_t, View*> ViewMap;
-
- // Returns the View by ViewId.
- View* GetViewById(const ViewId& view_id);
-
- // Overridden from ViewManager:
- virtual void CreateView(int32_t view_id,
- const mojo::Callback<void(bool)>& callback) OVERRIDE;
- virtual void AddView(const ViewId& parent_id,
- const ViewId& child_id,
- const mojo::Callback<void(bool)>& callback) OVERRIDE;
- virtual void RemoveFromParent(
- const ViewId& view_id,
- const mojo::Callback<void(bool)>& callback) OVERRIDE;
-
- // Id of this connection as assigned by RootViewManager. Assigned in
- // Initialize().
- int32_t id_;
-
- ViewMap view_map_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection);
-};
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_