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

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

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
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
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
11 #include "base/base_switches.h" 11 #include "base/base_switches.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/process/process.h" 19 #include "base/process/process.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "mojo/common/weak_binding_set.h" 21 #include "mojo/common/weak_binding_set.h"
22 #include "mojo/converters/network/network_type_converters.h" 22 #include "mojo/converters/network/network_type_converters.h"
23 #include "mojo/edk/embedder/embedder.h" 23 #include "mojo/edk/embedder/embedder.h"
24 #include "mojo/edk/embedder/platform_channel_pair.h" 24 #include "mojo/edk/embedder/platform_channel_pair.h"
25 #include "mojo/edk/embedder/scoped_platform_handle.h" 25 #include "mojo/edk/embedder/scoped_platform_handle.h"
26 #include "mojo/shell/application_manager_apptests.mojom.h" 26 #include "mojo/shell/application_manager_apptests.mojom.h"
27 #include "mojo/shell/public/cpp/application_connection.h" 27 #include "mojo/shell/public/cpp/connection.h"
28 #include "mojo/shell/public/cpp/application_delegate.h"
29 #include "mojo/shell/public/cpp/interface_factory.h" 28 #include "mojo/shell/public/cpp/interface_factory.h"
30 #include "mojo/shell/public/cpp/shell.h" 29 #include "mojo/shell/public/cpp/shell.h"
30 #include "mojo/shell/public/cpp/shell_client.h"
31 #include "mojo/shell/public/interfaces/application_manager.mojom.h" 31 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
32 #include "mojo/shell/runner/child/test_native_main.h" 32 #include "mojo/shell/runner/child/test_native_main.h"
33 #include "mojo/shell/runner/common/switches.h" 33 #include "mojo/shell/runner/common/switches.h"
34 #include "mojo/shell/runner/init.h" 34 #include "mojo/shell/runner/init.h"
35 35
36 using mojo::shell::test::mojom::CreateInstanceForHandleTestPtr; 36 using mojo::shell::test::mojom::CreateInstanceForHandleTestPtr;
37 using mojo::shell::test::mojom::Driver; 37 using mojo::shell::test::mojom::Driver;
38 38
39 namespace { 39 namespace {
40 40
41 class TargetApplicationDelegate : public mojo::ApplicationDelegate, 41 class TargetApplicationDelegate : public mojo::ShellClient,
42 public mojo::InterfaceFactory<Driver>, 42 public mojo::InterfaceFactory<Driver>,
43 public Driver { 43 public Driver {
44 public: 44 public:
45 TargetApplicationDelegate() : shell_(nullptr), weak_factory_(this) {} 45 TargetApplicationDelegate() : shell_(nullptr), weak_factory_(this) {}
46 ~TargetApplicationDelegate() override {} 46 ~TargetApplicationDelegate() override {}
47 47
48 private: 48 private:
49 // mojo::ApplicationDelegate: 49 // mojo::ShellClient:
50 void Initialize(mojo::Shell* shell, const std::string& url, 50 void Initialize(mojo::Shell* shell, const std::string& url,
51 uint32_t id) override { 51 uint32_t id) override {
52 shell_ = shell; 52 shell_ = shell;
53 53
54 base::FilePath target_path; 54 base::FilePath target_path;
55 CHECK(base::PathService::Get(base::DIR_EXE, &target_path)); 55 CHECK(base::PathService::Get(base::DIR_EXE, &target_path));
56 #if defined(OS_WIN) 56 #if defined(OS_WIN)
57 target_path = target_path.Append( 57 target_path = target_path.Append(
58 FILE_PATH_LITERAL("application_manager_apptest_target.exe")); 58 FILE_PATH_LITERAL("application_manager_apptest_target.exe"));
59 #else 59 #else
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #elif defined(OS_POSIX) 103 #elif defined(OS_POSIX)
104 options.fds_to_remap = &handle_passing_info; 104 options.fds_to_remap = &handle_passing_info;
105 #endif 105 #endif
106 target_ = base::LaunchProcess(child_command_line, options); 106 target_ = base::LaunchProcess(child_command_line, options);
107 DCHECK(target_.IsValid()); 107 DCHECK(target_.IsValid());
108 receiver->SetPID(target_.Pid()); 108 receiver->SetPID(target_.Pid());
109 mojo::edk::ChildProcessLaunched(target_.Handle(), 109 mojo::edk::ChildProcessLaunched(target_.Handle(),
110 platform_channel_pair.PassServerHandle()); 110 platform_channel_pair.PassServerHandle());
111 } 111 }
112 112
113 bool AcceptConnection(mojo::ApplicationConnection* connection) override { 113 bool AcceptConnection(mojo::Connection* connection) override {
114 connection->AddService<Driver>(this); 114 connection->AddService<Driver>(this);
115 return true; 115 return true;
116 } 116 }
117 117
118 // mojo::InterfaceFactory<Driver>: 118 // mojo::InterfaceFactory<Driver>:
119 void Create(mojo::ApplicationConnection* connection, 119 void Create(mojo::Connection* connection,
120 mojo::InterfaceRequest<Driver> request) override { 120 mojo::InterfaceRequest<Driver> request) override {
121 bindings_.AddBinding(this, std::move(request)); 121 bindings_.AddBinding(this, std::move(request));
122 } 122 }
123 123
124 // Driver: 124 // Driver:
125 void QuitDriver() override { 125 void QuitDriver() override {
126 target_.Terminate(0, false); 126 target_.Terminate(0, false);
127 shell_->Quit(); 127 shell_->Quit();
128 } 128 }
129 129
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 int main(int argc, char** argv) { 170 int main(int argc, char** argv) {
171 base::AtExitManager at_exit; 171 base::AtExitManager at_exit;
172 base::CommandLine::Init(argc, argv); 172 base::CommandLine::Init(argc, argv);
173 173
174 mojo::shell::InitializeLogging(); 174 mojo::shell::InitializeLogging();
175 175
176 TargetApplicationDelegate delegate; 176 TargetApplicationDelegate delegate;
177 return mojo::shell::TestNativeMain(&delegate); 177 return mojo::shell::TestNativeMain(&delegate);
178 } 178 }
OLDNEW
« no previous file with comments | « mojo/shell/application_manager_apptest.cc ('k') | mojo/shell/application_manager_apptest_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698