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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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
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 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 view->RemoveObserver(this); 85 view->RemoveObserver(this);
86 delete this; 86 delete this;
87 } 87 }
88 88
89 View* root_; 89 View* root_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(RootObserver); 91 DISALLOW_COPY_AND_ASSIGN(RootObserver);
92 }; 92 };
93 93
94 ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate, 94 ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate,
95 Shell* shell) 95 Shell* shell,
96 : connected_(false), connection_id_(0), next_id_(1), delegate_(delegate) { 96 ScopedMessagePipeHandle handle,
97 bool delete_on_error)
98 : connected_(false),
99 connection_id_(0),
100 next_id_(1),
101 delegate_(delegate),
102 binding_(this, handle.Pass()),
103 service_(binding_.client()),
104 delete_on_error_(delete_on_error) {
97 } 105 }
98 106
99 ViewManagerClientImpl::~ViewManagerClientImpl() { 107 ViewManagerClientImpl::~ViewManagerClientImpl() {
100 std::vector<View*> non_owned; 108 std::vector<View*> non_owned;
101 while (!views_.empty()) { 109 while (!views_.empty()) {
102 IdToViewMap::iterator it = views_.begin(); 110 IdToViewMap::iterator it = views_.begin();
103 if (OwnsView(it->second->id())) { 111 if (OwnsView(it->second->id())) {
104 it->second->Destroy(); 112 it->second->Destroy();
105 } else { 113 } else {
106 non_owned.push_back(it->second); 114 non_owned.push_back(it->second);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ServiceProviderPtr sp; 200 ServiceProviderPtr sp;
193 BindToProxy(new ServiceProviderImpl, &sp); 201 BindToProxy(new ServiceProviderImpl, &sp);
194 Embed(url, view_id, sp.Pass()); 202 Embed(url, view_id, sp.Pass());
195 } 203 }
196 204
197 void ViewManagerClientImpl::Embed( 205 void ViewManagerClientImpl::Embed(
198 const String& url, 206 const String& url,
199 Id view_id, 207 Id view_id,
200 ServiceProviderPtr service_provider) { 208 ServiceProviderPtr service_provider) {
201 DCHECK(connected_); 209 DCHECK(connected_);
202 service_->Embed(url, view_id, service_provider.Pass(), 210 service_->Embed(url, view_id,
203 ActionCompletedCallback()); 211 MakeRequest<ServiceProvider>(service_provider.PassMessagePipe()),
212 ActionCompletedCallback());
204 } 213 }
205 214
206 void ViewManagerClientImpl::AddView(View* view) { 215 void ViewManagerClientImpl::AddView(View* view) {
207 DCHECK(views_.find(view->id()) == views_.end()); 216 DCHECK(views_.find(view->id()) == views_.end());
208 views_[view->id()] = view; 217 views_[view->id()] = view;
209 } 218 }
210 219
211 void ViewManagerClientImpl::RemoveView(Id view_id) { 220 void ViewManagerClientImpl::RemoveView(Id view_id) {
212 IdToViewMap::iterator it = views_.find(view_id); 221 IdToViewMap::iterator it = views_.find(view_id);
213 if (it != views_.end()) 222 if (it != views_.end())
(...skipping 10 matching lines...) Expand all
224 const std::vector<View*>& ViewManagerClientImpl::GetRoots() const { 233 const std::vector<View*>& ViewManagerClientImpl::GetRoots() const {
225 return roots_; 234 return roots_;
226 } 235 }
227 236
228 View* ViewManagerClientImpl::GetViewById(Id id) { 237 View* ViewManagerClientImpl::GetViewById(Id id) {
229 IdToViewMap::const_iterator it = views_.find(id); 238 IdToViewMap::const_iterator it = views_.find(id);
230 return it != views_.end() ? it->second : NULL; 239 return it != views_.end() ? it->second : NULL;
231 } 240 }
232 241
233 //////////////////////////////////////////////////////////////////////////////// 242 ////////////////////////////////////////////////////////////////////////////////
234 // ViewManagerClientImpl, InterfaceImpl overrides:
235
236 void ViewManagerClientImpl::OnConnectionEstablished() {
237 service_ = client();
238 }
239
240 ////////////////////////////////////////////////////////////////////////////////
241 // ViewManagerClientImpl, ViewManagerClient implementation: 243 // ViewManagerClientImpl, ViewManagerClient implementation:
242 244
243 void ViewManagerClientImpl::OnEmbed( 245 void ViewManagerClientImpl::OnEmbed(
244 ConnectionSpecificId connection_id, 246 ConnectionSpecificId connection_id,
245 const String& creator_url, 247 const String& creator_url,
246 ViewDataPtr root_data, 248 ViewDataPtr root_data,
247 InterfaceRequest<ServiceProvider> parent_services, 249 InterfaceRequest<ServiceProvider> parent_services,
248 ScopedMessagePipeHandle window_manager_pipe) { 250 ScopedMessagePipeHandle window_manager_pipe) {
249 if (!connected_) { 251 if (!connected_) {
250 connected_ = true; 252 connected_ = true;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 FOR_EACH_OBSERVER(ViewObserver, 390 FOR_EACH_OBSERVER(ViewObserver,
389 *ViewPrivate(focused).observers(), 391 *ViewPrivate(focused).observers(),
390 OnViewFocusChanged(focused, blurred)); 392 OnViewFocusChanged(focused, blurred));
391 } 393 }
392 } 394 }
393 395
394 void ViewManagerClientImpl::OnActiveWindowChanged(Id old_focused_window, 396 void ViewManagerClientImpl::OnActiveWindowChanged(Id old_focused_window,
395 Id new_focused_window) {} 397 Id new_focused_window) {}
396 398
397 //////////////////////////////////////////////////////////////////////////////// 399 ////////////////////////////////////////////////////////////////////////////////
400 // OnConnectionError, private:
401 void ViewManagerClientImpl::OnConnectionError() {
402 if (delete_on_error_)
403 delete this;
404 }
405
406 ////////////////////////////////////////////////////////////////////////////////
398 // ViewManagerClientImpl, private: 407 // ViewManagerClientImpl, private:
399 408
400 void ViewManagerClientImpl::RemoveRoot(View* root) { 409 void ViewManagerClientImpl::RemoveRoot(View* root) {
401 std::vector<View*>::iterator it = 410 std::vector<View*>::iterator it =
402 std::find(roots_.begin(), roots_.end(), root); 411 std::find(roots_.begin(), roots_.end(), root);
403 if (it != roots_.end()) 412 if (it != roots_.end())
404 roots_.erase(it); 413 roots_.erase(it);
405 } 414 }
406 415
407 void ViewManagerClientImpl::OnActionCompleted(bool success) { 416 void ViewManagerClientImpl::OnActionCompleted(bool success) {
(...skipping 10 matching lines...) Expand all
418 base::Unretained(this)); 427 base::Unretained(this));
419 } 428 }
420 429
421 base::Callback<void(ErrorCode)> 430 base::Callback<void(ErrorCode)>
422 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { 431 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() {
423 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, 432 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode,
424 base::Unretained(this)); 433 base::Unretained(this));
425 } 434 }
426 435
427 } // namespace mojo 436 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698