| 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/surfaces/surfaces_service_application.h" | 5 #include "mojo/services/surfaces/surfaces_service_application.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/display.h" | 7 #include "cc/surfaces/display.h" |
| 8 | 8 |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_runner_chromium.h" | 10 #include "mojo/public/cpp/application/application_runner_chromium.h" |
| 11 #include "mojo/services/surfaces/surfaces_service_impl.h" |
| 11 | 12 |
| 12 namespace mojo { | 13 namespace mojo { |
| 13 | 14 |
| 14 SurfacesServiceApplication::SurfacesServiceApplication() | 15 SurfacesServiceApplication::SurfacesServiceApplication() |
| 15 : next_id_namespace_(1u), display_(NULL) { | 16 : next_id_namespace_(1u), display_(NULL) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 SurfacesServiceApplication::~SurfacesServiceApplication() { | 19 SurfacesServiceApplication::~SurfacesServiceApplication() { |
| 19 } | 20 } |
| 20 | 21 |
| 21 bool SurfacesServiceApplication::ConfigureIncomingConnection( | 22 bool SurfacesServiceApplication::ConfigureIncomingConnection( |
| 22 ApplicationConnection* connection) { | 23 ApplicationConnection* connection) { |
| 23 connection->AddService(this); | 24 connection->AddService(this); |
| 24 return true; | 25 return true; |
| 25 } | 26 } |
| 26 | 27 |
| 27 void SurfacesServiceApplication::Create(ApplicationConnection* connection, | 28 void SurfacesServiceApplication::Create( |
| 28 InterfaceRequest<Surface> request) { | 29 ApplicationConnection* connection, |
| 29 BindToRequest(new SurfacesImpl(&manager_, next_id_namespace_++, this), | 30 InterfaceRequest<SurfacesService> request) { |
| 31 BindToRequest(new SurfacesServiceImpl(&manager_, &next_id_namespace_, this), |
| 30 &request); | 32 &request); |
| 31 } | 33 } |
| 32 | 34 |
| 33 void SurfacesServiceApplication::FrameSubmitted() { | 35 void SurfacesServiceApplication::FrameSubmitted() { |
| 34 if (display_) | 36 if (display_) |
| 35 display_->Draw(); | 37 display_->Draw(); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void SurfacesServiceApplication::SetDisplay(cc::Display* display) { | 40 void SurfacesServiceApplication::SetDisplay(cc::Display* display) { |
| 39 display_ = display; | 41 display_ = display; |
| 40 } | 42 } |
| 41 | 43 |
| 42 } // namespace mojo | 44 } // namespace mojo |
| 43 | 45 |
| 44 MojoResult MojoMain(MojoHandle shell_handle) { | 46 MojoResult MojoMain(MojoHandle shell_handle) { |
| 45 mojo::ApplicationRunnerChromium runner(new mojo::SurfacesServiceApplication); | 47 mojo::ApplicationRunnerChromium runner(new mojo::SurfacesServiceApplication); |
| 46 return runner.Run(shell_handle); | 48 return runner.Run(shell_handle); |
| 47 } | 49 } |
| OLD | NEW |