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

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

Issue 1681813002: Rename Connection::AddService/ConnectToService to Connection::AddInterface/GetInterface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface_binder
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_package_apptest.cc ('k') | mojo/shell/fetcher/about_fetcher_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/shell/capability_filter_test.h" 5 #include "mojo/shell/capability_filter_test.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 private: 50 private:
51 // Overridden from ApplicationLoader: 51 // Overridden from ApplicationLoader:
52 void Load(const GURL& url, 52 void Load(const GURL& url,
53 InterfaceRequest<mojom::ShellClient> request) override { 53 InterfaceRequest<mojom::ShellClient> request) override {
54 app_.reset(new ShellConnection(this, std::move(request))); 54 app_.reset(new ShellConnection(this, std::move(request)));
55 } 55 }
56 56
57 // Overridden from ShellClient: 57 // Overridden from ShellClient:
58 bool AcceptConnection(Connection* connection) override { 58 bool AcceptConnection(Connection* connection) override {
59 connection->AddService<Validator>(this); 59 connection->AddInterface<Validator>(this);
60 return true; 60 return true;
61 } 61 }
62 62
63 // Overridden from InterfaceFactory<Validator>: 63 // Overridden from InterfaceFactory<Validator>:
64 void Create(Connection* connection, 64 void Create(Connection* connection,
65 InterfaceRequest<Validator> request) override { 65 InterfaceRequest<Validator> request) override {
66 validator_bindings_.AddBinding(this, std::move(request)); 66 validator_bindings_.AddBinding(this, std::move(request));
67 } 67 }
68 68
69 // Overridden from Validator: 69 // Overridden from Validator:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void Create(Connection* connection, 138 void Create(Connection* connection,
139 InterfaceRequest<Unsafe> request) override { 139 InterfaceRequest<Unsafe> request) override {
140 unsafe_bindings_.AddBinding(this, std::move(request)); 140 unsafe_bindings_.AddBinding(this, std::move(request));
141 } 141 }
142 142
143 template <typename Interface> 143 template <typename Interface>
144 void AddService(Connection* connection) { 144 void AddService(Connection* connection) {
145 validator_->AddServiceCalled(connection->GetRemoteApplicationURL(), 145 validator_->AddServiceCalled(connection->GetRemoteApplicationURL(),
146 connection->GetConnectionURL(), 146 connection->GetConnectionURL(),
147 Interface::Name_, 147 Interface::Name_,
148 !connection->AddService<Interface>(this)); 148 !connection->AddInterface<Interface>(this));
149 } 149 }
150 150
151 Shell* shell_; 151 Shell* shell_;
152 ValidatorPtr validator_; 152 ValidatorPtr validator_;
153 WeakBindingSet<Safe> safe_bindings_; 153 WeakBindingSet<Safe> safe_bindings_;
154 WeakBindingSet<Unsafe> unsafe_bindings_; 154 WeakBindingSet<Unsafe> unsafe_bindings_;
155 155
156 DISALLOW_COPY_AND_ASSIGN(ServiceApplication); 156 DISALLOW_COPY_AND_ASSIGN(ServiceApplication);
157 }; 157 };
158 158
159 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
160 // TestApplication: 160 // TestApplication:
161 161
162 TestApplication::TestApplication() : shell_(nullptr) {} 162 TestApplication::TestApplication() : shell_(nullptr) {}
163 TestApplication::~TestApplication() {} 163 TestApplication::~TestApplication() {}
164 164
165 void TestApplication::Initialize(Shell* shell, const std::string& url, 165 void TestApplication::Initialize(Shell* shell, const std::string& url,
166 uint32_t id) { 166 uint32_t id) {
167 shell_ = shell; 167 shell_ = shell;
168 url_ = url; 168 url_ = url;
169 } 169 }
170 bool TestApplication::AcceptConnection(Connection* connection) { 170 bool TestApplication::AcceptConnection(Connection* connection) {
171 // TestApplications receive their Validator via the inbound connection. 171 // TestApplications receive their Validator via the inbound connection.
172 connection->ConnectToService(&validator_); 172 connection->GetInterface(&validator_);
173 173
174 connection1_ = shell_->Connect("test:service"); 174 connection1_ = shell_->Connect("test:service");
175 connection1_->SetRemoteServiceProviderConnectionErrorHandler( 175 connection1_->SetRemoteServiceProviderConnectionErrorHandler(
176 base::Bind(&TestApplication::ConnectionClosed, 176 base::Bind(&TestApplication::ConnectionClosed,
177 base::Unretained(this), "test:service")); 177 base::Unretained(this), "test:service"));
178 178
179 connection2_ = shell_->Connect("test:service2"); 179 connection2_ = shell_->Connect("test:service2");
180 connection2_->SetRemoteServiceProviderConnectionErrorHandler( 180 connection2_->SetRemoteServiceProviderConnectionErrorHandler(
181 base::Bind(&TestApplication::ConnectionClosed, 181 base::Bind(&TestApplication::ConnectionClosed,
182 base::Unretained(this), "test:service2")); 182 base::Unretained(this), "test:service2"));
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void CapabilityFilterTest::RunTest() { 344 void CapabilityFilterTest::RunTest() {
345 loop()->Run(); 345 loop()->Run();
346 EXPECT_TRUE(validator_->expectations_met()); 346 EXPECT_TRUE(validator_->expectations_met());
347 if (!validator_->expectations_met()) 347 if (!validator_->expectations_met())
348 validator_->PrintUnmetExpectations(); 348 validator_->PrintUnmetExpectations();
349 } 349 }
350 350
351 } // namespace test 351 } // namespace test
352 } // namespace shell 352 } // namespace shell
353 } // namespace mojo 353 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_package_apptest.cc ('k') | mojo/shell/fetcher/about_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698