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

Side by Side Diff: mash/webtest/webtest.cc

Issue 2646193002: Replace OnConnect with OnBindInterface in //mash. (Closed)
Patch Set: . Created 3 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 | « mash/webtest/webtest.h ('k') | no next file » | 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 "mash/webtest/webtest.h" 5 #include "mash/webtest/webtest.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 Webtest* webtest_; 146 Webtest* webtest_;
147 aura::Window* content_area_ = nullptr; 147 aura::Window* content_area_ = nullptr;
148 navigation::mojom::ViewPtr view_; 148 navigation::mojom::ViewPtr view_;
149 mojo::Binding<navigation::mojom::ViewClient> view_client_binding_; 149 mojo::Binding<navigation::mojom::ViewClient> view_client_binding_;
150 base::string16 current_title_; 150 base::string16 current_title_;
151 151
152 DISALLOW_COPY_AND_ASSIGN(UI); 152 DISALLOW_COPY_AND_ASSIGN(UI);
153 }; 153 };
154 154
155 Webtest::Webtest() {} 155 Webtest::Webtest() {
156 registry_.AddInterface<mojom::Launchable>(this);
157 }
156 Webtest::~Webtest() {} 158 Webtest::~Webtest() {}
157 159
158 void Webtest::AddWindow(views::Widget* window) { 160 void Webtest::AddWindow(views::Widget* window) {
159 windows_.push_back(window); 161 windows_.push_back(window);
160 } 162 }
161 163
162 void Webtest::RemoveWindow(views::Widget* window) { 164 void Webtest::RemoveWindow(views::Widget* window) {
163 auto it = std::find(windows_.begin(), windows_.end(), window); 165 auto it = std::find(windows_.begin(), windows_.end(), window);
164 DCHECK(it != windows_.end()); 166 DCHECK(it != windows_.end());
165 windows_.erase(it); 167 windows_.erase(it);
166 if (windows_.empty()) 168 if (windows_.empty())
167 base::MessageLoop::current()->QuitWhenIdle(); 169 base::MessageLoop::current()->QuitWhenIdle();
168 } 170 }
169 171
170 void Webtest::OnStart() { 172 void Webtest::OnStart() {
171 tracing_.Initialize(context()->connector(), context()->identity().name()); 173 tracing_.Initialize(context()->connector(), context()->identity().name());
172 aura_init_ = base::MakeUnique<views::AuraInit>( 174 aura_init_ = base::MakeUnique<views::AuraInit>(
173 context()->connector(), context()->identity(), "views_mus_resources.pak", 175 context()->connector(), context()->identity(), "views_mus_resources.pak",
174 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); 176 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS);
175 } 177 }
176 178
177 bool Webtest::OnConnect(const service_manager::ServiceInfo& remote_info, 179 void Webtest::OnBindInterface(const service_manager::ServiceInfo& source_info,
178 service_manager::InterfaceRegistry* registry) { 180 const std::string& interface_name,
179 registry->AddInterface<mojom::Launchable>(this); 181 mojo::ScopedMessagePipeHandle interface_pipe) {
180 return true; 182 registry_.BindInterface(source_info.identity, interface_name,
183 std::move(interface_pipe));
181 } 184 }
182 185
183 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) { 186 void Webtest::Launch(uint32_t what, mojom::LaunchMode how) {
184 bool reuse = how == mojom::LaunchMode::REUSE || 187 bool reuse = how == mojom::LaunchMode::REUSE ||
185 how == mojom::LaunchMode::DEFAULT; 188 how == mojom::LaunchMode::DEFAULT;
186 if (reuse && !windows_.empty()) { 189 if (reuse && !windows_.empty()) {
187 windows_.back()->Activate(); 190 windows_.back()->Activate();
188 return; 191 return;
189 } 192 }
190 193
(...skipping 11 matching lines...) Expand all
202 AddWindow(window); 205 AddWindow(window);
203 } 206 }
204 207
205 void Webtest::Create(const service_manager::Identity& remote_identity, 208 void Webtest::Create(const service_manager::Identity& remote_identity,
206 mojom::LaunchableRequest request) { 209 mojom::LaunchableRequest request) {
207 bindings_.AddBinding(this, std::move(request)); 210 bindings_.AddBinding(this, std::move(request));
208 } 211 }
209 212
210 } // namespace webtest 213 } // namespace webtest
211 } // namespace mash 214 } // namespace mash
OLDNEW
« no previous file with comments | « mash/webtest/webtest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698