diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 21:13:14 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 21:13:14 +0000 |
commit | 61621d1f632ae1180325c25accd223921440d788 (patch) | |
tree | 568eb464f617548275d6611d6d86914c5263910c | |
parent | b097c4ffdce84568bfbf77af3038685271af1d8a (diff) | |
download | chromium_src-61621d1f632ae1180325c25accd223921440d788.zip chromium_src-61621d1f632ae1180325c25accd223921440d788.tar.gz chromium_src-61621d1f632ae1180325c25accd223921440d788.tar.bz2 |
Revert r3932 in an attempt to unbreak the tree.
Review URL: http://codereview.chromium.org/8161
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3937 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/SConscript | 6 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 74 | ||||
-rw-r--r-- | chrome/common/logging_chrome.cc | 29 |
3 files changed, 33 insertions, 76 deletions
diff --git a/chrome/common/SConscript b/chrome/common/SConscript index edbbfbb..52c9e0e 100644 --- a/chrome/common/SConscript +++ b/chrome/common/SConscript @@ -54,7 +54,6 @@ if env['PLATFORM'] in ('posix', 'win32'): 'animation.cc', 'chrome_constants.cc', 'chrome_counters.cc', - 'chrome_paths.cc', 'chrome_switches.cc', 'debug_flags.cc', 'env_vars.cc', @@ -63,9 +62,7 @@ if env['PLATFORM'] in ('posix', 'win32'): 'jpeg_codec.cc', 'json_value_serializer.cc', 'libxml_utils.cc', - 'logging_chrome.cc', 'net/cookie_monster_sqlite.cc', - 'notification_registrar.cc', 'notification_service.cc', 'pref_member.cc', 'pref_names.cc', @@ -82,6 +79,7 @@ if env['PLATFORM'] == 'win32': # TODO(port): Port these. input_files.extend([ 'child_process.cc', + 'chrome_paths.cc', 'chrome_plugin_lib.cc', 'chrome_plugin_util.cc', 'chrome_process_filter.cc', @@ -103,8 +101,10 @@ if env['PLATFORM'] == 'win32': 'ipc_sync_message.cc', 'jstemplate_builder.cc', 'l10n_util.cc', + 'logging_chrome.cc', 'message_router.cc', 'net/url_request_intercept_job.cc', + 'notification_registrar.cc', 'os_exchange_data.cc', 'plugin_messages.cc', 'pref_service.cc', diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index 71b3d3d..9d6da38 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -2,30 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" - -#if defined(OS_WIN) #include <windows.h> #include <shellapi.h> #include <shlobj.h> -#endif #include "chrome/common/chrome_paths.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/path_service.h" -#include "base/sys_info.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" namespace chrome { +bool GetUserDirectory(int directory_type, std::wstring* result) { + wchar_t path_buf[MAX_PATH]; + if (FAILED(SHGetFolderPath(NULL, directory_type, NULL, + SHGFP_TYPE_CURRENT, path_buf))) + return false; + result->assign(path_buf); + return true; +} + // Gets the default user data directory, regardless of whether // DIR_USER_DATA has been overridden by a command-line option. bool GetDefaultUserDataDirectory(std::wstring* result) { -#if defined(OS_WIN) if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) return false; #if defined(GOOGLE_CHROME_BUILD) @@ -34,11 +36,6 @@ bool GetDefaultUserDataDirectory(std::wstring* result) { file_util::AppendToPath(result, chrome::kBrowserAppName); file_util::AppendToPath(result, chrome::kUserDataDirname); return true; -#else // defined(OS_WIN) - // TODO(port): Decide what to do on other platforms. - NOTIMPLEMENTED(); - return false; -#endif // defined(OS_WIN) } bool GetGearsPluginPathFromCommandLine(std::wstring *path) { @@ -67,6 +64,14 @@ bool PathProvider(int key, std::wstring* result) { return PathService::Get(base::FILE_MODULE, result); } + // We need to go compute the value. It would be nice to support paths with + // names longer than MAX_PATH, but the system functions don't seem to be + // designed for it either, with the exception of GetTempPath (but other + // things will surely break if the temp path is too long, so we don't bother + // handling it. + wchar_t system_buffer[MAX_PATH]; + system_buffer[0] = 0; + // Assume that we will need to create the directory if it does not already // exist. This flag can be set to true to prevent checking. bool exists = false; @@ -78,20 +83,8 @@ bool PathProvider(int key, std::wstring* result) { return false; break; case chrome::DIR_USER_DOCUMENTS: -#if defined(OS_WIN) - { - wchar_t path_buf[MAX_PATH]; - if (FAILED(SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, - SHGFP_TYPE_CURRENT, path_buf))) - return false; - cur.assign(path_buf); - } -#else - // TODO(port): Get the path (possibly using xdg-user-dirs) - // or decide we don't need it on other platforms. - NOTIMPLEMENTED(); - return false; -#endif + if (!GetUserDirectory(CSIDL_MYDOCUMENTS, &cur)) + return false; break; case chrome::DIR_CRASH_DUMPS: // The crash reports are always stored relative to the default user data @@ -103,26 +96,10 @@ bool PathProvider(int key, std::wstring* result) { file_util::AppendToPath(&cur, L"Crash Reports"); break; case chrome::DIR_USER_DESKTOP: -#if defined(OS_WIN) - { - // We need to go compute the value. It would be nice to support paths - // with names longer than MAX_PATH, but the system functions don't seem - // to be designed for it either, with the exception of GetTempPath - // (but other things will surely break if the temp path is too long, - // so we don't bother handling it. - wchar_t system_buffer[MAX_PATH]; - system_buffer[0] = 0; - if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, - SHGFP_TYPE_CURRENT, system_buffer))) - return false; - cur.assign(system_buffer); - } -#else - // TODO(port): Get the path (possibly using xdg-user-dirs) - // or decide we don't need it on other platforms. - NOTIMPLEMENTED(); - return false; -#endif + if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, + SHGFP_TYPE_CURRENT, system_buffer))) + return false; + cur = system_buffer; exists = true; break; case chrome::DIR_RESOURCES: @@ -154,12 +131,7 @@ bool PathProvider(int key, std::wstring* result) { break; case chrome::DIR_USER_SCRIPTS: // TODO(aa): Figure out where the script directory should live. -#if defined(OS_WIN) cur = L"C:\\SCRIPTS\\"; -#else - NOTIMPLEMENTED(); - return false; -#endif exists = true; // don't trigger directory creation code break; case chrome::FILE_LOCAL_STATE: diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index e3ec737..af6b647 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -2,11 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" - -#if defined(OS_WIN) #include <windows.h> -#endif #include <iostream> #include <fstream> @@ -14,7 +10,6 @@ #include "chrome/common/logging_chrome.h" #include "base/command_line.h" -#include "base/debug_util.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" @@ -36,7 +31,7 @@ static bool chrome_logging_initialized_ = false; // with that error in the str parameter. #pragma optimize("", off) static void SilentRuntimeAssertHandler(const std::string& str) { - DebugUtil::BreakDebugger(); + __debugbreak(); } #pragma optimize("", on) @@ -48,7 +43,6 @@ static void SuppressDialogs() { logging::SetLogAssertHandler(SilentRuntimeAssertHandler); -#if defined(OS_WIN) UINT new_flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; @@ -56,7 +50,6 @@ static void SuppressDialogs() { // Preserve existing error mode, as discussed at http://t/dmea UINT existing_flags = SetErrorMode(new_flags); SetErrorMode(existing_flags | new_flags); -#endif dialogs_are_suppressed_ = true; } @@ -91,13 +84,7 @@ void InitChromeLogging(const CommandLine& command_line, log_mode = logging::LOG_NONE; } -#if defined(OS_POSIX) - const char* log_file_name = WideToUTF8(GetLogFileName()).c_str(); -#elif defined(OS_WIN) - const wchar_t* log_file_name = GetLogFileName().c_str(); -#endif - - logging::InitLogging(log_file_name, + logging::InitLogging(GetLogFileName().c_str(), log_mode, logging::LOCK_LOG_FILE, delete_old_log_file); @@ -143,9 +130,11 @@ void CleanupChromeLogging() { } std::wstring GetLogFileName() { - std::wstring filename = base::SysInfo::GetEnvVar(env_vars::kLogFileName); - if (filename != L"") - return filename; + wchar_t filename[MAX_PATH]; + unsigned status = GetEnvironmentVariable(env_vars::kLogFileName, + filename, MAX_PATH); + if (status && (status <= MAX_PATH)) + return std::wstring(filename); const std::wstring log_filename(L"chrome_debug.log"); std::wstring log_path; @@ -171,11 +160,7 @@ size_t GetFatalAssertions(AssertionList* assertions) { size_t assertion_count = 0; std::ifstream log_file; -#if defined(OS_WIN) log_file.open(GetLogFileName().c_str()); -#elif defined(OS_POSIX) - log_file.open(WideToUTF8(GetLogFileName()).c_str()); -#endif if (!log_file.is_open()) return 0; |