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

Side by Side Diff: mojo/examples/surfaces_app/child_app.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix network_service_loader Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/examples/png_viewer/png_viewer.cc ('k') | mojo/examples/surfaces_app/child_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/examples/surfaces_app/child_impl.h" 5 #include "mojo/examples/surfaces_app/child_impl.h"
6 #include "mojo/public/cpp/application/application_connection.h" 6 #include "mojo/public/cpp/application/application_connection.h"
7 #include "mojo/public/cpp/application/application_delegate.h" 7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/bindings/string.h" 9 #include "mojo/public/cpp/bindings/string.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace examples { 12 namespace examples {
13 13
14 class ChildApp : public ApplicationDelegate, public ChildImpl::Context { 14 class ChildApp : public ApplicationDelegate, public InterfaceFactory<Child> {
15 public: 15 public:
16 ChildApp() {} 16 ChildApp() {}
17 virtual ~ChildApp() {} 17 virtual ~ChildApp() {}
18 18
19 virtual void Initialize(ApplicationImpl* app) OVERRIDE { app_ = app; } 19 virtual void Initialize(ApplicationImpl* app) OVERRIDE {
20 surfaces_service_connection_ =
21 app->ConnectToApplication("mojo:mojo_surfaces_service");
22 }
20 23
21 // ApplicationDelegate implementation. 24 // ApplicationDelegate implementation.
22 virtual bool ConfigureIncomingConnection( 25 virtual bool ConfigureIncomingConnection(
23 ApplicationConnection* connection) OVERRIDE { 26 ApplicationConnection* connection) OVERRIDE {
24 connection->AddService<ChildImpl, ChildImpl::Context>(this); 27 connection->AddService(this);
25 return true; 28 return true;
26 } 29 }
27 30
28 // ChildImpl::Context implementation. 31 // InterfaceFactory<Child> implementation.
29 virtual ApplicationConnection* ShellConnection( 32 virtual void Create(ApplicationConnection* connection,
30 const mojo::String& application_url) OVERRIDE { 33 InterfaceRequest<Child> request) OVERRIDE {
31 return app_->ConnectToApplication(application_url); 34 BindToRequest(new ChildImpl(surfaces_service_connection_), &request);
32 } 35 }
33 36
34 private: 37 private:
35 ApplicationImpl* app_; 38 ApplicationConnection* surfaces_service_connection_;
36 39
37 DISALLOW_COPY_AND_ASSIGN(ChildApp); 40 DISALLOW_COPY_AND_ASSIGN(ChildApp);
38 }; 41 };
39 42
40 } // namespace examples 43 } // namespace examples
41 44
42 // static 45 // static
43 ApplicationDelegate* ApplicationDelegate::Create() { 46 ApplicationDelegate* ApplicationDelegate::Create() {
44 return new examples::ChildApp(); 47 return new examples::ChildApp();
45 } 48 }
46 49
47 } // namespace mojo 50 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/png_viewer/png_viewer.cc ('k') | mojo/examples/surfaces_app/child_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698