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

Side by Side Diff: mojo/shell/standalone/test/pingable_app.cc

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
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/standalone/shell_apptest.cc ('k') | sql/mojo/sql_test_base.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/public/c/system/main.h" 5 #include "mojo/public/c/system/main.h"
6 #include "mojo/public/cpp/bindings/callback.h" 6 #include "mojo/public/cpp/bindings/callback.h"
7 #include "mojo/public/cpp/bindings/interface_request.h" 7 #include "mojo/public/cpp/bindings/interface_request.h"
8 #include "mojo/public/cpp/bindings/strong_binding.h" 8 #include "mojo/public/cpp/bindings/strong_binding.h"
9 #include "mojo/shell/public/cpp/application_delegate.h" 9 #include "mojo/shell/public/cpp/application_delegate.h"
10 #include "mojo/shell/public/cpp/application_impl.h"
11 #include "mojo/shell/public/cpp/application_runner.h" 10 #include "mojo/shell/public/cpp/application_runner.h"
12 #include "mojo/shell/public/cpp/interface_factory.h" 11 #include "mojo/shell/public/cpp/interface_factory.h"
12 #include "mojo/shell/public/cpp/shell.h"
13 #include "mojo/shell/standalone/test/pingable.mojom.h" 13 #include "mojo/shell/standalone/test/pingable.mojom.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 16
17 class PingableImpl : public Pingable { 17 class PingableImpl : public Pingable {
18 public: 18 public:
19 PingableImpl(InterfaceRequest<Pingable> request, 19 PingableImpl(InterfaceRequest<Pingable> request,
20 const std::string& app_url, 20 const std::string& app_url,
21 const std::string& connection_url) 21 const std::string& connection_url)
22 : binding_(this, std::move(request)), 22 : binding_(this, std::move(request)),
(...skipping 14 matching lines...) Expand all
37 }; 37 };
38 38
39 class PingableApp : public mojo::ApplicationDelegate, 39 class PingableApp : public mojo::ApplicationDelegate,
40 public mojo::InterfaceFactory<Pingable> { 40 public mojo::InterfaceFactory<Pingable> {
41 public: 41 public:
42 PingableApp() {} 42 PingableApp() {}
43 ~PingableApp() override {} 43 ~PingableApp() override {}
44 44
45 private: 45 private:
46 // ApplicationDelegate: 46 // ApplicationDelegate:
47 void Initialize(ApplicationImpl* impl) override { app_url_ = impl->url(); } 47 void Initialize(Shell* shell, const std::string& url, uint32_t id) override {
48 app_url_ = url;
49 }
48 50
49 bool AcceptConnection(mojo::ApplicationConnection* connection) override { 51 bool AcceptConnection(mojo::ApplicationConnection* connection) override {
50 connection->AddService(this); 52 connection->AddService(this);
51 return true; 53 return true;
52 } 54 }
53 55
54 // InterfaceFactory<Pingable>: 56 // InterfaceFactory<Pingable>:
55 void Create(mojo::ApplicationConnection* connection, 57 void Create(mojo::ApplicationConnection* connection,
56 mojo::InterfaceRequest<Pingable> request) override { 58 mojo::InterfaceRequest<Pingable> request) override {
57 new PingableImpl(std::move(request), app_url_, 59 new PingableImpl(std::move(request), app_url_,
58 connection->GetConnectionURL()); 60 connection->GetConnectionURL());
59 } 61 }
60 62
61 std::string app_url_; 63 std::string app_url_;
62 }; 64 };
63 65
64 } // namespace mojo 66 } // namespace mojo
65 67
66 MojoResult MojoMain(MojoHandle shell_handle) { 68 MojoResult MojoMain(MojoHandle shell_handle) {
67 mojo::ApplicationRunner runner(new mojo::PingableApp); 69 mojo::ApplicationRunner runner(new mojo::PingableApp);
68 return runner.Run(shell_handle); 70 return runner.Run(shell_handle);
69 } 71 }
OLDNEW
« no previous file with comments | « mojo/shell/standalone/shell_apptest.cc ('k') | sql/mojo/sql_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698