XWalk WebView patchset, README and LICENSE files.
[platform/framework/web/xwalk_webview.git] / patchset / 0031-Be-more-flexible-in-the-way-we-look-for-efl_process.patch
1 From f15c42e99c2a4c3d7404959a033a852df3516d55 Mon Sep 17 00:00:00 2001
2 From: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
3 Date: Fri, 16 Aug 2013 14:06:52 +0300
4 Subject: [PATCH 31/33] Be more flexible in the way we look for "efl_process".
5
6 The existing code always expected the "efl_process" helper process to be in
7 the same directory as the program being run.
8
9 This obviously breaks horribly when "efl_process" is installed in a system
10 location and one is developing a new application in another directory.
11
12 Mitigate the problem by first looking for the helper process in the
13 application's current directory and then checking /usr/bin.
14
15 This is only a slight bit more portable, but gyp does not have the notions
16 of "install target" and "installation directories", so we cannot also check
17 for a location where we always expect the executable to be.
18 ---
19  efl_webview/lib/web_runtime_context.cc | 40 +++++++++++++++++++++++++---------
20  1 file changed, 30 insertions(+), 10 deletions(-)
21
22 diff --git a/efl_webview/lib/web_runtime_context.cc b/efl_webview/lib/web_runtime_context.cc
23 index ffceaec..48f5f7c 100644
24 --- a/efl_webview/lib/web_runtime_context.cc
25 +++ b/efl_webview/lib/web_runtime_context.cc
26 @@ -21,6 +21,7 @@
27  
28  #include "base/base_paths.h"
29  #include "base/command_line.h"
30 +#include "base/file_util.h"
31  #include "base/path_service.h"
32  #include "content/public/app/content_main_runner.h"
33  #include "content/public/browser/browser_main_runner.h"
34 @@ -38,17 +39,36 @@ WebRuntimeContext* g_context = 0;
35  
36  const char g_sub_process_name[] = "efl_process";
37  
38 -void SubprocessPathInit() {
39 -  base::FilePath current_directory;
40 -  CHECK(PathService::Get(base::FILE_EXE, &current_directory));
41 -  current_directory = current_directory.DirName();
42 -
43 -  // TODO: use more elegant way.
44 -  base::FilePath subprocess_path(
45 -      current_directory.value() + "/" + g_sub_process_name);
46 +base::FilePath SubProcessPath() {
47 +  // We look for "efl_process" in two places:
48 +  // 1. The running binary's directory.
49 +  // 2. A hardcoded /usr/bin.
50 +  // TODO: This is not portable and unfriendly to packagers, but gyp's lack of
51 +  // an "install" target (and therefore of destination paths) makes portability
52 +  // difficult.
53 +  base::FilePath sub_process_path_current;
54 +  CHECK(PathService::Get(base::DIR_EXE, &sub_process_path_current));
55 +  base::FilePath sub_process_path_fallback("/usr/bin");
56 +
57 +  sub_process_path_current =
58 +      sub_process_path_current.Append(g_sub_process_name);
59 +  sub_process_path_fallback =
60 +      sub_process_path_fallback.Append(g_sub_process_name);
61 +
62 +  if (file_util::PathExists(sub_process_path_current))
63 +    return sub_process_path_current;
64 +  else if (file_util::PathExists(sub_process_path_fallback))
65 +    return sub_process_path_fallback;
66 +
67 +  LOG(FATAL) << "No process called '" << g_sub_process_name
68 +             << "' could not be found on the system.";
69 +  return base::FilePath();
70 +}
71  
72 +void SubProcessPathInit() {
73 +  static const base::FilePath& sub_process_path = SubProcessPath();
74    CommandLine::ForCurrentProcess()->
75 -      AppendSwitchPath(switches::kBrowserSubprocessPath, subprocess_path);
76 +      AppendSwitchPath(switches::kBrowserSubprocessPath, sub_process_path);
77  }
78  
79  base::MessagePump* MessagePumpFactory()
80 @@ -71,7 +91,7 @@ WebRuntimeContext::WebRuntimeContext() {
81      runner->Initialize(0, 0, new ContentMainDelegateXWalk);
82    }
83  
84 -  SubprocessPathInit();
85 +  SubProcessPathInit();
86  
87    static content::BrowserMainRunner *browserRunner = 0;
88    if (!browserRunner) {
89 -- 
90 1.8.1.2
91