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

Side by Side Diff: services/view_manager/view_manager_root_connection.cc

Issue 1531403003: Delete the ViewManager and WindowManager services. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-3
Patch Set: rebase Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/view_manager/view_manager_root_connection.h"
6
7 #include "base/trace_event/trace_event.h"
8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "services/view_manager/client_connection.h"
11 #include "services/view_manager/connection_manager.h"
12 #include "services/view_manager/display_manager.h"
13 #include "services/view_manager/view_manager_service_impl.h"
14
15 using mojo::ApplicationConnection;
16 using mojo::InterfaceRequest;
17 using mojo::ViewManagerService;
18 using mojo::WindowManagerInternalClient;
19
20 namespace view_manager {
21
22 ViewManagerRootConnection::ViewManagerRootConnection(
23 mojo::ApplicationImpl* application_impl,
24 ViewManagerRootConnectionObserver* observer)
25 : app_impl_(application_impl), observer_(observer) {}
26
27 ViewManagerRootConnection::~ViewManagerRootConnection() {
28 observer_->OnCloseViewManagerRootConnection(this);
29 }
30
31 bool ViewManagerRootConnection::Init(mojo::ApplicationConnection* connection) {
32 TRACE_EVENT0("view_manager", __func__);
33 if (connection_manager_.get()) {
34 NOTREACHED() << "Only one incoming connection is allowed.";
35 }
36 // |connection| originates from the WindowManager. Let it connect directly
37 // to the ViewManager and WindowManagerInternalClient.
38 connection->AddService<ViewManagerService>(this);
39 connection->AddService<WindowManagerInternalClient>(this);
40 connection->ConnectToService(&wm_internal_);
41 // If no ServiceProvider has been sent, refuse the connection.
42 if (!wm_internal_) {
43 delete this;
44 return false;
45 }
46 wm_internal_.set_connection_error_handler(
47 base::Bind(&ViewManagerRootConnection::OnLostConnectionToWindowManager,
48 base::Unretained(this)));
49
50 scoped_ptr<DefaultDisplayManager> display_manager(new DefaultDisplayManager(
51 app_impl_, connection,
52 base::Bind(&ViewManagerRootConnection::OnLostConnectionToWindowManager,
53 base::Unretained(this))));
54 connection_manager_.reset(
55 new ConnectionManager(this, display_manager.Pass(), wm_internal_.get()));
56 return true;
57 }
58
59 void ViewManagerRootConnection::OnLostConnectionToWindowManager() {
60 delete this;
61 }
62
63 ClientConnection*
64 ViewManagerRootConnection::CreateClientConnectionForEmbedAtView(
65 ConnectionManager* connection_manager,
66 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
67 mojo::ConnectionSpecificId creator_id,
68 const std::string& creator_url,
69 const std::string& url,
70 const ViewId& root_id) {
71 TRACE_EVENT0("view_manager", __func__);
72 mojo::ViewManagerClientPtr client;
73 app_impl_->ConnectToService(url, &client);
74
75 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
76 connection_manager, creator_id, creator_url, url, root_id));
77 return new DefaultClientConnection(service.Pass(), connection_manager,
78 service_request.Pass(), client.Pass());
79 }
80
81 ClientConnection*
82 ViewManagerRootConnection::CreateClientConnectionForEmbedAtView(
83 ConnectionManager* connection_manager,
84 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
85 mojo::ConnectionSpecificId creator_id,
86 const std::string& creator_url,
87 const ViewId& root_id,
88 mojo::ViewManagerClientPtr view_manager_client) {
89 TRACE_EVENT0("view_manager", __func__);
90 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
91 connection_manager, creator_id, creator_url, std::string(), root_id));
92 return new DefaultClientConnection(service.Pass(), connection_manager,
93 service_request.Pass(),
94 view_manager_client.Pass());
95 }
96
97 void ViewManagerRootConnection::Create(
98 ApplicationConnection* connection,
99 InterfaceRequest<ViewManagerService> request) {
100 TRACE_EVENT0("view_manager", __func__);
101 if (connection_manager_->has_window_manager_client_connection()) {
102 VLOG(1) << "ViewManager interface requested more than once.";
103 return;
104 }
105
106 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
107 connection_manager_.get(), kInvalidConnectionId, std::string(),
108 std::string("mojo:window_manager"), RootViewId()));
109 mojo::ViewManagerClientPtr client;
110 wm_internal_client_request_ = GetProxy(&client);
111 scoped_ptr<ClientConnection> client_connection(
112 new DefaultClientConnection(service.Pass(), connection_manager_.get(),
113 request.Pass(), client.Pass()));
114 connection_manager_->SetWindowManagerClientConnection(
115 client_connection.Pass());
116 }
117
118 void ViewManagerRootConnection::Create(
119 ApplicationConnection* connection,
120 InterfaceRequest<WindowManagerInternalClient> request) {
121 TRACE_EVENT0("view_manager", __func__);
122 if (wm_internal_client_binding_.get()) {
123 VLOG(1) << "WindowManagerInternalClient requested more than once.";
124 return;
125 }
126
127 // ConfigureIncomingConnection() must have been called before getting here.
128 DCHECK(connection_manager_.get());
129 wm_internal_client_binding_.reset(
130 new mojo::Binding<WindowManagerInternalClient>(connection_manager_.get(),
131 request.Pass()));
132 wm_internal_client_binding_->set_connection_error_handler(
133 base::Bind(&ViewManagerRootConnection::OnLostConnectionToWindowManager,
134 base::Unretained(this)));
135 wm_internal_->SetViewManagerClient(
136 wm_internal_client_request_.PassMessagePipe());
137 }
138
139 } // namespace view_manager
OLDNEW
« no previous file with comments | « services/view_manager/view_manager_root_connection.h ('k') | services/view_manager/view_manager_service_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698