summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/message_pump_android.cc10
-rw-r--r--base/os_compat_android.h6
-rw-r--r--base/path_service_unittest.cc6
-rw-r--r--base/process_util.cc11
-rw-r--r--base/shared_memory_android.cc6
-rw-r--r--base/third_party/nspr/prtime.cc7
-rw-r--r--base/time_posix.cc8
7 files changed, 43 insertions, 11 deletions
diff --git a/base/message_pump_android.cc b/base/message_pump_android.cc
index d9fdf9c..7136eff 100644
--- a/base/message_pump_android.cc
+++ b/base/message_pump_android.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "jni/system_message_handler_jni.h"
-using base::android::AutoJObject;
+using base::android::ScopedJavaReference;
namespace {
@@ -81,13 +81,13 @@ void MessagePumpForUI::Start(Delegate* delegate) {
DCHECK(env);
jclass clazz = env->FindClass(kClassPathName);
- DCHECK(!clazz);
+ DCHECK(clazz);
jmethodID constructor = base::android::GetMethodID(env, clazz, "<init>",
"(I)V");
- AutoJObject client = AutoJObject::FromLocalRef(
- env, env->NewObject(clazz, constructor, delegate));
- DCHECK(!client.obj());
+ ScopedJavaReference<jobject> client(env, env->NewObject(clazz, constructor,
+ delegate));
+ DCHECK(client.obj());
g_system_message_handler_obj = env->NewGlobalRef(client.obj());
diff --git a/base/os_compat_android.h b/base/os_compat_android.h
index fb69efa..af6e167 100644
--- a/base/os_compat_android.h
+++ b/base/os_compat_android.h
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <sys/types.h>
+#include <time64.h>
#include <utime.h>
// Not implemented in Bionic. See platform_file_android.cc.
@@ -23,4 +24,9 @@ inline int lockf(int fd, int cmd, off_t ignored_len) {
return flock(fd, cmd);
}
+// Android has only timegm64() and no timegm().
+inline time_t timegm(struct tm* const tmp) {
+ return static_cast<time_t>(timegm64(tmp));
+}
+
#endif // BASE_OS_COMPAT_ANDROID_H_
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index 26998de..ec9cf28 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -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.
@@ -51,6 +51,10 @@ typedef PlatformTest PathServiceTest;
// correct value while returning false.)
TEST_F(PathServiceTest, Get) {
for (int key = base::DIR_CURRENT; key < base::PATH_END; ++key) {
+#if defined(OS_ANDROID)
+ if (key == base::FILE_MODULE)
+ continue; // Android doesn't implement FILE_MODULE;
+#endif
EXPECT_PRED1(ReturnsValidPath, key);
}
#if defined(OS_WIN)
diff --git a/base/process_util.cc b/base/process_util.cc
index 7fe1a85..9979dfa 100644
--- a/base/process_util.cc
+++ b/base/process_util.cc
@@ -60,6 +60,17 @@ NamedProcessIterator::NamedProcessIterator(
const FilePath::StringType& executable_name,
const ProcessFilter* filter) : ProcessIterator(filter),
executable_name_(executable_name) {
+#if defined(OS_ANDROID)
+ // On Android, the process name contains only the last 15 characters, which
+ // is in file /proc/<pid>/stat, the string between open parenthesis and close
+ // parenthesis. Please See ProcessIterator::CheckForNextProcess for details.
+ // Now if the length of input process name is greater than 15, only save the
+ // last 15 characters.
+ if (executable_name_.size() > 15) {
+ executable_name_ = FilePath::StringType(executable_name_,
+ executable_name_.size() - 15, 15);
+ }
+#endif
}
NamedProcessIterator::~NamedProcessIterator() {
diff --git a/base/shared_memory_android.cc b/base/shared_memory_android.cc
index c2f3315..72c3a56 100644
--- a/base/shared_memory_android.cc
+++ b/base/shared_memory_android.cc
@@ -39,9 +39,9 @@ bool SharedMemory::CreateNamed(const std::string& name,
}
bool SharedMemory::Delete(const std::string& name) {
- // ashmem doesn't support name mapping
- NOTIMPLEMENTED();
- return false;
+ // Like on Windows, this is intentionally returning true as ashmem will
+ // automatically releases the resource when all FDs on it are closed.
+ return true;
}
bool SharedMemory::Open(const std::string& name, bool read_only) {
diff --git a/base/third_party/nspr/prtime.cc b/base/third_party/nspr/prtime.cc
index f1fcf26..61b7303 100644
--- a/base/third_party/nspr/prtime.cc
+++ b/base/third_party/nspr/prtime.cc
@@ -71,6 +71,9 @@
#include <windows.h>
#elif defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
+#elif defined(OS_ANDROID)
+#include <ctype.h>
+#include "base/os_compat_android.h" // For timegm()
#endif
#include <errno.h> /* for EINVAL */
#include <time.h>
@@ -138,10 +141,10 @@ PR_ImplodeTime(const PRExplodedTime *exploded)
gregorian_date.minute = exploded->tm_min;
gregorian_date.second = exploded->tm_sec;
- // Compute |absolute_time| in seconds, correct for gmt and dst
+ // Compute |absolute_time| in seconds, correct for gmt and dst
// (note the combined offset will be negative when we need to add it), then
// convert to microseconds which is what PRTime expects.
- CFAbsoluteTime absolute_time =
+ CFAbsoluteTime absolute_time =
CFGregorianDateGetAbsoluteTime(gregorian_date, NULL);
PRTime result = static_cast<PRTime>(absolute_time);
result -= exploded->tm_params.tp_gmt_offset +
diff --git a/base/time_posix.cc b/base/time_posix.cc
index f83a9656..30dd380 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -13,8 +13,16 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#if defined(OS_ANDROID)
+#include "base/os_compat_android.h"
+#endif
+
namespace base {
+#if defined(OS_ANDROID)
+#define _POSIX_MONOTONIC_CLOCK 1
+#endif
+
struct timespec TimeDelta::ToTimeSpec() const {
int64 microseconds = InMicroseconds();
time_t seconds = 0;