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

Side by Side Diff: components/resource_provider/resource_provider_test_app.cc

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 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"
(...skipping 28 matching lines...) Expand all
39 std::set<std::string> SetWithStrings(const std::string& contents1, 39 std::set<std::string> SetWithStrings(const std::string& contents1,
40 const std::string& contents2) { 40 const std::string& contents2) {
41 std::set<std::string> result; 41 std::set<std::string> result;
42 result.insert(contents1); 42 result.insert(contents1);
43 result.insert(contents2); 43 result.insert(contents2);
44 return result; 44 return result;
45 } 45 }
46 46
47 class Test : public mojom::Test { 47 class Test : public mojom::Test {
48 public: 48 public:
49 explicit Test(mojo::Connector* connector) : connector_(connector) {} 49 explicit Test(shell::Connector* connector) : connector_(connector) {}
50 ~Test() override {} 50 ~Test() override {}
51 51
52 // mojom::Test: 52 // mojom::Test:
53 void GetResource1(const GetResource1Callback& callback) override { 53 void GetResource1(const GetResource1Callback& callback) override {
54 printf("GetResource1\n"); 54 printf("GetResource1\n");
55 ResourceContentsMap results(GetResources(SetWithString("sample"))); 55 ResourceContentsMap results(GetResources(SetWithString("sample")));
56 printf("GetResource1 result %s\n", results["sample"].c_str()); 56 printf("GetResource1 result %s\n", results["sample"].c_str());
57 callback.Run(results["sample"]); 57 callback.Run(results["sample"]);
58 } 58 }
59 void GetBothResources(const GetBothResourcesCallback& callback) override { 59 void GetBothResources(const GetBothResourcesCallback& callback) override {
(...skipping 11 matching lines...) Expand all
71 71
72 // Load the contents of each of the handles. 72 // Load the contents of each of the handles.
73 ResourceContentsMap results; 73 ResourceContentsMap results;
74 for (auto& path : paths) { 74 for (auto& path : paths) {
75 base::File file(loader.ReleaseFile(path)); 75 base::File file(loader.ReleaseFile(path));
76 results[path] = ReadFile(&file); 76 results[path] = ReadFile(&file);
77 } 77 }
78 return results; 78 return results;
79 } 79 }
80 80
81 mojo::Connector* connector_; 81 shell::Connector* connector_;
82 82
83 DISALLOW_COPY_AND_ASSIGN(Test); 83 DISALLOW_COPY_AND_ASSIGN(Test);
84 }; 84 };
85 85
86 class TestApp : public mojo::ShellClient, 86 class TestApp : public shell::ShellClient,
87 public mojo::InterfaceFactory<mojom::Test> { 87 public shell::InterfaceFactory<mojom::Test> {
88 public: 88 public:
89 TestApp() {} 89 TestApp() {}
90 ~TestApp() override {} 90 ~TestApp() override {}
91 91
92 // mojo::ShellClient: 92 // shell::ShellClient:
93 void Initialize(mojo::Connector* connector, 93 void Initialize(shell::Connector* connector,
94 const mojo::Identity& identity, 94 const shell::Identity& identity,
95 uint32_t id) override { 95 uint32_t id) override {
96 test_.reset(new Test(connector)); 96 test_.reset(new Test(connector));
97 } 97 }
98 bool AcceptConnection(mojo::Connection* connection) override { 98 bool AcceptConnection(shell::Connection* connection) override {
99 connection->AddInterface<mojom::Test>(this); 99 connection->AddInterface<mojom::Test>(this);
100 return true; 100 return true;
101 } 101 }
102 102
103 // InterfaceFactory<mojom::Test>: 103 // InterfaceFactory<mojom::Test>:
104 void Create(mojo::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 scoped_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 mojo::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 }
OLDNEW
« no previous file with comments | « components/resource_provider/resource_provider_app.cc ('k') | components/resource_provider/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698