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

Side by Side Diff: services/fake_surfaces/fake_surfaces_service_application.cc

Issue 882083003: Remove mojo.SurfacesService interface in favor of mojo.Surface directly (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
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 "services/fake_surfaces/fake_surfaces_service_application.h" 5 #include "services/fake_surfaces/fake_surfaces_service_application.h"
6 6
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/common/tracing_impl.h" 8 #include "mojo/common/tracing_impl.h"
9 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 mojo::SizePtr size, 53 mojo::SizePtr size,
54 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request) 54 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request)
55 override {} 55 override {}
56 56
57 private: 57 private:
58 mojo::StrongBinding<mojo::Surface> binding_; 58 mojo::StrongBinding<mojo::Surface> binding_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(FakeSurfaceImpl); 60 DISALLOW_COPY_AND_ASSIGN(FakeSurfaceImpl);
61 }; 61 };
62 62
63 class FakeSurfacesServiceImpl : public mojo::SurfacesService {
64 public:
65 FakeSurfacesServiceImpl(uint32_t* id_namespace,
66 InterfaceRequest<mojo::SurfacesService> request)
67 : binding_(this, request.Pass()), next_id_namespace_(id_namespace) {}
68 ~FakeSurfacesServiceImpl() override {}
69
70 // mojo::SurfacesService implementation.
71 void CreateSurfaceConnection(
72 const mojo::Callback<void(mojo::SurfacePtr, uint32_t)>& callback)
73 override {
74 mojo::SurfacePtr surface;
75 uint32_t id_namespace = (*next_id_namespace_)++;
76 new FakeSurfaceImpl(id_namespace, GetProxy(&surface));
77 callback.Run(surface.Pass(), id_namespace);
78 }
79
80 private:
81 mojo::StrongBinding<mojo::SurfacesService> binding_;
82 uint32_t* next_id_namespace_;
83
84 DISALLOW_COPY_AND_ASSIGN(FakeSurfacesServiceImpl);
85 };
86
87 FakeSurfacesServiceApplication::FakeSurfacesServiceApplication() 63 FakeSurfacesServiceApplication::FakeSurfacesServiceApplication()
88 : next_id_namespace_(1u) { 64 : next_id_namespace_(1u) {
89 } 65 }
90 66
91 FakeSurfacesServiceApplication::~FakeSurfacesServiceApplication() { 67 FakeSurfacesServiceApplication::~FakeSurfacesServiceApplication() {
92 } 68 }
93 69
94 void FakeSurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) { 70 void FakeSurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
95 mojo::TracingImpl::Create(app); 71 mojo::TracingImpl::Create(app);
96 } 72 }
97 73
98 bool FakeSurfacesServiceApplication::ConfigureIncomingConnection( 74 bool FakeSurfacesServiceApplication::ConfigureIncomingConnection(
99 mojo::ApplicationConnection* connection) { 75 mojo::ApplicationConnection* connection) {
100 connection->AddService<mojo::SurfacesService>(this); 76 connection->AddService(this);
101 connection->AddService<mojo::Surface>(this);
102 return true; 77 return true;
103 } 78 }
104 79
105 void FakeSurfacesServiceApplication::Create( 80 void FakeSurfacesServiceApplication::Create(
106 mojo::ApplicationConnection* connection, 81 mojo::ApplicationConnection* connection,
107 InterfaceRequest<mojo::SurfacesService> request) {
108 new FakeSurfacesServiceImpl(&next_id_namespace_, request.Pass());
109 }
110
111 void FakeSurfacesServiceApplication::Create(
112 mojo::ApplicationConnection* connection,
113 InterfaceRequest<mojo::Surface> request) { 82 InterfaceRequest<mojo::Surface> request) {
114 new FakeSurfaceImpl(next_id_namespace_++, request.Pass()); 83 new FakeSurfaceImpl(next_id_namespace_++, request.Pass());
115 } 84 }
116 85
117 } // namespace fake_surfaces 86 } // namespace fake_surfaces
118 87
119 MojoResult MojoMain(MojoHandle shell_handle) { 88 MojoResult MojoMain(MojoHandle shell_handle) {
120 mojo::ApplicationRunnerChromium runner( 89 mojo::ApplicationRunnerChromium runner(
121 new fake_surfaces::FakeSurfacesServiceApplication); 90 new fake_surfaces::FakeSurfacesServiceApplication);
122 return runner.Run(shell_handle); 91 return runner.Run(shell_handle);
123 } 92 }
OLDNEW
« no previous file with comments | « services/fake_surfaces/fake_surfaces_service_application.h ('k') | services/native_viewport/viewport_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698