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

Unified Diff: base/file_util_posix.cc

Issue 115773: Prototype implementation of zygotes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_descriptor_shuffle.cc ('k') | base/logging.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_posix.cc
===================================================================
--- base/file_util_posix.cc (revision 17632)
+++ base/file_util_posix.cc (working copy)
@@ -27,6 +27,7 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "base/time.h"
+#include "base/zygote_manager.h"
namespace file_util {
@@ -625,20 +626,37 @@
}
bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
- file_ = open(file_name.value().c_str(), O_RDONLY);
+ file_ = -1;
+#if defined(OS_LINUX)
+ base::ZygoteManager* zm = base::ZygoteManager::Get();
+ if (zm) {
+ file_ = zm->OpenFile(file_name.value().c_str());
+ if (file_ == -1) {
+ LOG(INFO) << "Zygote manager can't open " << file_name.value()
+ << ", retrying locally";
+ }
+ }
+#endif // defined(OS_LINUX)
if (file_ == -1)
+ file_ = open(file_name.value().c_str(), O_RDONLY);
+ if (file_ == -1) {
+ LOG(ERROR) << "Couldn't open " << file_name.value();
return false;
+ }
struct stat file_stat;
- if (fstat(file_, &file_stat) == -1)
+ if (fstat(file_, &file_stat) == -1) {
+ LOG(ERROR) << "Couldn't fstat " << file_name.value() << ", errno " << errno;
return false;
+ }
length_ = file_stat.st_size;
data_ = static_cast<uint8*>(
mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0));
if (data_ == MAP_FAILED)
- data_ = NULL;
- return data_ != NULL;
+ LOG(ERROR) << "Couldn't mmap " << file_name.value() << ", errno " << errno;
+
+ return data_ != MAP_FAILED;
}
void MemoryMappedFile::CloseHandles() {
« no previous file with comments | « base/file_descriptor_shuffle.cc ('k') | base/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698