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

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

Issue 56553002: Say "noto" goto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« mojo/public/system/core.h ('K') | « mojo/public/system/core.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_container.h" 5 #include "mojo/shell/app_container.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/callback_helpers.h"
9 #include "base/file_util.h" 10 #include "base/file_util.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/native_library.h" 12 #include "base/native_library.h"
13 #include "base/scoped_native_library.h"
12 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
13 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
14 #include "mojo/public/system/core.h" 16 #include "mojo/public/system/core.h"
15 #include "mojo/services/native_viewport/native_viewport_controller.h" 17 #include "mojo/services/native_viewport/native_viewport_controller.h"
16 #include "mojo/shell/context.h" 18 #include "mojo/shell/context.h"
17 19
18 typedef MojoResult (*MojoMainFunction)(mojo::Handle pipe); 20 typedef MojoResult (*MojoMainFunction)(mojo::Handle pipe);
19 21
20 namespace mojo { 22 namespace mojo {
21 namespace shell { 23 namespace shell {
22 24
23 void LaunchAppOnThread( 25 void LaunchAppOnThread(
24 const base::FilePath& app_path, 26 const base::FilePath& app_path,
25 Handle app_handle) { 27 Handle app_handle_raw) {
26 MojoResult result = MOJO_RESULT_OK; 28 base::ScopedClosureRunner app_deleter(
27 MojoMainFunction main_function = NULL; 29 base::Bind(base::IgnoreResult(&base::DeleteFile), app_path, false));
30 ScopedHandle app_handle(app_handle_raw);
28 31
29 base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, NULL); 32 base::ScopedNativeLibrary app_library(
30 if (!app_library) { 33 base::LoadNativeLibrary(app_path, NULL));
34 if (!app_library.is_valid()) {
31 LOG(ERROR) << "Failed to load library: " << app_path.value().c_str(); 35 LOG(ERROR) << "Failed to load library: " << app_path.value().c_str();
32 goto completed; 36 return;
33 } 37 }
34 38
35 main_function = reinterpret_cast<MojoMainFunction>( 39 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>(
36 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); 40 app_library.GetFunctionPointer("MojoMain"));
37 if (!main_function) { 41 if (!main_function) {
38 LOG(ERROR) << "Entrypoint MojoMain not found."; 42 LOG(ERROR) << "Entrypoint MojoMain not found.";
39 goto completed; 43 return;
40 } 44 }
41 45
42 result = main_function(app_handle); 46 MojoResult result = main_function(app_handle.get());
43 if (result < MOJO_RESULT_OK) { 47 if (result < MOJO_RESULT_OK) {
44 LOG(ERROR) << "MojoMain returned an error: " << result; 48 LOG(ERROR) << "MojoMain returned an error: " << result;
45 // TODO(*): error handling? 49 return;
46 goto completed;
47 } 50 }
48 51
49 LOG(INFO) << "MojoMain succeeded: " << result; 52 LOG(INFO) << "MojoMain succeeded: " << result;
50
51 completed:
52 base::UnloadNativeLibrary(app_library);
53 base::DeleteFile(app_path, false);
54 Close(app_handle);
55 } 53 }
56 54
57 AppContainer::AppContainer(Context* context) 55 AppContainer::AppContainer(Context* context)
58 : context_(context) 56 : context_(context)
59 , weak_factory_(this) { 57 , weak_factory_(this) {
60 } 58 }
61 59
62 AppContainer::~AppContainer() { 60 AppContainer::~AppContainer() {
63 } 61 }
64 62
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 97
100 void AppContainer::AppCompleted() { 98 void AppContainer::AppCompleted() {
101 native_viewport_controller_->Close(); 99 native_viewport_controller_->Close();
102 100
103 thread_.reset(); 101 thread_.reset();
104 Close(shell_handle_); 102 Close(shell_handle_);
105 } 103 }
106 104
107 } // namespace shell 105 } // namespace shell
108 } // namespace mojo 106 } // namespace mojo
OLDNEW
« mojo/public/system/core.h ('K') | « mojo/public/system/core.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698