diff options
-rw-r--r-- | base/file_util.h | 8 | ||||
-rw-r--r-- | base/file_util_win.cc | 53 | ||||
-rw-r--r-- | chrome/browser/utility_process_host.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker.cc | 34 |
6 files changed, 15 insertions, 88 deletions
diff --git a/base/file_util.h b/base/file_util.h index 7825d5b..553f520 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -281,14 +281,6 @@ bool CreateTemporaryDirInDir(const FilePath& base_dir, // already exists. The directory is only readable by the current user. bool CreateDirectory(const FilePath& full_path); -#if defined(OS_WIN) -// Added for debugging an issue where CreateDirectory() fails. LOG(*) does -// not work, because the failure happens in a sandboxed process. -// TODO(skerner): Remove once crbug/35198 is resolved. -bool CreateDirectoryExtraLogging(const FilePath& full_path, - std::ostream& error); -#endif // defined (OS_WIN) - // Returns the file size. Returns true on success. bool GetFileSize(const FilePath& file_path, int64* file_size); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index b3ce896..61e6082 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -593,31 +593,17 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix, } bool CreateDirectory(const FilePath& full_path) { - return file_util::CreateDirectoryExtraLogging(full_path, LOG(INFO)); -} - -// TODO(skerner): Extra logging has been added to understand crbug/35198 . -// Remove it once we get a log from a user who can reproduce the issue. -bool CreateDirectoryExtraLogging(const FilePath& full_path, - std::ostream& log) { - log << "Enter CreateDirectory: full_path = " << full_path.value() - << std::endl; // If the path exists, we've succeeded if it's a directory, failed otherwise. const wchar_t* full_path_str = full_path.value().c_str(); DWORD fileattr = ::GetFileAttributes(full_path_str); - log << "::GetFileAttributes() returned " << fileattr << std::endl; - if (fileattr == INVALID_FILE_ATTRIBUTES) { - DWORD fileattr_error = GetLastError(); - log << "::GetFileAttributes() failed. GetLastError() = " - << fileattr_error << std::endl; - } else { + if (fileattr != INVALID_FILE_ATTRIBUTES) { if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0) { - log << "CreateDirectory(" << full_path_str << "), " - << "directory already exists." << std::endl; + DLOG(INFO) << "CreateDirectory(" << full_path_str << "), " + << "directory already exists."; return true; } else { - log << "CreateDirectory(" << full_path_str << "), " - << "conflicts with existing file." << std::endl; + LOG(WARNING) << "CreateDirectory(" << full_path_str << "), " + << "conflicts with existing file."; } } @@ -628,49 +614,26 @@ bool CreateDirectoryExtraLogging(const FilePath& full_path, // directories starting with the highest-level missing parent. FilePath parent_path(full_path.DirName()); if (parent_path.value() == full_path.value()) { - log << "Can't create directory: parent_path " << parent_path.value() - << " should not equal full_path " << full_path.value() - << std::endl; return false; } if (!CreateDirectory(parent_path)) { - log << "Failed to create one of the parent directories: " - << parent_path.value() << std::endl; + DLOG(WARNING) << "Failed to create one of the parent directories."; return false; } - log << "About to call ::CreateDirectory() with full_path_str = " - << full_path_str << std::endl; if (!::CreateDirectory(full_path_str, NULL)) { DWORD error_code = ::GetLastError(); - log << "CreateDirectory() gave last error " << error_code << std::endl; - - DWORD fileattr = GetFileAttributes(full_path.value().c_str()); - if (fileattr == INVALID_FILE_ATTRIBUTES) { - DWORD fileattr_error = ::GetLastError(); - log << "GetFileAttributes() failed, GetLastError() = " - << fileattr_error << std::endl; - } else { - log << "GetFileAttributes() returned " << fileattr << std::endl; - log << "Is the path a directory: " - << ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0) << std::endl; - } if (error_code == ERROR_ALREADY_EXISTS && DirectoryExists(full_path)) { // This error code doesn't indicate whether we were racing with someone // creating the same directory, or a file with the same path, therefore // we check. - log << "Race condition? Directory already exists: " - << full_path.value() << std::endl; return true; } else { - DWORD dir_exists_error = ::GetLastError(); - log << "Failed to create directory " << full_path_str << std::endl; - log << "GetLastError() for DirectoryExists() is " - << dir_exists_error << std::endl; + LOG(WARNING) << "Failed to create directory " << full_path_str + << ", last error is " << error_code << "."; return false; } } else { - log << "::CreateDirectory() succeeded." << std::endl; return true; } } diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc index f7e84ce..5091169 100644 --- a/chrome/browser/utility_process_host.cc +++ b/chrome/browser/utility_process_host.cc @@ -129,9 +129,6 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { cmd_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); } - if (browser_command_line.HasSwitch(switches::kIssue35198ExtraLogging)) - cmd_line->AppendSwitch(switches::kIssue35198ExtraLogging); - #if defined(OS_POSIX) // TODO(port): Sandbox this on Linux. Also, zygote this to work with // Linux updating. diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index f3ee9f3..3f0da98 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -678,10 +678,6 @@ const char kInternalNaCl[] = "internal-nacl"; // Runs a trusted Pepper plugin inside the renderer process. const char kInternalPepper[] = "internal-pepper"; -// The following flag allows users who can reproduce crbug/35198 -// to enable extra logging. It will be removed once the issue is fixed. -const char kIssue35198ExtraLogging[] = "issue35198-logging"; - // Specifies the flags passed to JS engine const char kJavaScriptFlags[] = "js-flags"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index e9fa031..105d522 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -197,7 +197,6 @@ extern const char kInProcessWebGL[]; extern const char kIncognito[]; extern const char kInternalNaCl[]; extern const char kInternalPepper[]; -extern const char kIssue35198ExtraLogging[]; extern const char kJavaScriptFlags[]; extern const char kKeepAliveForTest[]; extern const char kLoadExtension[]; diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index 23950c5..a758a55 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -4,7 +4,6 @@ #include "chrome/common/extensions/extension_unpacker.h" -#include "base/command_line.h" #include "base/file_util.h" #include "base/scoped_handle.h" #include "base/scoped_temp_dir.h" @@ -13,7 +12,6 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "net/base/file_stream.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/common_param_traits.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" @@ -151,33 +149,17 @@ bool ExtensionUnpacker::Run() { temp_install_dir_ = extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); + if (!file_util::CreateDirectory(temp_install_dir_)) { + #if defined(OS_WIN) - // To understand crbug/35198, allow users who can reproduce the issue - // to enable extra logging while unpacking. - bool extra_logging = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kIssue35198ExtraLogging); - LOG(INFO) << "Extra logging for issue 35198: " << extra_logging; - - std::ostringstream log_stream; - std::string dir_string = WideToUTF8(temp_install_dir_.value()); - log_stream << kCouldNotCreateDirectoryError << dir_string << std::endl; - - if (!file_util::CreateDirectoryExtraLogging(temp_install_dir_, log_stream)) { - if (extra_logging) { - log_stream.flush(); - SetError(log_stream.str()); - } else { - SetError(kCouldNotCreateDirectoryError + dir_string); - } - return false; - } + std::string dir_string = WideToUTF8(temp_install_dir_.value()); #else - if (!file_util::CreateDirectory(temp_install_dir_)) { std::string dir_string = temp_install_dir_.value(); +#endif + SetError(kCouldNotCreateDirectoryError + dir_string); return false; } -#endif if (!Unzip(extension_path_, temp_install_dir_)) { SetError(kCouldNotUnzipExtension); @@ -189,15 +171,13 @@ bool ExtensionUnpacker::Run() { if (!parsed_manifest_.get()) return false; // Error was already reported. - // NOTE: Since the Unpacker doesn't have the extension's public_id, the + // NOTE: Since the unpacker doesn't have the extension's public_id, the // InitFromValue is allowed to generate a temporary id for the extension. // ANY CODE THAT FOLLOWS SHOULD NOT DEPEND ON THE CORRECT ID OF THIS // EXTENSION. Extension extension(temp_install_dir_); std::string error; - if (!extension.InitFromValue(*parsed_manifest_, - false, - &error)) { + if (!extension.InitFromValue(*parsed_manifest_, false, &error)) { SetError(error); return false; } |