OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/child_process_host.h" | 5 #include "chrome/common/child_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | |
10 #include "chrome/common/child_process_info.h" | 11 #include "chrome/common/child_process_info.h" |
11 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
12 #include "chrome/common/chrome_paths_internal.h" | 13 #include "chrome/common/chrome_paths_internal.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/plugin_messages.h" | 15 #include "chrome/common/plugin_messages.h" |
15 #include "ipc/ipc_logging.h" | 16 #include "ipc/ipc_logging.h" |
16 | 17 |
17 #if defined(OS_LINUX) | 18 #if defined(OS_LINUX) |
18 #include "base/linux_util.h" | 19 #include "base/linux_util.h" |
19 #endif // OS_LINUX | 20 #endif // OS_LINUX |
(...skipping 29 matching lines...) Expand all Loading... | |
49 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
50 // On the Mac, the child executable lives at a predefined location within | 51 // On the Mac, the child executable lives at a predefined location within |
51 // the app bundle's versioned directory. | 52 // the app bundle's versioned directory. |
52 return chrome::GetVersionedDirectory(). | 53 return chrome::GetVersionedDirectory(). |
53 Append(chrome::kHelperProcessExecutablePath); | 54 Append(chrome::kHelperProcessExecutablePath); |
54 #endif | 55 #endif |
55 | 56 |
56 #if defined(OS_LINUX) | 57 #if defined(OS_LINUX) |
57 // Use /proc/self/exe rather than our known binary path so updates | 58 // Use /proc/self/exe rather than our known binary path so updates |
58 // can't swap out the binary from underneath us. | 59 // can't swap out the binary from underneath us. |
59 if (allow_self) | 60 // When running under Valgrind, forking /proc/self/exe ends up forking the |
61 // Valgrind executable, which then crashes. However, it's almost safe to | |
62 // assume that the updates won't happen while testing with Valgrind tools. | |
63 if (allow_self && !RunningOnValgrind()) | |
60 return FilePath("/proc/self/exe"); | 64 return FilePath("/proc/self/exe"); |
61 #endif | 65 #endif |
62 | 66 |
63 // On most platforms, the child executable is the same as the current | 67 // On most platforms, the child executable is the same as the current |
64 // executable. | 68 // executable. |
65 PathService::Get(base::FILE_EXE, &child_path); | 69 PathService::Get(base::FILE_EXE, &child_path); |
evanm
2011/01/14 17:19:20
Do we know if this returns /proc/self/exe too? My
| |
66 return child_path; | 70 return child_path; |
67 } | 71 } |
68 | 72 |
69 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
70 // static | 74 // static |
71 void ChildProcessHost::PreCacheFont(LOGFONT font) { | 75 void ChildProcessHost::PreCacheFont(LOGFONT font) { |
72 // If a child process is running in a sandbox, GetTextMetrics() | 76 // If a child process is running in a sandbox, GetTextMetrics() |
73 // can sometimes fail. If a font has not been loaded | 77 // can sometimes fail. If a font has not been loaded |
74 // previously, GetTextMetrics() will try to load the font | 78 // previously, GetTextMetrics() will try to load the font |
75 // from the font file. However, the sandboxed process does | 79 // from the font file. However, the sandboxed process does |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 for (size_t i = 0; i < host_->filters_.size(); ++i) | 213 for (size_t i = 0; i < host_->filters_.size(); ++i) |
210 host_->filters_[i]->OnChannelError(); | 214 host_->filters_[i]->OnChannelError(); |
211 | 215 |
212 // This will delete host_, which will also destroy this! | 216 // This will delete host_, which will also destroy this! |
213 host_->OnChildDied(); | 217 host_->OnChildDied(); |
214 } | 218 } |
215 | 219 |
216 void ChildProcessHost::ForceShutdown() { | 220 void ChildProcessHost::ForceShutdown() { |
217 Send(new PluginProcessMsg_Shutdown()); | 221 Send(new PluginProcessMsg_Shutdown()); |
218 } | 222 } |
OLD | NEW |