Commit aa91eb9f authored by michaelbai@google.com's avatar michaelbai@google.com

Upstream misc changes for android.

BUG=
TEST=

Review URL: http://codereview.chromium.org/7701014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98432 0039d316-1c4b-4281-b951-d872f2087c98
parent 2e5257e2
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "jni/system_message_handler_jni.h" #include "jni/system_message_handler_jni.h"
using base::android::AutoJObject; using base::android::ScopedJavaReference;
namespace { namespace {
...@@ -81,13 +81,13 @@ void MessagePumpForUI::Start(Delegate* delegate) { ...@@ -81,13 +81,13 @@ void MessagePumpForUI::Start(Delegate* delegate) {
DCHECK(env); DCHECK(env);
jclass clazz = env->FindClass(kClassPathName); jclass clazz = env->FindClass(kClassPathName);
DCHECK(!clazz); DCHECK(clazz);
jmethodID constructor = base::android::GetMethodID(env, clazz, "<init>", jmethodID constructor = base::android::GetMethodID(env, clazz, "<init>",
"(I)V"); "(I)V");
AutoJObject client = AutoJObject::FromLocalRef( ScopedJavaReference<jobject> client(env, env->NewObject(clazz, constructor,
env, env->NewObject(clazz, constructor, delegate)); delegate));
DCHECK(!client.obj()); DCHECK(client.obj());
g_system_message_handler_obj = env->NewGlobalRef(client.obj()); g_system_message_handler_obj = env->NewGlobalRef(client.obj());
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <time64.h>
#include <utime.h> #include <utime.h>
// Not implemented in Bionic. See platform_file_android.cc. // Not implemented in Bionic. See platform_file_android.cc.
...@@ -23,4 +24,9 @@ inline int lockf(int fd, int cmd, off_t ignored_len) { ...@@ -23,4 +24,9 @@ inline int lockf(int fd, int cmd, off_t ignored_len) {
return flock(fd, cmd); 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_ #endif // BASE_OS_COMPAT_ANDROID_H_
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -51,6 +51,10 @@ typedef PlatformTest PathServiceTest; ...@@ -51,6 +51,10 @@ typedef PlatformTest PathServiceTest;
// correct value while returning false.) // correct value while returning false.)
TEST_F(PathServiceTest, Get) { TEST_F(PathServiceTest, Get) {
for (int key = base::DIR_CURRENT; key < base::PATH_END; ++key) { 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); EXPECT_PRED1(ReturnsValidPath, key);
} }
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -60,6 +60,17 @@ NamedProcessIterator::NamedProcessIterator( ...@@ -60,6 +60,17 @@ NamedProcessIterator::NamedProcessIterator(
const FilePath::StringType& executable_name, const FilePath::StringType& executable_name,
const ProcessFilter* filter) : ProcessIterator(filter), const ProcessFilter* filter) : ProcessIterator(filter),
executable_name_(executable_name) { 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() { NamedProcessIterator::~NamedProcessIterator() {
......
...@@ -39,9 +39,9 @@ bool SharedMemory::CreateNamed(const std::string& name, ...@@ -39,9 +39,9 @@ bool SharedMemory::CreateNamed(const std::string& name,
} }
bool SharedMemory::Delete(const std::string& name) { bool SharedMemory::Delete(const std::string& name) {
// ashmem doesn't support name mapping // Like on Windows, this is intentionally returning true as ashmem will
NOTIMPLEMENTED(); // automatically releases the resource when all FDs on it are closed.
return false; return true;
} }
bool SharedMemory::Open(const std::string& name, bool read_only) { bool SharedMemory::Open(const std::string& name, bool read_only) {
......
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
#include <windows.h> #include <windows.h>
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#elif defined(OS_ANDROID)
#include <ctype.h>
#include "base/os_compat_android.h" // For timegm()
#endif #endif
#include <errno.h> /* for EINVAL */ #include <errno.h> /* for EINVAL */
#include <time.h> #include <time.h>
...@@ -138,10 +141,10 @@ PR_ImplodeTime(const PRExplodedTime *exploded) ...@@ -138,10 +141,10 @@ PR_ImplodeTime(const PRExplodedTime *exploded)
gregorian_date.minute = exploded->tm_min; gregorian_date.minute = exploded->tm_min;
gregorian_date.second = exploded->tm_sec; 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 // (note the combined offset will be negative when we need to add it), then
// convert to microseconds which is what PRTime expects. // convert to microseconds which is what PRTime expects.
CFAbsoluteTime absolute_time = CFAbsoluteTime absolute_time =
CFGregorianDateGetAbsoluteTime(gregorian_date, NULL); CFGregorianDateGetAbsoluteTime(gregorian_date, NULL);
PRTime result = static_cast<PRTime>(absolute_time); PRTime result = static_cast<PRTime>(absolute_time);
result -= exploded->tm_params.tp_gmt_offset + result -= exploded->tm_params.tp_gmt_offset +
......
...@@ -13,8 +13,16 @@ ...@@ -13,8 +13,16 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/logging.h" #include "base/logging.h"
#if defined(OS_ANDROID)
#include "base/os_compat_android.h"
#endif
namespace base { namespace base {
#if defined(OS_ANDROID)
#define _POSIX_MONOTONIC_CLOCK 1
#endif
struct timespec TimeDelta::ToTimeSpec() const { struct timespec TimeDelta::ToTimeSpec() const {
int64 microseconds = InMicroseconds(); int64 microseconds = InMicroseconds();
time_t seconds = 0; time_t seconds = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment