summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/child_process_logging.h2
-rw-r--r--chrome/common/chrome_paths.cc2
-rw-r--r--chrome/common/multi_process_lock.h7
-rw-r--r--chrome/common/multi_process_lock_linux.cc23
-rw-r--r--chrome/common/multi_process_lock_mac.cc6
-rw-r--r--chrome/common/multi_process_lock_unittest.cc24
-rw-r--r--chrome/common/multi_process_lock_win.cc4
-rw-r--r--chrome/common/url_constants.cc2
-rw-r--r--chrome/common/url_constants.h2
9 files changed, 40 insertions, 32 deletions
diff --git a/chrome/common/child_process_logging.h b/chrome/common/child_process_logging.h
index 8b5a733..b5894f0 100644
--- a/chrome/common/child_process_logging.h
+++ b/chrome/common/child_process_logging.h
@@ -33,7 +33,7 @@ static const size_t kMaxSwitches = 15;
namespace child_process_logging {
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
// These are declared here so the crash reporter can access them directly in
// compromised context without going through the standard library.
extern char g_active_url[];
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index ed27d7a..77d8d38 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -305,7 +305,7 @@ bool PathProvider(int key, FilePath* result) {
if (!file_util::PathExists(cur)) // We don't want to create this
return false;
break;
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
case chrome::DIR_POLICY_FILES: {
#if defined(GOOGLE_CHROME_BUILD)
cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies"));
diff --git a/chrome/common/multi_process_lock.h b/chrome/common/multi_process_lock.h
index 24754f5..8116e84 100644
--- a/chrome/common/multi_process_lock.h
+++ b/chrome/common/multi_process_lock.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,11 +15,6 @@
class MultiProcessLock {
public:
- // The length of a multi-process lock name is limited on Linux, so
- // it is limited it on all platforms for consistency. This length does
- // not include a terminator.
- static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 106;
-
// Factory method for creating a multi-process lock.
// |name| is the name of the lock. The name has special meaning on Windows
// where the prefix can determine the namespace of the lock.
diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc
index c5b70a4..f610237 100644
--- a/chrome/common/multi_process_lock_linux.cc
+++ b/chrome/common/multi_process_lock_linux.cc
@@ -24,33 +24,30 @@ class MultiProcessLockLinux : public MultiProcessLock {
}
virtual bool TryLock() {
+ struct sockaddr_un address;
+
+ // +1 for terminator, +1 for 0 in position 0 that makes it an
+ // abstract named socket.
+ const size_t max_len = sizeof(address.sun_path) - 2;
+
if (fd_ != -1) {
DLOG(ERROR) << "MultiProcessLock is already locked - " << name_;
return true;
}
- if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) {
+ if (name_.length() > max_len) {
LOG(ERROR) << "Socket name too long (" << name_.length()
- << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_;
+ << " > " << max_len << ") - " << name_;
return false;
}
- struct sockaddr_un address;
-
- // +1 for terminator, +1 for 0 in position 0 that makes it an
- // abstract named socket.
- // If this assert fails it is because sockaddr_un.sun_path size has been
- // redefined and MULTI_PROCESS_LOCK_NAME_MAX_LEN can change accordingly.
- COMPILE_ASSERT(sizeof(address.sun_path)
- == MULTI_PROCESS_LOCK_NAME_MAX_LEN + 2, sun_path_size_changed);
-
memset(&address, 0, sizeof(address));
int print_length = snprintf(&address.sun_path[1],
- MULTI_PROCESS_LOCK_NAME_MAX_LEN + 1,
+ max_len + 1,
"%s", name_.c_str());
if (print_length < 0 ||
- print_length > static_cast<int>(MULTI_PROCESS_LOCK_NAME_MAX_LEN)) {
+ print_length > static_cast<int>(max_len)) {
PLOG(ERROR) << "Couldn't create sun_path - " << name_;
return false;
}
diff --git a/chrome/common/multi_process_lock_mac.cc b/chrome/common/multi_process_lock_mac.cc
index 9a9cbe21..8a05b94 100644
--- a/chrome/common/multi_process_lock_mac.cc
+++ b/chrome/common/multi_process_lock_mac.cc
@@ -8,6 +8,8 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
+#include <servers/bootstrap.h>
+
class MultiProcessLockMac : public MultiProcessLock {
public:
explicit MultiProcessLockMac(const std::string& name) : name_(name) { }
@@ -24,9 +26,9 @@ class MultiProcessLockMac : public MultiProcessLock {
return true;
}
- if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) {
+ if (name_.length() >= BOOTSTRAP_MAX_NAME_LEN) {
LOG(ERROR) << "Socket name too long (" << name_.length()
- << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_;
+ << " >= " << BOOTSTRAP_MAX_NAME_LEN << ") - " << name_;
return false;
}
diff --git a/chrome/common/multi_process_lock_unittest.cc b/chrome/common/multi_process_lock_unittest.cc
index e1408ee..30c4d7b 100644
--- a/chrome/common/multi_process_lock_unittest.cc
+++ b/chrome/common/multi_process_lock_unittest.cc
@@ -77,13 +77,27 @@ TEST_F(MultiProcessLockTest, BasicCreationTest) {
}
TEST_F(MultiProcessLockTest, LongNameTest) {
- // Linux has a max path name of 108 characters.
- // http://lxr.linux.no/linux+v2.6.36/include/linux/un.h
- // This is enforced on all platforms.
+ // Every platform has has it's own max path name size,
+ // so different checks are needed for them.
+ // POSIX: sizeof(address.sun_path) - 2
+ // Mac OS X: BOOTSTRAP_MAX_NAME_LEN
+ // Windows: MAX_PATH
LOG(INFO) << "Following error log due to long name is expected";
+#if defined(OS_MACOSX)
+ std::string name("This is a name that is longer than one hundred and "
+ "twenty-eight characters to make sure that we fail appropriately on "
+ "Mac OS X when we have a path that is too long for Mac OS X to handle");
+#elif defined(OS_POSIX)
std::string name("This is a name that is longer than one hundred and eight "
- "characters to make sure that we fail appropriately on linux when we "
- "have a path that is to long for linux to handle");
+ "characters to make sure that we fail appropriately on POSIX systems "
+ "when we have a path that is too long for the system to handle");
+#elif defined(OS_WIN)
+ std::string name("This is a name that is longer than two hundred and sixty "
+ "characters to make sure that we fail appropriately on Windows when we "
+ "have a path that is too long for Windows to handle "
+ "This limitation comes from the MAX_PATH definition which is obviously "
+ "defined to be a maximum of two hundred and sixty characters ");
+#endif
scoped_ptr<MultiProcessLock> test_lock(MultiProcessLock::Create(name));
EXPECT_FALSE(test_lock->TryLock());
}
diff --git a/chrome/common/multi_process_lock_win.cc b/chrome/common/multi_process_lock_win.cc
index b668f78..d35258e 100644
--- a/chrome/common/multi_process_lock_win.cc
+++ b/chrome/common/multi_process_lock_win.cc
@@ -24,9 +24,9 @@ class MultiProcessLockWin : public MultiProcessLock {
return true;
}
- if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) {
+ if (name_.length() >= MAX_PATH) {
LOG(ERROR) << "Socket name too long (" << name_.length()
- << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_;
+ << " >= " << MAX_PATH << ") - " << name_;
return false;
}
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 6092537..1a742ba 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -189,7 +189,7 @@ const char kChromeUIWorkersHost[] = "workers";
const char kChromeUIScreenshotPath[] = "screenshots";
const char kChromeUIThemePath[] = "theme";
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
const char kChromeUILinuxProxyConfigHost[] = "linux-proxy-config";
const char kChromeUISandboxHost[] = "sandbox";
#endif
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index 0e896d5..3dc7163 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -181,7 +181,7 @@ extern const char kChromeUIWorkersHost[];
extern const char kChromeUIScreenshotPath[];
extern const char kChromeUIThemePath[];
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
extern const char kChromeUILinuxProxyConfigHost[];
extern const char kChromeUISandboxHost[];
#endif