Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/view_manager/connection_manager.h" | 5 #include "mojo/services/view_manager/connection_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/public/cpp/application/application_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
| 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" | 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
| 11 #include "mojo/services/view_manager/view_manager_service_impl.h" | 11 #include "mojo/services/view_manager/view_manager_service_impl.h" |
| 12 #include "ui/aura/env.h" | |
| 13 | 12 |
| 14 namespace mojo { | 13 namespace mojo { |
| 15 namespace service { | 14 namespace service { |
| 16 | 15 |
| 17 ConnectionManager::ScopedChange::ScopedChange( | 16 ConnectionManager::ScopedChange::ScopedChange( |
| 18 ViewManagerServiceImpl* connection, | 17 ViewManagerServiceImpl* connection, |
| 19 ConnectionManager* connection_manager, | 18 ConnectionManager* connection_manager, |
| 20 bool is_delete_view) | 19 bool is_delete_view) |
| 21 : connection_manager_(connection_manager), | 20 : connection_manager_(connection_manager), |
| 22 connection_id_(connection->id()), | 21 connection_id_(connection->id()), |
| 23 is_delete_view_(is_delete_view) { | 22 is_delete_view_(is_delete_view) { |
| 24 connection_manager_->PrepareForChange(this); | 23 connection_manager_->PrepareForChange(this); |
| 25 } | 24 } |
| 26 | 25 |
| 27 ConnectionManager::ScopedChange::~ScopedChange() { | 26 ConnectionManager::ScopedChange::~ScopedChange() { |
| 28 connection_manager_->FinishChange(); | 27 connection_manager_->FinishChange(); |
| 29 } | 28 } |
| 30 | 29 |
| 31 ConnectionManager::Context::Context() { | |
| 32 // Pass in false as native viewport creates the PlatformEventSource. | |
| 33 aura::Env::CreateInstance(false); | |
| 34 } | |
| 35 | |
| 36 ConnectionManager::Context::~Context() { | |
| 37 aura::Env::DeleteInstance(); | |
| 38 } | |
| 39 | |
| 40 ConnectionManager::ConnectionManager( | 30 ConnectionManager::ConnectionManager( |
| 41 ApplicationConnection* app_connection, | 31 ApplicationConnection* app_connection, |
| 42 DisplayManagerDelegate* display_manager_delegate, | |
| 43 const Callback<void()>& native_viewport_closed_callback) | 32 const Callback<void()>& native_viewport_closed_callback) |
| 44 : app_connection_(app_connection), | 33 : app_connection_(app_connection), |
| 45 next_connection_id_(1), | 34 next_connection_id_(1), |
| 46 display_manager_(app_connection, | 35 display_manager_(app_connection, |
| 47 this, | 36 this, |
| 48 display_manager_delegate, | |
| 49 native_viewport_closed_callback), | 37 native_viewport_closed_callback), |
| 50 root_(new ServerView(this, RootViewId())), | 38 root_(new ServerView(this, RootViewId())), |
| 51 current_change_(NULL) { | 39 current_change_(NULL) { |
| 40 root_->SetBounds(gfx::Rect(800, 600)); | |
|
sky
2014/09/03 22:45:28
Can we move this to the native viewport service? T
jamesr
2014/09/03 23:32:47
The way NVS works today is the client picks the si
| |
| 52 } | 41 } |
| 53 | 42 |
| 54 ConnectionManager::~ConnectionManager() { | 43 ConnectionManager::~ConnectionManager() { |
| 55 while (!connections_created_by_connect_.empty()) | 44 while (!connections_created_by_connect_.empty()) |
| 56 delete *(connections_created_by_connect_.begin()); | 45 delete *(connections_created_by_connect_.begin()); |
| 57 // All the connections should have been destroyed. | 46 // All the connections should have been destroyed. |
| 58 DCHECK(connection_map_.empty()); | 47 DCHECK(connection_map_.empty()); |
| 59 root_.reset(); | 48 root_.reset(); |
| 60 } | 49 } |
| 61 | 50 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 const gfx::Rect& new_bounds) { | 251 const gfx::Rect& new_bounds) { |
| 263 ProcessViewBoundsChanged(view, old_bounds, new_bounds); | 252 ProcessViewBoundsChanged(view, old_bounds, new_bounds); |
| 264 if (!view->parent()) | 253 if (!view->parent()) |
| 265 return; | 254 return; |
| 266 | 255 |
| 267 // TODO(sky): optimize this. | 256 // TODO(sky): optimize this. |
| 268 display_manager_.SchedulePaint(view->parent(), old_bounds); | 257 display_manager_.SchedulePaint(view->parent(), old_bounds); |
| 269 display_manager_.SchedulePaint(view->parent(), new_bounds); | 258 display_manager_.SchedulePaint(view->parent(), new_bounds); |
| 270 } | 259 } |
| 271 | 260 |
| 272 void ConnectionManager::OnViewBitmapChanged(const ServerView* view) { | 261 void ConnectionManager::OnViewSurfaceChanged(const ServerView* view) { |
| 273 display_manager_.SchedulePaint(view, gfx::Rect(view->bounds().size())); | 262 display_manager_.SchedulePaint(view, gfx::Rect(view->bounds().size())); |
| 274 } | 263 } |
| 275 | 264 |
| 276 } // namespace service | 265 } // namespace service |
| 277 } // namespace mojo | 266 } // namespace mojo |
| OLD | NEW |