summaryrefslogtreecommitdiff
path: root/chromium/base
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-11-21 14:09:57 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-11-29 15:14:36 +0100
commiteb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch)
tree2c7c940e1dbee81b89d935626110816b494aa32c /chromium/base
parent9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff)
downloadqtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/base')
-rw-r--r--chromium/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java11
-rw-r--r--chromium/base/base.gypi7
-rw-r--r--chromium/base/debug/crash_logging.h5
-rw-r--r--chromium/base/debug/trace_event_unittest.cc2
-rw-r--r--chromium/base/file_util_unittest.cc235
-rw-r--r--chromium/base/files/file_enumerator_win.cc6
-rw-r--r--chromium/base/os_compat_android.cc3
-rw-r--r--chromium/base/posix/file_descriptor_shuffle.h2
-rw-r--r--chromium/base/synchronization/lock_impl_posix.cc17
-rw-r--r--chromium/base/time/time_posix.cc51
-rw-r--r--chromium/base/time/time_unittest.cc24
-rw-r--r--chromium/base/values.cc2
-rw-r--r--chromium/base/values.h2
-rw-r--r--chromium/base/win/scoped_handle.h2
14 files changed, 188 insertions, 181 deletions
diff --git a/chromium/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/chromium/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
index 8c4ac0fe01b..eb33091cfe1 100644
--- a/chromium/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
+++ b/chromium/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
@@ -56,17 +56,6 @@ public class ApiCompatibilityUtils {
}
/**
- * @see android.view.ViewGroup.MarginLayoutParams#getMarginEnd()
- */
- public static int getMarginEnd(MarginLayoutParams layoutParams) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- return layoutParams.getMarginEnd();
- } else {
- return layoutParams.rightMargin;
- }
- }
-
- /**
* @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int)
*/
public static void setMarginStart(MarginLayoutParams layoutParams, int start) {
diff --git a/chromium/base/base.gypi b/chromium/base/base.gypi
index 6d82ee335b9..6dd8bf67eb4 100644
--- a/chromium/base/base.gypi
+++ b/chromium/base/base.gypi
@@ -757,6 +757,13 @@
['include', '^threading/platform_thread_linux\\.cc$'],
],
}],
+ ['OS == "android" and <(android_webview_build)==1', {
+ 'defines': [
+ # WebView builds as part of the system which already has sincos;
+ # avoid defining it again as it causes a linker warning.
+ 'ANDROID_SINCOS_PROVIDED',
+ ],
+ }],
['OS == "ios" and _toolset != "host"', {
'sources/': [
# Pull in specific Mac files for iOS (which have been filtered out
diff --git a/chromium/base/debug/crash_logging.h b/chromium/base/debug/crash_logging.h
index 376d0116553..d6ffa912ee6 100644
--- a/chromium/base/debug/crash_logging.h
+++ b/chromium/base/debug/crash_logging.h
@@ -23,8 +23,7 @@ namespace debug {
class StackTrace;
-// Set or clear a specific key-value pair from the crash metadata. Keys and
-// values are terminated at the null byte.
+// Set or clear a specific key-value pair from the crash metadata.
BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key,
const base::StringPiece& value);
BASE_EXPORT void ClearCrashKey(const base::StringPiece& key);
@@ -76,8 +75,6 @@ BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count,
// Returns the correspnding crash key object or NULL for a given key.
BASE_EXPORT const CrashKey* LookupCrashKey(const base::StringPiece& key);
-// In the platform crash reporting implementation, these functions set and
-// clear the NUL-termianted key-value pairs.
typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&,
const base::StringPiece&);
typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&);
diff --git a/chromium/base/debug/trace_event_unittest.cc b/chromium/base/debug/trace_event_unittest.cc
index b5909845f27..ea295c05dba 100644
--- a/chromium/base/debug/trace_event_unittest.cc
+++ b/chromium/base/debug/trace_event_unittest.cc
@@ -54,7 +54,7 @@ class TraceEventTestFixture : public testing::Test {
void OnTraceNotification(int notification) {
if (notification & TraceLog::EVENT_WATCH_NOTIFICATION)
++event_watch_notification_;
- notifications_received_ |= notification;
+ notifications_received_ |= notification;
}
DictionaryValue* FindMatchingTraceEntry(const JsonKeyValue* key_values);
DictionaryValue* FindNamePhase(const char* name, const char* phase);
diff --git a/chromium/base/file_util_unittest.cc b/chromium/base/file_util_unittest.cc
index 787b6d50ba7..e523920431f 100644
--- a/chromium/base/file_util_unittest.cc
+++ b/chromium/base/file_util_unittest.cc
@@ -30,7 +30,6 @@
#if defined(OS_WIN)
#include "base/win/scoped_handle.h"
-#include "base/win/windows_version.h"
#endif
// This macro helps avoid wrapped lines in the test structs.
@@ -117,36 +116,6 @@ bool DeleteReparsePoint(HANDLE source) {
}
return true;
}
-
-// Manages a reparse point for a test.
-class ReparsePoint {
- public:
- // Creates a reparse point from |source| (an empty directory) to |target|.
- ReparsePoint(const FilePath& source, const FilePath& target) {
- dir_.Set(
- ::CreateFile(source.value().c_str(),
- FILE_ALL_ACCESS,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
- NULL));
- created_ = dir_.IsValid() && SetReparsePoint(dir_, target);
- }
-
- ~ReparsePoint() {
- if (created_)
- DeleteReparsePoint(dir_);
- }
-
- bool IsValid() { return created_; }
-
- private:
- base::win::ScopedHandle dir_;
- bool created_;
- DISALLOW_COPY_AND_ASSIGN(ReparsePoint);
-};
-
#endif
#if defined(OS_POSIX)
@@ -462,61 +431,86 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {
FilePath to_sub_a = base_b.Append(FPL("to_sub_a"));
ASSERT_TRUE(file_util::CreateDirectory(to_sub_a));
- FilePath normalized_path;
- {
- ReparsePoint reparse_to_sub_a(to_sub_a, sub_a);
- ASSERT_TRUE(reparse_to_sub_a.IsValid());
-
- FilePath to_base_b = base_b.Append(FPL("to_base_b"));
- ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
- ReparsePoint reparse_to_base_b(to_base_b, base_b);
- ASSERT_TRUE(reparse_to_base_b.IsValid());
-
- FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
- ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
- ReparsePoint reparse_to_sub_long(to_sub_long, sub_long);
- ASSERT_TRUE(reparse_to_sub_long.IsValid());
-
- // Normalize a junction free path: base_a\sub_a\file.txt .
- ASSERT_TRUE(file_util::NormalizeFilePath(file_txt, &normalized_path));
- ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
-
- // Check that the path base_b\to_sub_a\file.txt can be normalized to exclude
- // the junction to_sub_a.
- ASSERT_TRUE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")),
- &normalized_path));
- ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
-
- // Check that the path base_b\to_base_b\to_base_b\to_sub_a\file.txt can be
- // normalized to exclude junctions to_base_b and to_sub_a .
- ASSERT_TRUE(file_util::NormalizeFilePath(base_b.Append(FPL("to_base_b"))
- .Append(FPL("to_base_b"))
- .Append(FPL("to_sub_a"))
- .Append(FPL("file.txt")),
- &normalized_path));
- ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
-
- // A long enough path will cause NormalizeFilePath() to fail. Make a long
- // path using to_base_b many times, and check that paths long enough to fail
- // do not cause a crash.
- FilePath long_path = base_b;
- const int kLengthLimit = MAX_PATH + 200;
- while (long_path.value().length() <= kLengthLimit) {
- long_path = long_path.Append(FPL("to_base_b"));
- }
- long_path = long_path.Append(FPL("to_sub_a"))
- .Append(FPL("file.txt"));
+ base::win::ScopedHandle reparse_to_sub_a(
+ ::CreateFile(to_sub_a.value().c_str(),
+ FILE_ALL_ACCESS,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
+ NULL));
+ ASSERT_TRUE(reparse_to_sub_a.IsValid());
+ ASSERT_TRUE(SetReparsePoint(reparse_to_sub_a, sub_a));
- ASSERT_FALSE(file_util::NormalizeFilePath(long_path, &normalized_path));
+ FilePath to_base_b = base_b.Append(FPL("to_base_b"));
+ ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
+ base::win::ScopedHandle reparse_to_base_b(
+ ::CreateFile(to_base_b.value().c_str(),
+ FILE_ALL_ACCESS,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
+ NULL));
+ ASSERT_TRUE(reparse_to_base_b.IsValid());
+ ASSERT_TRUE(SetReparsePoint(reparse_to_base_b, base_b));
- // Normalizing the junction to deep.txt should fail, because the expanded
- // path to deep.txt is longer than MAX_PATH.
- ASSERT_FALSE(file_util::NormalizeFilePath(to_sub_long.Append(deep_txt),
- &normalized_path));
+ FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
+ ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
+ base::win::ScopedHandle reparse_to_sub_long(
+ ::CreateFile(to_sub_long.value().c_str(),
+ FILE_ALL_ACCESS,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
+ NULL));
+ ASSERT_TRUE(reparse_to_sub_long.IsValid());
+ ASSERT_TRUE(SetReparsePoint(reparse_to_sub_long, sub_long));
- // Delete the reparse points, and see that NormalizeFilePath() fails
- // to traverse them.
+ // Normalize a junction free path: base_a\sub_a\file.txt .
+ FilePath normalized_path;
+ ASSERT_TRUE(file_util::NormalizeFilePath(file_txt, &normalized_path));
+ ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
+
+ // Check that the path base_b\to_sub_a\file.txt can be normalized to exclude
+ // the junction to_sub_a.
+ ASSERT_TRUE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")),
+ &normalized_path));
+ ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
+
+ // Check that the path base_b\to_base_b\to_base_b\to_sub_a\file.txt can be
+ // normalized to exclude junctions to_base_b and to_sub_a .
+ ASSERT_TRUE(file_util::NormalizeFilePath(base_b.Append(FPL("to_base_b"))
+ .Append(FPL("to_base_b"))
+ .Append(FPL("to_sub_a"))
+ .Append(FPL("file.txt")),
+ &normalized_path));
+ ASSERT_STREQ(file_txt.value().c_str(), normalized_path.value().c_str());
+
+ // A long enough path will cause NormalizeFilePath() to fail. Make a long
+ // path using to_base_b many times, and check that paths long enough to fail
+ // do not cause a crash.
+ FilePath long_path = base_b;
+ const int kLengthLimit = MAX_PATH + 200;
+ while (long_path.value().length() <= kLengthLimit) {
+ long_path = long_path.Append(FPL("to_base_b"));
}
+ long_path = long_path.Append(FPL("to_sub_a"))
+ .Append(FPL("file.txt"));
+
+ ASSERT_FALSE(file_util::NormalizeFilePath(long_path, &normalized_path));
+
+ // Normalizing the junction to deep.txt should fail, because the expanded
+ // path to deep.txt is longer than MAX_PATH.
+ ASSERT_FALSE(file_util::NormalizeFilePath(to_sub_long.Append(deep_txt),
+ &normalized_path));
+
+ // Delete the reparse points, and see that NormalizeFilePath() fails
+ // to traverse them.
+ ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_a));
+ ASSERT_TRUE(DeleteReparsePoint(reparse_to_base_b));
+ ASSERT_TRUE(DeleteReparsePoint(reparse_to_sub_long));
ASSERT_FALSE(file_util::NormalizeFilePath(to_sub_a.Append(FPL("file.txt")),
&normalized_path));
@@ -1827,35 +1821,36 @@ TEST_F(FileUtilTest, DetectDirectoryTest) {
TEST_F(FileUtilTest, FileEnumeratorTest) {
// Test an empty directory.
FileEnumerator f0(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
- EXPECT_EQ(f0.Next().value(), FPL(""));
- EXPECT_EQ(f0.Next().value(), FPL(""));
+ EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
+ EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
// Test an empty directory, non-recursively, including "..".
FileEnumerator f0_dotdot(temp_dir_.path(), false,
FILES_AND_DIRECTORIES | FileEnumerator::INCLUDE_DOT_DOT);
- EXPECT_EQ(temp_dir_.path().Append(FPL("..")).value(),
+ EXPECT_EQ(temp_dir_.path().Append(FILE_PATH_LITERAL("..")).value(),
+ f0_dotdot.Next().value());
+ EXPECT_EQ(FILE_PATH_LITERAL(""),
f0_dotdot.Next().value());
- EXPECT_EQ(FPL(""), f0_dotdot.Next().value());
// create the directories
- FilePath dir1 = temp_dir_.path().Append(FPL("dir1"));
+ FilePath dir1 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir1"));
EXPECT_TRUE(file_util::CreateDirectory(dir1));
- FilePath dir2 = temp_dir_.path().Append(FPL("dir2"));
+ FilePath dir2 = temp_dir_.path().Append(FILE_PATH_LITERAL("dir2"));
EXPECT_TRUE(file_util::CreateDirectory(dir2));
- FilePath dir2inner = dir2.Append(FPL("inner"));
+ FilePath dir2inner = dir2.Append(FILE_PATH_LITERAL("inner"));
EXPECT_TRUE(file_util::CreateDirectory(dir2inner));
// create the files
- FilePath dir2file = dir2.Append(FPL("dir2file.txt"));
+ FilePath dir2file = dir2.Append(FILE_PATH_LITERAL("dir2file.txt"));
CreateTextFile(dir2file, std::wstring());
- FilePath dir2innerfile = dir2inner.Append(FPL("innerfile.txt"));
+ FilePath dir2innerfile = dir2inner.Append(FILE_PATH_LITERAL("innerfile.txt"));
CreateTextFile(dir2innerfile, std::wstring());
- FilePath file1 = temp_dir_.path().Append(FPL("file1.txt"));
+ FilePath file1 = temp_dir_.path().Append(FILE_PATH_LITERAL("file1.txt"));
CreateTextFile(file1, std::wstring());
FilePath file2_rel = dir2.Append(FilePath::kParentDirectory)
- .Append(FPL("file2.txt"));
+ .Append(FILE_PATH_LITERAL("file2.txt"));
CreateTextFile(file2_rel, std::wstring());
- FilePath file2_abs = temp_dir_.path().Append(FPL("file2.txt"));
+ FilePath file2_abs = temp_dir_.path().Append(FILE_PATH_LITERAL("file2.txt"));
// Only enumerate files.
FileEnumerator f1(temp_dir_.path(), true, FileEnumerator::FILES);
@@ -1889,7 +1884,8 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
FindResultCollector c2_dotdot(f2_dotdot);
EXPECT_TRUE(c2_dotdot.HasFile(dir1));
EXPECT_TRUE(c2_dotdot.HasFile(dir2));
- EXPECT_TRUE(c2_dotdot.HasFile(temp_dir_.path().Append(FPL(".."))));
+ EXPECT_TRUE(c2_dotdot.HasFile(
+ temp_dir_.path().Append(FILE_PATH_LITERAL(".."))));
EXPECT_EQ(c2_dotdot.size(), 3);
// Enumerate files and directories.
@@ -1914,7 +1910,8 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c4.size(), 4);
// Enumerate with a pattern.
- FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES, FPL("dir*"));
+ FileEnumerator f5(temp_dir_.path(), true, FILES_AND_DIRECTORIES,
+ FILE_PATH_LITERAL("dir*"));
FindResultCollector c5(f5);
EXPECT_TRUE(c5.HasFile(dir1));
EXPECT_TRUE(c5.HasFile(dir2));
@@ -1923,52 +1920,10 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_TRUE(c5.HasFile(dir2innerfile));
EXPECT_EQ(c5.size(), 5);
-#if defined(OS_WIN)
- {
- // Make dir1 point to dir2.
- ReparsePoint reparse_point(dir1, dir2);
- EXPECT_TRUE(reparse_point.IsValid());
-
- if ((base::win::GetVersion() >= base::win::VERSION_VISTA)) {
- // There can be a delay for the enumeration code to see the change on
- // the file system so skip this test for XP.
- // Enumerate the reparse point.
- FileEnumerator f6(dir1, true, FILES_AND_DIRECTORIES);
- FindResultCollector c6(f6);
- FilePath inner2 = dir1.Append(FPL("inner"));
- EXPECT_TRUE(c6.HasFile(inner2));
- EXPECT_TRUE(c6.HasFile(inner2.Append(FPL("innerfile.txt"))));
- EXPECT_TRUE(c6.HasFile(dir1.Append(FPL("dir2file.txt"))));
- EXPECT_EQ(c6.size(), 3);
- }
-
- // No changes for non recursive operation.
- FileEnumerator f7(temp_dir_.path(), false, FILES_AND_DIRECTORIES);
- FindResultCollector c7(f7);
- EXPECT_TRUE(c7.HasFile(dir2));
- EXPECT_TRUE(c7.HasFile(dir2));
- EXPECT_TRUE(c7.HasFile(file1));
- EXPECT_TRUE(c7.HasFile(file2_abs));
- EXPECT_EQ(c7.size(), 4);
-
- // Should not enumerate inside dir1 when using recursion.
- FileEnumerator f8(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
- FindResultCollector c8(f8);
- EXPECT_TRUE(c8.HasFile(dir1));
- EXPECT_TRUE(c8.HasFile(dir2));
- EXPECT_TRUE(c8.HasFile(file1));
- EXPECT_TRUE(c8.HasFile(file2_abs));
- EXPECT_TRUE(c8.HasFile(dir2file));
- EXPECT_TRUE(c8.HasFile(dir2inner));
- EXPECT_TRUE(c8.HasFile(dir2innerfile));
- EXPECT_EQ(c8.size(), 7);
- }
-#endif
-
// Make sure the destructor closes the find handle while in the middle of a
// query to allow TearDown to delete the directory.
- FileEnumerator f9(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
- EXPECT_FALSE(f9.Next().value().empty()); // Should have found something
+ FileEnumerator f6(temp_dir_.path(), true, FILES_AND_DIRECTORIES);
+ EXPECT_FALSE(f6.Next().value().empty()); // Should have found something
// (we don't care what).
}
diff --git a/chromium/base/files/file_enumerator_win.cc b/chromium/base/files/file_enumerator_win.cc
index e47f5421a71..64c98455ce5 100644
--- a/chromium/base/files/file_enumerator_win.cc
+++ b/chromium/base/files/file_enumerator_win.cc
@@ -133,10 +133,8 @@ FilePath FileEnumerator::Next() {
if (recursive_) {
// If |cur_file| is a directory, and we are doing recursive searching,
// add it to pending_paths_ so we scan it after we finish scanning this
- // directory. However, don't do recursion through reparse points or we
- // may end up with an infinite cycle.
- if (!(find_data_.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
- pending_paths_.push(cur_file);
+ // directory.
+ pending_paths_.push(cur_file);
}
if (file_type_ & FileEnumerator::DIRECTORIES)
return cur_file;
diff --git a/chromium/base/os_compat_android.cc b/chromium/base/os_compat_android.cc
index 2643dc30e1e..ec221e480dc 100644
--- a/chromium/base/os_compat_android.cc
+++ b/chromium/base/os_compat_android.cc
@@ -75,7 +75,8 @@ time_t timegm(struct tm* const t) {
// for each function would simply end up calling itself, resulting in a
// runtime crash due to stack overflow.
//
-#if defined(__GNUC__) && !defined(__clang__)
+#if defined(__GNUC__) && !defined(__clang__) && \
+ !defined(ANDROID_SINCOS_PROVIDED)
// For the record, Clang does not support the 'optimize' attribute.
// In the unlikely event that it begins performing this optimization too,
diff --git a/chromium/base/posix/file_descriptor_shuffle.h b/chromium/base/posix/file_descriptor_shuffle.h
index 9cd918f2e15..6888c3e5237 100644
--- a/chromium/base/posix/file_descriptor_shuffle.h
+++ b/chromium/base/posix/file_descriptor_shuffle.h
@@ -47,7 +47,7 @@ class InjectionDelegate {
// An implementation of the InjectionDelegate interface using the file
// descriptor table of the current process as the domain.
-class BASE_EXPORT FileDescriptorTableInjection : public InjectionDelegate {
+class FileDescriptorTableInjection : public InjectionDelegate {
virtual bool Duplicate(int* result, int fd) OVERRIDE;
virtual bool Move(int src, int dest) OVERRIDE;
virtual void Close(int fd) OVERRIDE;
diff --git a/chromium/base/synchronization/lock_impl_posix.cc b/chromium/base/synchronization/lock_impl_posix.cc
index 86158767ea9..f638fcd321c 100644
--- a/chromium/base/synchronization/lock_impl_posix.cc
+++ b/chromium/base/synchronization/lock_impl_posix.cc
@@ -5,7 +5,6 @@
#include "base/synchronization/lock_impl.h"
#include <errno.h>
-#include <string.h>
#include "base/logging.h"
@@ -17,13 +16,13 @@ LockImpl::LockImpl() {
// In debug, setup attributes for lock error checking.
pthread_mutexattr_t mta;
int rv = pthread_mutexattr_init(&mta);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
rv = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_ERRORCHECK);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
rv = pthread_mutex_init(&os_lock_, &mta);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
rv = pthread_mutexattr_destroy(&mta);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
#else
// In release, go with the default lock attributes.
pthread_mutex_init(&os_lock_, NULL);
@@ -32,23 +31,23 @@ LockImpl::LockImpl() {
LockImpl::~LockImpl() {
int rv = pthread_mutex_destroy(&os_lock_);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
}
bool LockImpl::Try() {
int rv = pthread_mutex_trylock(&os_lock_);
- DCHECK(rv == 0 || rv == EBUSY) << ". " << strerror(rv);
+ DCHECK(rv == 0 || rv == EBUSY);
return rv == 0;
}
void LockImpl::Lock() {
int rv = pthread_mutex_lock(&os_lock_);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
}
void LockImpl::Unlock() {
int rv = pthread_mutex_unlock(&os_lock_);
- DCHECK_EQ(rv, 0) << ". " << strerror(rv);
+ DCHECK_EQ(rv, 0);
}
} // namespace internal
diff --git a/chromium/base/time/time_posix.cc b/chromium/base/time/time_posix.cc
index 16eb83c59a9..69e80e10c60 100644
--- a/chromium/base/time/time_posix.cc
+++ b/chromium/base/time/time_posix.cc
@@ -211,9 +211,41 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore
#endif
- SysTime seconds = SysTimeFromTimeStruct(&timestruct, is_local);
int64 milliseconds;
+ SysTime seconds;
+
+ // Certain exploded dates do not really exist due to daylight saving times,
+ // and this causes mktime() to return implementation-defined values when
+ // tm_isdst is set to -1. On Android, the function will return -1, while the
+ // C libraries of other platforms typically return a liberally-chosen value.
+ // Handling this requires the special code below.
+
+ // SysTimeFromTimeStruct() modifies the input structure, save current value.
+ struct tm timestruct0 = timestruct;
+
+ seconds = SysTimeFromTimeStruct(&timestruct, is_local);
+ if (seconds == -1) {
+ // Get the time values with tm_isdst == 0 and 1, then select the closest one
+ // to UTC 00:00:00 that isn't -1.
+ timestruct = timestruct0;
+ timestruct.tm_isdst = 0;
+ int64 seconds_isdst0 = SysTimeFromTimeStruct(&timestruct, is_local);
+
+ timestruct = timestruct0;
+ timestruct.tm_isdst = 1;
+ int64 seconds_isdst1 = SysTimeFromTimeStruct(&timestruct, is_local);
+
+ // seconds_isdst0 or seconds_isdst1 can be -1 for some timezones.
+ // E.g. "CLST" (Chile Summer Time) returns -1 for 'tm_isdt == 1'.
+ if (seconds_isdst0 < 0)
+ seconds = seconds_isdst1;
+ else if (seconds_isdst1 < 0)
+ seconds = seconds_isdst0;
+ else
+ seconds = std::min(seconds_isdst0, seconds_isdst1);
+ }
+
// Handle overflow. Clamping the range to what mktime and timegm might
// return is the best that can be done here. It's not ideal, but it's better
// than failing here or ignoring the overflow case and treating each time
@@ -234,14 +266,19 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
// When representing the most distant time in the future, add in an extra
// 999ms to avoid the time being less than any other possible value that
// this function can return.
+
+ // On Android, SysTime is int64, special care must be taken to avoid
+ // overflows.
+ const int64 min_seconds = (sizeof(SysTime) < sizeof(int64))
+ ? std::numeric_limits<SysTime>::min()
+ : std::numeric_limits<int32_t>::min();
+ const int64 max_seconds = (sizeof(SysTime) < sizeof(int64))
+ ? std::numeric_limits<SysTime>::max()
+ : std::numeric_limits<int32_t>::max();
if (exploded.year < 1969) {
- CHECK(sizeof(SysTime) < sizeof(int64)) << "integer overflow";
- milliseconds = std::numeric_limits<SysTime>::min();
- milliseconds *= kMillisecondsPerSecond;
+ milliseconds = min_seconds * kMillisecondsPerSecond;
} else {
- CHECK(sizeof(SysTime) < sizeof(int64)) << "integer overflow";
- milliseconds = std::numeric_limits<SysTime>::max();
- milliseconds *= kMillisecondsPerSecond;
+ milliseconds = max_seconds * kMillisecondsPerSecond;
milliseconds += (kMillisecondsPerSecond - 1);
}
} else {
diff --git a/chromium/base/time/time_unittest.cc b/chromium/base/time/time_unittest.cc
index 7f3fde0c5ee..81a3358f08c 100644
--- a/chromium/base/time/time_unittest.cc
+++ b/chromium/base/time/time_unittest.cc
@@ -7,6 +7,8 @@
#include <time.h>
#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -541,6 +543,28 @@ TEST_F(TimeTest, TimeTOverflow) {
}
#endif
+#if defined(OS_ANDROID)
+TEST_F(TimeTest, FromLocalExplodedCrashOnAndroid) {
+ // This crashed inside Time:: FromLocalExploded() on Android 4.1.2.
+ // See http://crbug.com/287821
+ Time::Exploded midnight = {2013, // year
+ 10, // month
+ 0, // day_of_week
+ 13, // day_of_month
+ 0, // hour
+ 0, // minute
+ 0, // second
+ };
+ // The string passed to putenv() must be a char* and the documentation states
+ // that it 'becomes part of the environment', so use a static buffer.
+ static char buffer[] = "TZ=America/Santiago";
+ putenv(buffer);
+ tzset();
+ Time t = Time::FromLocalExploded(midnight);
+ EXPECT_EQ(1381633200, t.ToTimeT());
+}
+#endif // OS_ANDROID
+
TEST(TimeTicks, Deltas) {
for (int index = 0; index < 50; index++) {
TimeTicks ticks_start = TimeTicks::Now();
diff --git a/chromium/base/values.cc b/chromium/base/values.cc
index adfb9801398..0c6a44c0d8e 100644
--- a/chromium/base/values.cc
+++ b/chromium/base/values.cc
@@ -752,7 +752,7 @@ bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key,
return true;
}
-DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() {
+DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() const {
Value* copy = CopyWithoutEmptyChildren(this);
return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue;
}
diff --git a/chromium/base/values.h b/chromium/base/values.h
index 4025c751eeb..21d72aba714 100644
--- a/chromium/base/values.h
+++ b/chromium/base/values.h
@@ -324,7 +324,7 @@ class BASE_EXPORT DictionaryValue : public Value {
// Makes a copy of |this| but doesn't include empty dictionaries and lists in
// the copy. This never returns NULL, even if |this| itself is empty.
- DictionaryValue* DeepCopyWithoutEmptyChildren();
+ DictionaryValue* DeepCopyWithoutEmptyChildren() const;
// Merge |dictionary| into this dictionary. This is done recursively, i.e. any
// sub-dictionaries will be merged as well. In case of key collisions, the
diff --git a/chromium/base/win/scoped_handle.h b/chromium/base/win/scoped_handle.h
index d236a70beb4..1e1b5b434df 100644
--- a/chromium/base/win/scoped_handle.h
+++ b/chromium/base/win/scoped_handle.h
@@ -197,7 +197,7 @@ class BASE_EXPORT VerifierTraits {
DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
};
-typedef GenericScopedHandle<HandleTraits, VerifierTraits> ScopedHandle;
+typedef GenericScopedHandle<HandleTraits, DummyVerifierTraits> ScopedHandle;
} // namespace win
} // namespace base