OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "components/resource_provider/public/cpp/resource_loader.h" | 11 #include "components/resource_provider/public/cpp/resource_loader.h" |
12 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" | 12 #include "components/resource_provider/public/interfaces/resource_provider.mojom
.h" |
13 #include "components/resource_provider/test.mojom.h" | 13 #include "components/resource_provider/test.mojom.h" |
14 #include "mojo/platform_handle/platform_handle_functions.h" | 14 #include "mojo/platform_handle/platform_handle_functions.h" |
15 #include "mojo/public/c/system/main.h" | 15 #include "mojo/public/c/system/main.h" |
16 #include "mojo/public/cpp/bindings/array.h" | 16 #include "mojo/public/cpp/bindings/array.h" |
17 #include "mojo/public/cpp/bindings/binding_set.h" | 17 #include "mojo/public/cpp/bindings/binding_set.h" |
18 #include "services/shell/public/cpp/application_runner.h" | 18 #include "services/shell/public/cpp/application_runner.h" |
19 #include "services/shell/public/cpp/shell_client.h" | 19 #include "services/shell/public/cpp/shell_client.h" |
20 | 20 |
21 namespace resource_provider { | 21 namespace resource_provider { |
22 namespace test { | 22 namespace test { |
23 | 23 |
24 std::string ReadFile(base::File* file) { | 24 std::string ReadFile(base::File* file) { |
25 const size_t kBufferSize = 1 << 16; | 25 const size_t kBufferSize = 1 << 16; |
26 scoped_ptr<char[]> buffer(new char[kBufferSize]); | 26 std::unique_ptr<char[]> buffer(new char[kBufferSize]); |
27 const int read = file->ReadAtCurrentPos(buffer.get(), kBufferSize); | 27 const int read = file->ReadAtCurrentPos(buffer.get(), kBufferSize); |
28 if (read == -1) | 28 if (read == -1) |
29 return std::string(); | 29 return std::string(); |
30 return std::string(buffer.get(), read); | 30 return std::string(buffer.get(), read); |
31 } | 31 } |
32 | 32 |
33 std::set<std::string> SetWithString(const std::string& contents) { | 33 std::set<std::string> SetWithString(const std::string& contents) { |
34 std::set<std::string> result; | 34 std::set<std::string> result; |
35 result.insert(contents); | 35 result.insert(contents); |
36 return result; | 36 return result; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 // InterfaceFactory<mojom::Test>: | 103 // InterfaceFactory<mojom::Test>: |
104 void Create(shell::Connection* connection, | 104 void Create(shell::Connection* connection, |
105 mojom::TestRequest request) override { | 105 mojom::TestRequest request) override { |
106 printf("test app create\n"); | 106 printf("test app create\n"); |
107 bindings_.AddBinding(test_.get(), std::move(request)); | 107 bindings_.AddBinding(test_.get(), std::move(request)); |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 scoped_ptr<Test> test_; | 111 std::unique_ptr<Test> test_; |
112 mojo::BindingSet<test::mojom::Test> bindings_; | 112 mojo::BindingSet<test::mojom::Test> bindings_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(TestApp); | 114 DISALLOW_COPY_AND_ASSIGN(TestApp); |
115 }; | 115 }; |
116 | 116 |
117 } // namespace test | 117 } // namespace test |
118 } // namespace resource_provider | 118 } // namespace resource_provider |
119 | 119 |
120 MojoResult MojoMain(MojoHandle shell_handle) { | 120 MojoResult MojoMain(MojoHandle shell_handle) { |
121 return shell::ApplicationRunner(new resource_provider::test::TestApp) | 121 return shell::ApplicationRunner(new resource_provider::test::TestApp) |
122 .Run(shell_handle); | 122 .Run(shell_handle); |
123 } | 123 } |
OLD | NEW |