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

Side by Side Diff: mojo/shell/application_package_apptest.cc

Issue 1675153002: ApplicationImpl->ShellConnection, mojom::Application->mojom::ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ci2
Patch Set: . Created 4 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
« no previous file with comments | « mojo/shell/application_manager_unittest.cc ('k') | mojo/shell/background/background_shell.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 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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 using GetNameCallback = 29 using GetNameCallback =
30 test::mojom::ApplicationPackageApptestService::GetNameCallback; 30 test::mojom::ApplicationPackageApptestService::GetNameCallback;
31 31
32 class ProvidedApplicationDelegate 32 class ProvidedApplicationDelegate
33 : public ShellClient, 33 : public ShellClient,
34 public InterfaceFactory<test::mojom::ApplicationPackageApptestService>, 34 public InterfaceFactory<test::mojom::ApplicationPackageApptestService>,
35 public test::mojom::ApplicationPackageApptestService, 35 public test::mojom::ApplicationPackageApptestService,
36 public base::SimpleThread { 36 public base::SimpleThread {
37 public: 37 public:
38 ProvidedApplicationDelegate(const std::string& name, 38 ProvidedApplicationDelegate(const std::string& name,
39 InterfaceRequest<mojom::Application> request, 39 InterfaceRequest<mojom::ShellClient> request,
40 const Callback<void()>& destruct_callback) 40 const Callback<void()>& destruct_callback)
41 : base::SimpleThread(name), 41 : base::SimpleThread(name),
42 name_(name), 42 name_(name),
43 request_(std::move(request)), 43 request_(std::move(request)),
44 destruct_callback_(destruct_callback) { 44 destruct_callback_(destruct_callback) {
45 Start(); 45 Start();
46 } 46 }
47 ~ProvidedApplicationDelegate() override { 47 ~ProvidedApplicationDelegate() override {
48 Join(); 48 Join();
49 destruct_callback_.Run(); 49 destruct_callback_.Run();
(...skipping 21 matching lines...) Expand all
71 } 71 }
72 72
73 // base::SimpleThread: 73 // base::SimpleThread:
74 void Run() override { 74 void Run() override {
75 ApplicationRunner(this).Run(request_.PassMessagePipe().release().value(), 75 ApplicationRunner(this).Run(request_.PassMessagePipe().release().value(),
76 false); 76 false);
77 delete this; 77 delete this;
78 } 78 }
79 79
80 const std::string name_; 80 const std::string name_;
81 InterfaceRequest<mojom::Application> request_; 81 InterfaceRequest<mojom::ShellClient> request_;
82 const Callback<void()> destruct_callback_; 82 const Callback<void()> destruct_callback_;
83 WeakBindingSet<test::mojom::ApplicationPackageApptestService> bindings_; 83 WeakBindingSet<test::mojom::ApplicationPackageApptestService> bindings_;
84 84
85 DISALLOW_COPY_AND_ASSIGN(ProvidedApplicationDelegate); 85 DISALLOW_COPY_AND_ASSIGN(ProvidedApplicationDelegate);
86 }; 86 };
87 87
88 class ApplicationPackageApptestDelegate 88 class ApplicationPackageApptestDelegate
89 : public ShellClient, 89 : public ShellClient,
90 public InterfaceFactory<mojom::ContentHandler>, 90 public InterfaceFactory<mojom::ContentHandler>,
91 public InterfaceFactory<test::mojom::ApplicationPackageApptestService>, 91 public InterfaceFactory<test::mojom::ApplicationPackageApptestService>,
(...skipping 19 matching lines...) Expand all
111 } 111 }
112 112
113 // InterfaceFactory<test::mojom::ApplicationPackageApptestService>: 113 // InterfaceFactory<test::mojom::ApplicationPackageApptestService>:
114 void Create(Connection* connection, 114 void Create(Connection* connection,
115 InterfaceRequest<test::mojom::ApplicationPackageApptestService> 115 InterfaceRequest<test::mojom::ApplicationPackageApptestService>
116 request) override { 116 request) override {
117 bindings_.AddBinding(this, std::move(request)); 117 bindings_.AddBinding(this, std::move(request));
118 } 118 }
119 119
120 // mojom::ContentHandler: 120 // mojom::ContentHandler:
121 void StartApplication(InterfaceRequest<mojom::Application> request, 121 void StartApplication(InterfaceRequest<mojom::ShellClient> request,
122 URLResponsePtr response, 122 URLResponsePtr response,
123 const Callback<void()>& destruct_callback) override { 123 const Callback<void()>& destruct_callback) override {
124 const std::string url = response->url; 124 const std::string url = response->url;
125 if (url == "mojo://package_test_a/") { 125 if (url == "mojo://package_test_a/") {
126 new ProvidedApplicationDelegate("A", std::move(request), 126 new ProvidedApplicationDelegate("A", std::move(request),
127 destruct_callback); 127 destruct_callback);
128 } else if (url == "mojo://package_test_b/") { 128 } else if (url == "mojo://package_test_b/") {
129 new ProvidedApplicationDelegate("B", std::move(request), 129 new ProvidedApplicationDelegate("B", std::move(request),
130 destruct_callback); 130 destruct_callback);
131 } 131 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 base::RunLoop run_loop; 199 base::RunLoop run_loop;
200 std::string b_name; 200 std::string b_name;
201 service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop)); 201 service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop));
202 run_loop.Run(); 202 run_loop.Run();
203 EXPECT_EQ("B", b_name); 203 EXPECT_EQ("B", b_name);
204 } 204 }
205 } 205 }
206 206
207 } // namespace shell 207 } // namespace shell
208 } // namespace mojo 208 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager_unittest.cc ('k') | mojo/shell/background/background_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698