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

Unified Diff: mojo/shell/app_container.cc

Issue 56553002: Say "noto" goto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: eru? 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/utility/scoped_handle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/app_container.cc
diff --git a/mojo/shell/app_container.cc b/mojo/shell/app_container.cc
index de0fe2ab6fb2d52674cfb4fcfb6733cacdbd2659..bb8ed23184bca743cbc3e390d7eb12c7e8346c42 100644
--- a/mojo/shell/app_container.cc
+++ b/mojo/shell/app_container.cc
@@ -6,12 +6,15 @@
#include "base/bind.h"
#include "base/callback_forward.h"
+#include "base/callback_helpers.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/native_library.h"
+#include "base/scoped_native_library.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "mojo/public/system/core.h"
+#include "mojo/public/utility/scoped_handle.h"
#include "mojo/services/native_viewport/native_viewport_controller.h"
#include "mojo/shell/context.h"
@@ -22,36 +25,32 @@ namespace shell {
void LaunchAppOnThread(
const base::FilePath& app_path,
- Handle app_handle) {
- MojoResult result = MOJO_RESULT_OK;
- MojoMainFunction main_function = NULL;
-
- base::NativeLibrary app_library = base::LoadNativeLibrary(app_path, NULL);
- if (!app_library) {
+ Handle app_handle_raw) {
+ base::ScopedClosureRunner app_deleter(
+ base::Bind(base::IgnoreResult(&base::DeleteFile), app_path, false));
+ ScopedHandle app_handle(app_handle_raw);
+
+ base::ScopedNativeLibrary app_library(
+ base::LoadNativeLibrary(app_path, NULL));
+ if (!app_library.is_valid()) {
LOG(ERROR) << "Failed to load library: " << app_path.value().c_str();
- goto completed;
+ return;
}
- main_function = reinterpret_cast<MojoMainFunction>(
- base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain"));
+ MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>(
+ app_library.GetFunctionPointer("MojoMain"));
if (!main_function) {
LOG(ERROR) << "Entrypoint MojoMain not found.";
- goto completed;
+ return;
}
- result = main_function(app_handle);
+ MojoResult result = main_function(app_handle.get());
if (result < MOJO_RESULT_OK) {
LOG(ERROR) << "MojoMain returned an error: " << result;
- // TODO(*): error handling?
- goto completed;
+ return;
}
LOG(INFO) << "MojoMain succeeded: " << result;
-
-completed:
- base::UnloadNativeLibrary(app_library);
- base::DeleteFile(app_path, false);
- Close(app_handle);
}
AppContainer::AppContainer(Context* context)
« no previous file with comments | « mojo/public/utility/scoped_handle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698