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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "mojo/public/c/system/main.h" | 7 #include "mojo/public/c/system/main.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_runner.h" | 10 #include "mojo/public/cpp/application/application_runner.h" |
11 #include "mojo/public/cpp/application/interface_factory_impl.h" | 11 #include "mojo/public/cpp/application/interface_factory_impl.h" |
12 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | 12 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace examples { | 15 namespace examples { |
16 | 16 |
17 class PrintBodyApplication : public InterfaceImpl<Application> { | 17 class PrintBodyApplication : public InterfaceImpl<Application> { |
18 public: | 18 public: |
19 PrintBodyApplication(ShellPtr shell, ScopedDataPipeConsumerHandle body) | 19 PrintBodyApplication(ShellPtr shell, ScopedDataPipeConsumerHandle body) |
20 : shell_(shell.Pass()), body_(body.Pass()) { | 20 : shell_(shell.Pass()), body_(body.Pass()) { |
21 shell_.set_client(this); | 21 shell_.set_client(this); |
22 } | 22 } |
23 | 23 |
24 virtual void Initialize(Array<String> args) override {} | 24 virtual void Initialize(Array<String> args) override {} |
25 | 25 |
26 virtual void AcceptConnection(const String& requestor_url, | 26 virtual void AcceptConnection(const String& requestor_url, |
27 ServiceProviderPtr service_provider) override { | 27 InterfaceRequest<ServiceProvider> services, |
| 28 ServiceProviderPtr exported_services) override { |
28 printf("ContentHandler::OnConnect - requestor_url:%s - body follows\n\n", | 29 printf("ContentHandler::OnConnect - requestor_url:%s - body follows\n\n", |
29 requestor_url.To<std::string>().c_str()); | 30 requestor_url.To<std::string>().c_str()); |
30 PrintResponse(body_.Pass()); | 31 PrintResponse(body_.Pass()); |
31 delete this; | 32 delete this; |
32 } | 33 } |
33 | 34 |
34 private: | 35 private: |
35 void PrintResponse(ScopedDataPipeConsumerHandle body) const { | 36 void PrintResponse(ScopedDataPipeConsumerHandle body) const { |
36 for (;;) { | 37 for (;;) { |
37 char buf[512]; | 38 char buf[512]; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp); | 94 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp); |
94 }; | 95 }; |
95 | 96 |
96 } // namespace examples | 97 } // namespace examples |
97 } // namespace mojo | 98 } // namespace mojo |
98 | 99 |
99 MojoResult MojoMain(MojoHandle shell_handle) { | 100 MojoResult MojoMain(MojoHandle shell_handle) { |
100 mojo::ApplicationRunner runner(new mojo::examples::ContentHandlerApp); | 101 mojo::ApplicationRunner runner(new mojo::examples::ContentHandlerApp); |
101 return runner.Run(shell_handle); | 102 return runner.Run(shell_handle); |
102 } | 103 } |
OLD | NEW |