| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
| 10 #include "mojo/public/cpp/application/application_test_base.h" | 10 #include "mojo/public/cpp/application/application_test_base.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using mojo::ERROR_CODE_NONE; | 22 using mojo::ERROR_CODE_NONE; |
| 23 using mojo::ErrorCode; | 23 using mojo::ErrorCode; |
| 24 using mojo::EventPtr; | 24 using mojo::EventPtr; |
| 25 using mojo::Id; | 25 using mojo::Id; |
| 26 using mojo::InterfaceRequest; | 26 using mojo::InterfaceRequest; |
| 27 using mojo::ORDER_DIRECTION_ABOVE; | 27 using mojo::ORDER_DIRECTION_ABOVE; |
| 28 using mojo::ORDER_DIRECTION_BELOW; | 28 using mojo::ORDER_DIRECTION_BELOW; |
| 29 using mojo::OrderDirection; | 29 using mojo::OrderDirection; |
| 30 using mojo::RectPtr; | 30 using mojo::RectPtr; |
| 31 using mojo::ServiceProvider; | 31 using mojo::ServiceProvider; |
| 32 using mojo::ServiceProviderPtr; |
| 32 using mojo::String; | 33 using mojo::String; |
| 33 using mojo::ViewDataPtr; | 34 using mojo::ViewDataPtr; |
| 34 using mojo::ViewManagerClient; | 35 using mojo::ViewManagerClient; |
| 35 using mojo::ViewManagerService; | 36 using mojo::ViewManagerService; |
| 36 | 37 |
| 37 namespace view_manager { | 38 namespace view_manager { |
| 38 | 39 |
| 39 // Creates an id used for transport from the specified parameters. | 40 // Creates an id used for transport from the specified parameters. |
| 40 Id BuildViewId(ConnectionSpecificId connection_id, | 41 Id BuildViewId(ConnectionSpecificId connection_id, |
| 41 ConnectionSpecificId view_id) { | 42 ConnectionSpecificId view_id) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 vm->CreateView(view_id, | 76 vm->CreateView(view_id, |
| 76 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); | 77 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); |
| 77 run_loop.Run(); | 78 run_loop.Run(); |
| 78 return result == ERROR_CODE_NONE; | 79 return result == ERROR_CODE_NONE; |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool Embed(ViewManagerService* vm, Id root_id) { | 82 bool Embed(ViewManagerService* vm, Id root_id) { |
| 82 bool result = false; | 83 bool result = false; |
| 83 base::RunLoop run_loop; | 84 base::RunLoop run_loop; |
| 84 { | 85 { |
| 85 mojo::ServiceProviderPtr sp; | 86 vm->Embed("mojo:view_manager_service_apptests", root_id, nullptr, nullptr, |
| 86 vm->Embed("mojo:view_manager_service_apptests", root_id, | |
| 87 GetProxy(&sp), | |
| 88 base::Bind(&BoolResultCallback, &run_loop, &result)); | 87 base::Bind(&BoolResultCallback, &run_loop, &result)); |
| 89 } | 88 } |
| 90 run_loop.Run(); | 89 run_loop.Run(); |
| 91 return result; | 90 return result; |
| 92 } | 91 } |
| 93 | 92 |
| 94 ErrorCode CreateViewWithErrorCode(ViewManagerService* vm, Id view_id) { | 93 ErrorCode CreateViewWithErrorCode(ViewManagerService* vm, Id view_id) { |
| 95 ErrorCode result = ERROR_CODE_NONE; | 94 ErrorCode result = ERROR_CODE_NONE; |
| 96 base::RunLoop run_loop; | 95 base::RunLoop run_loop; |
| 97 vm->CreateView(view_id, | 96 vm->CreateView(view_id, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 wait_state_->change_count == tracker_.changes()->size()) { | 258 wait_state_->change_count == tracker_.changes()->size()) { |
| 260 wait_state_->run_loop.Quit(); | 259 wait_state_->run_loop.Quit(); |
| 261 } | 260 } |
| 262 } | 261 } |
| 263 | 262 |
| 264 // ViewManagerClient: | 263 // ViewManagerClient: |
| 265 void OnEmbed(ConnectionSpecificId connection_id, | 264 void OnEmbed(ConnectionSpecificId connection_id, |
| 266 const String& creator_url, | 265 const String& creator_url, |
| 267 ViewDataPtr root, | 266 ViewDataPtr root, |
| 268 InterfaceRequest<ServiceProvider> services, | 267 InterfaceRequest<ServiceProvider> services, |
| 268 ServiceProviderPtr exposed_services, |
| 269 mojo::ScopedMessagePipeHandle window_manager_pipe) override { | 269 mojo::ScopedMessagePipeHandle window_manager_pipe) override { |
| 270 tracker()->OnEmbed(connection_id, creator_url, root.Pass()); | 270 tracker()->OnEmbed(connection_id, creator_url, root.Pass()); |
| 271 got_embed_ = true; | 271 got_embed_ = true; |
| 272 if (embed_run_loop_) | 272 if (embed_run_loop_) |
| 273 embed_run_loop_->Quit(); | 273 embed_run_loop_->Quit(); |
| 274 } | 274 } |
| 275 void OnEmbeddedAppDisconnected(Id view_id) override { | 275 void OnEmbeddedAppDisconnected(Id view_id) override { |
| 276 tracker()->OnEmbeddedAppDisconnected(view_id); | 276 tracker()->OnEmbeddedAppDisconnected(view_id); |
| 277 } | 277 } |
| 278 void OnViewBoundsChanged(Id view_id, | 278 void OnViewBoundsChanged(Id view_id, |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 // TODO(sky): need to better track changes to initial connection. For example, | 1414 // TODO(sky): need to better track changes to initial connection. For example, |
| 1415 // that SetBounsdViews/AddView and the like don't result in messages to the | 1415 // that SetBounsdViews/AddView and the like don't result in messages to the |
| 1416 // originating connection. | 1416 // originating connection. |
| 1417 | 1417 |
| 1418 // TODO(sky): make sure coverage of what was | 1418 // TODO(sky): make sure coverage of what was |
| 1419 // ViewManagerTest.SecondEmbedRoot_InitService and | 1419 // ViewManagerTest.SecondEmbedRoot_InitService and |
| 1420 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager | 1420 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager |
| 1421 // tests. | 1421 // tests. |
| 1422 | 1422 |
| 1423 } // namespace view_manager | 1423 } // namespace view_manager |
| OLD | NEW |