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 @@
#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());
......
......@@ -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_
// 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)
......
......@@ -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() {
......
......@@ -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) {
......
......@@ -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 +
......
......@@ -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;
......
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