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

Side by Side Diff: shell/app_child_process.cc

Issue 865253002: Delete temporary application file as soon as the application is launched. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review 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 "shell/app_child_process.h" 5 #include "shell/app_child_process.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 app_context->set_controller(impl.Pass()); 178 app_context->set_controller(impl.Pass());
179 } 179 }
180 180
181 void OnConnectionError() override { 181 void OnConnectionError() override {
182 // TODO(darin): How should we handle a connection error here? 182 // TODO(darin): How should we handle a connection error here?
183 } 183 }
184 184
185 // |AppChildController| methods: 185 // |AppChildController| methods:
186 void StartApp(const String& app_path, 186 void StartApp(const String& app_path,
187 uint8_t cleanup_behavior,
187 ScopedMessagePipeHandle service) override { 188 ScopedMessagePipeHandle service) override {
188 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; 189 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)";
189 DCHECK(thread_checker_.CalledOnValidThread()); 190 DCHECK(thread_checker_.CalledOnValidThread());
190 191
191 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, 192 unblocker_.Unblock(base::Bind(
192 base::FilePath::FromUTF8Unsafe(app_path), 193 &AppChildControllerImpl::StartAppOnMainThread,
193 base::Passed(&service))); 194 base::FilePath::FromUTF8Unsafe(app_path),
195 static_cast<DynamicServiceRunner::CleanupBehavior>(cleanup_behavior),
196 base::Passed(&service)));
194 } 197 }
195 198
196 private: 199 private:
197 AppChildControllerImpl(AppContext* app_context, 200 AppChildControllerImpl(AppContext* app_context,
198 const Blocker::Unblocker& unblocker) 201 const Blocker::Unblocker& unblocker)
199 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {} 202 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {}
200 203
201 // Callback for |embedder::CreateChannel()|. 204 // Callback for |embedder::CreateChannel()|.
202 void DidCreateChannel(embedder::ChannelInfo* channel_info) { 205 void DidCreateChannel(embedder::ChannelInfo* channel_info) {
203 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; 206 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()";
204 DCHECK(thread_checker_.CalledOnValidThread()); 207 DCHECK(thread_checker_.CalledOnValidThread());
205 channel_info_ = channel_info; 208 channel_info_ = channel_info;
206 } 209 }
207 210
208 static void StartAppOnMainThread(const base::FilePath& app_path, 211 static void StartAppOnMainThread(
209 ScopedMessagePipeHandle service) { 212 const base::FilePath& app_path,
213 DynamicServiceRunner::CleanupBehavior cleanup_behavior,
214 ScopedMessagePipeHandle service) {
210 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. 215 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc.
211 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() 216 DVLOG(2) << "Loading/running Mojo app from " << app_path.value()
212 << " out of process"; 217 << " out of process";
213 218
214 // We intentionally don't unload the native library as its lifetime is the 219 // We intentionally don't unload the native library as its lifetime is the
215 // same as that of the process. 220 // same as that of the process.
216 DynamicServiceRunner::LoadAndRunService(app_path, service.Pass()); 221 DynamicServiceRunner::LoadAndRunService(app_path, cleanup_behavior,
222 service.Pass());
217 } 223 }
218 224
219 base::ThreadChecker thread_checker_; 225 base::ThreadChecker thread_checker_;
220 AppContext* const app_context_; 226 AppContext* const app_context_;
221 Blocker::Unblocker unblocker_; 227 Blocker::Unblocker unblocker_;
222 228
223 embedder::ChannelInfo* channel_info_; 229 embedder::ChannelInfo* channel_info_;
224 230
225 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl); 231 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl);
226 }; 232 };
(...skipping 20 matching lines...) Expand all
247 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), 253 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context),
248 base::Passed(platform_channel()), blocker.GetUnblocker())); 254 base::Passed(platform_channel()), blocker.GetUnblocker()));
249 // This will block, then run whatever the controller wants. 255 // This will block, then run whatever the controller wants.
250 blocker.Block(); 256 blocker.Block();
251 257
252 app_context.Shutdown(); 258 app_context.Shutdown();
253 } 259 }
254 260
255 } // namespace shell 261 } // namespace shell
256 } // namespace mojo 262 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698