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

Side by Side Diff: shell/external_application_listener_unittest.cc

Issue 845593003: Pass ServiceProvider and ServiceProvider& params in Connect (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 base::ScopedTempDir temp_dir_; 68 base::ScopedTempDir temp_dir_;
69 base::FilePath socket_path_; 69 base::FilePath socket_path_;
70 scoped_ptr<ExternalApplicationListener> listener_; 70 scoped_ptr<ExternalApplicationListener> listener_;
71 }; 71 };
72 72
73 namespace { 73 namespace {
74 74
75 class StubShellImpl : public InterfaceImpl<Shell> { 75 class StubShellImpl : public InterfaceImpl<Shell> {
76 private: 76 private:
77 void ConnectToApplication( 77 void ConnectToApplication(const String& requestor_url,
78 const String& requestor_url, 78 InterfaceRequest<ServiceProvider> services,
79 InterfaceRequest<ServiceProvider> in_service_provider) override { 79 ServiceProviderPtr exported_services) override {
80 ServiceProviderPtr out_service_provider; 80 client()->AcceptConnection(requestor_url, services.Pass(),
81 out_service_provider.Bind(in_service_provider.PassMessagePipe()); 81 exported_services.Pass());
82 client()->AcceptConnection(requestor_url, out_service_provider.Pass());
83 } 82 }
84 }; 83 };
85 84
86 void DoLocalRegister(const GURL& app_url, ScopedMessagePipeHandle shell) { 85 void DoLocalRegister(const GURL& app_url, ScopedMessagePipeHandle shell) {
87 BindToPipe(new StubShellImpl, shell.Pass()); 86 BindToPipe(new StubShellImpl, shell.Pass());
88 } 87 }
89 88
90 void QuitLoopOnConnect(scoped_refptr<base::TaskRunner> loop, 89 void QuitLoopOnConnect(scoped_refptr<base::TaskRunner> loop,
91 base::Closure quit_callback, 90 base::Closure quit_callback,
92 int rv) { 91 int rv) {
(...skipping 25 matching lines...) Expand all
118 public: 117 public:
119 QuitLoopOnConnectApplicationImpl(const std::string& url, 118 QuitLoopOnConnectApplicationImpl(const std::string& url,
120 scoped_refptr<base::TaskRunner> loop, 119 scoped_refptr<base::TaskRunner> loop,
121 base::Closure quit_callback) 120 base::Closure quit_callback)
122 : url_(url), to_quit_(loop), quit_callback_(quit_callback) {} 121 : url_(url), to_quit_(loop), quit_callback_(quit_callback) {}
123 122
124 private: 123 private:
125 void Initialize(Array<String> args) override {} 124 void Initialize(Array<String> args) override {}
126 125
127 void AcceptConnection(const String& requestor_url, 126 void AcceptConnection(const String& requestor_url,
128 ServiceProviderPtr p) override { 127 InterfaceRequest<ServiceProvider> services,
128 ServiceProviderPtr exported_services) override {
129 DVLOG(1) << url_ << " accepting connection from " << requestor_url; 129 DVLOG(1) << url_ << " accepting connection from " << requestor_url;
130 to_quit_->PostTask(FROM_HERE, quit_callback_); 130 to_quit_->PostTask(FROM_HERE, quit_callback_);
131 } 131 }
132 132
133 const std::string url_; 133 const std::string url_;
134 scoped_refptr<base::TaskRunner> to_quit_; 134 scoped_refptr<base::TaskRunner> to_quit_;
135 base::Closure quit_callback_; 135 base::Closure quit_callback_;
136 }; 136 };
137 137
138 class FakeExternalApplication { 138 class FakeExternalApplication {
(...skipping 12 matching lines...) Expand all
151 base::Closure register_complete_callback) { 151 base::Closure register_complete_callback) {
152 connection_->Register( 152 connection_->Register(
153 GURL(url_), 153 GURL(url_),
154 base::Bind(&FakeExternalApplication::OnRegister, base::Unretained(this), 154 base::Bind(&FakeExternalApplication::OnRegister, base::Unretained(this),
155 register_complete_callback)); 155 register_complete_callback));
156 application_impl_ = application_impl.Pass(); 156 application_impl_ = application_impl.Pass();
157 } 157 }
158 158
159 void ConnectToAppByUrl(std::string app_url) { 159 void ConnectToAppByUrl(std::string app_url) {
160 ServiceProviderPtr sp; 160 ServiceProviderPtr sp;
161 ptr_->ConnectToApplication(app_url, GetProxy(&sp)); 161 ptr_->ConnectToApplication(app_url, GetProxy(&sp), ServiceProviderPtr());
162 } 162 }
163 163
164 const std::string& url() { return url_; } 164 const std::string& url() { return url_; }
165 165
166 private: 166 private:
167 void OnRegister(base::Closure complete_callback, ShellPtr shell) { 167 void OnRegister(base::Closure complete_callback, ShellPtr shell) {
168 ptr_ = shell.Pass(); 168 ptr_ = shell.Pass();
169 ptr_.set_client(application_impl_.get()); 169 ptr_.set_client(application_impl_.get());
170 complete_callback.Run(); 170 complete_callback.Run();
171 } 171 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 run_loop_.Run(); 246 run_loop_.Run();
247 247
248 // The apps need to be destroyed on the thread where they did socket stuff. 248 // The apps need to be destroyed on the thread where they did socket stuff.
249 io_thread_.task_runner()->PostTask( 249 io_thread_.task_runner()->PostTask(
250 FROM_HERE, base::Bind(&DestroyOnIOThread, base::Passed(&supersweet_app), 250 FROM_HERE, base::Bind(&DestroyOnIOThread, base::Passed(&supersweet_app),
251 base::Passed(&awesome_app))); 251 base::Passed(&awesome_app)));
252 } 252 }
253 253
254 } // namespace shell 254 } // namespace shell
255 } // namespace mojo 255 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698