Backed out 4 changesets (bug 1200343) for android talos failures

Backed out changeset 67dc42cbf02b (bug 1200343)
Backed out changeset b077acafcebb (bug 1200343)
Backed out changeset e115ca114601 (bug 1200343)
Backed out changeset 905e1fb54fd4 (bug 1200343)
This commit is contained in:
Wes Kocher 2015-09-25 13:21:58 -07:00
parent c1c7c141ff
commit 5ad8b759ce
11 changed files with 79 additions and 248 deletions

View File

@ -191,15 +191,15 @@ public class FennecNativeActions implements Actions {
}
public void sendPreferencesGetEvent(int requestId, String[] prefNames) {
PrefsHelper.getPrefsById(requestId, prefNames, /* observe */ false);
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesGetEvent(requestId, prefNames));
}
public void sendPreferencesObserveEvent(int requestId, String[] prefNames) {
PrefsHelper.getPrefsById(requestId, prefNames, /* observe */ true);
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesObserveEvent(requestId, prefNames));
}
public void sendPreferencesRemoveObserversEvent(int requestId) {
PrefsHelper.removePrefsObserver(requestId);
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesRemoveObserversEvent(requestId));
}
class PaintExpecter implements RepeatedEventExpecter {

View File

@ -97,6 +97,9 @@ public class GeckoEvent {
LOW_MEMORY(35),
NETWORK_LINK_CHANGE(36),
TELEMETRY_HISTOGRAM_ADD(37),
PREFERENCES_OBSERVE(39),
PREFERENCES_GET(40),
PREFERENCES_REMOVE_OBSERVERS(41),
TELEMETRY_UI_SESSION_START(42),
TELEMETRY_UI_SESSION_STOP(43),
TELEMETRY_UI_EVENT(44),
@ -222,6 +225,8 @@ public class GeckoEvent {
private float mGamepadButtonValue;
private float[] mGamepadValues;
private String[] mPrefNames;
private Object mObject;
private GeckoEvent(NativeGeckoEvent event) {
@ -762,6 +767,29 @@ public class GeckoEvent {
return event;
}
@RobocopTarget
public static GeckoEvent createPreferencesObserveEvent(int requestId, String[] prefNames) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.PREFERENCES_OBSERVE);
event.mCount = requestId;
event.mPrefNames = prefNames;
return event;
}
@RobocopTarget
public static GeckoEvent createPreferencesGetEvent(int requestId, String[] prefNames) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.PREFERENCES_GET);
event.mCount = requestId;
event.mPrefNames = prefNames;
return event;
}
@RobocopTarget
public static GeckoEvent createPreferencesRemoveObserversEvent(int requestId) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.PREFERENCES_REMOVE_OBSERVERS);
event.mCount = requestId;
return event;
}
public static GeckoEvent createLowMemoryEvent(int level) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.LOW_MEMORY);
event.mMetaState = level;

View File

@ -5,8 +5,6 @@
package org.mozilla.gecko;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.util.GeckoEventListener;
import org.json.JSONArray;
@ -28,11 +26,6 @@ public final class PrefsHelper {
private static int sUniqueRequestId = 1;
static final SparseArray<PrefHandler> sCallbacks = new SparseArray<PrefHandler>();
@WrapForJNI @RobocopTarget
/* package */ static native void getPrefsById(int requestId, String[] prefNames, boolean observe);
@WrapForJNI @RobocopTarget
/* package */ static native void removePrefsObserver(int requestId);
public static int getPref(String prefName, PrefHandler callback) {
return getPrefsInternal(new String[] { prefName }, callback);
}
@ -54,15 +47,14 @@ public final class PrefsHelper {
sCallbacks.put(requestId, callback);
}
// Because we use JS to handle pref events, we need to wait until the RUNNING state.
// If we ever convert that to native code, we can switch to using the JNI_READY state.
if (GeckoThread.isStateAtLeast(GeckoThread.State.RUNNING)) {
getPrefsById(requestId, prefNames, callback.isObserver());
GeckoEvent event;
if (callback.isObserver()) {
event = GeckoEvent.createPreferencesObserveEvent(requestId, prefNames);
} else {
GeckoThread.queueNativeCallUntil(
GeckoThread.State.RUNNING, PrefsHelper.class, "getPrefsById",
requestId, prefNames, callback.isObserver());
event = GeckoEvent.createPreferencesGetEvent(requestId, prefNames);
}
GeckoAppShell.sendEventToGecko(event);
return requestId;
}

View File

@ -70,6 +70,7 @@ jfieldID AndroidGeckoEvent::jGamepadButtonField = 0;
jfieldID AndroidGeckoEvent::jGamepadButtonPressedField = 0;
jfieldID AndroidGeckoEvent::jGamepadButtonValueField = 0;
jfieldID AndroidGeckoEvent::jGamepadValuesField = 0;
jfieldID AndroidGeckoEvent::jPrefNamesField = 0;
jfieldID AndroidGeckoEvent::jObjectField = 0;
jclass AndroidPoint::jPointClass = 0;
@ -178,6 +179,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
jGamepadButtonPressedField = geckoEvent.getField("mGamepadButtonPressed", "Z");
jGamepadButtonValueField = geckoEvent.getField("mGamepadButtonValue", "F");
jGamepadValuesField = geckoEvent.getField("mGamepadValues", "[F");
jPrefNamesField = geckoEvent.getField("mPrefNames", "[Ljava/lang/String;");
jObjectField = geckoEvent.getField("mObject", "Ljava/lang/Object;");
}
@ -607,6 +609,18 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
break;
}
case PREFERENCES_OBSERVE:
case PREFERENCES_GET: {
ReadStringArray(mPrefNames, jenv, jPrefNamesField);
mCount = jenv->GetIntField(jobj, jCountField);
break;
}
case PREFERENCES_REMOVE_OBSERVERS: {
mCount = jenv->GetIntField(jobj, jCountField);
break;
}
default:
break;
}

View File

@ -524,6 +524,7 @@ public:
const nsTArray<int>& ToolTypes() { return mToolTypes; }
const nsTArray<float>& Orientations() { return mOrientations; }
const nsTArray<nsIntPoint>& PointRadii() { return mPointRadii; }
const nsTArray<nsString>& PrefNames() { return mPrefNames; }
double X() { return mX; }
double Y() { return mY; }
double Z() { return mZ; }
@ -620,6 +621,7 @@ protected:
float mGamepadButtonValue;
nsTArray<float> mGamepadValues;
nsCOMPtr<nsIObserver> mObserver;
nsTArray<nsString> mPrefNames;
MultiTouchInput mApzInput;
mozilla::layers::ScrollableLayerGuid mApzGuid;
uint64_t mApzInputBlockId;
@ -689,6 +691,7 @@ protected:
static jfieldID jRangeBackColorField;
static jfieldID jRangeLineColorField;
static jfieldID jLocationField;
static jfieldID jPrefNamesField;
static jfieldID jConnectionTypeField;
static jfieldID jIsWifiField;
@ -742,6 +745,9 @@ public:
NETWORK_LINK_CHANGE = 36,
TELEMETRY_HISTOGRAM_ADD = 37,
ADD_OBSERVER = 38,
PREFERENCES_OBSERVE = 39,
PREFERENCES_GET = 40,
PREFERENCES_REMOVE_OBSERVERS = 41,
TELEMETRY_UI_SESSION_START = 42,
TELEMETRY_UI_SESSION_STOP = 43,
TELEMETRY_UI_EVENT = 44,

View File

@ -85,25 +85,6 @@ public:
template<class Impl>
constexpr JNINativeMethod GeckoView::Window::Natives<Impl>::methods[];
template<class Impl>
class PrefsHelper::Natives : public mozilla::jni::NativeImpl<PrefsHelper, Impl>
{
public:
static constexpr JNINativeMethod methods[] = {
mozilla::jni::MakeNativeMethod<PrefsHelper::GetPrefsById_t>(
mozilla::jni::NativeStub<PrefsHelper::GetPrefsById_t, Impl>
::template Wrap<&Impl::GetPrefsById>),
mozilla::jni::MakeNativeMethod<PrefsHelper::RemovePrefsObserver_t>(
mozilla::jni::NativeStub<PrefsHelper::RemovePrefsObserver_t, Impl>
::template Wrap<&Impl::RemovePrefsObserver>)
};
};
template<class Impl>
constexpr JNINativeMethod PrefsHelper::Natives<Impl>::methods[];
template<class Impl>
class NativeJSContainer::Natives : public mozilla::jni::NativeImpl<NativeJSContainer, Impl>
{

View File

@ -956,14 +956,6 @@ constexpr char GeckoView::Window::DisposeNative_t::signature[];
constexpr char GeckoView::Window::Open_t::name[];
constexpr char GeckoView::Window::Open_t::signature[];
constexpr char PrefsHelper::name[];
constexpr char PrefsHelper::GetPrefsById_t::name[];
constexpr char PrefsHelper::GetPrefsById_t::signature[];
constexpr char PrefsHelper::RemovePrefsObserver_t::name[];
constexpr char PrefsHelper::RemovePrefsObserver_t::signature[];
constexpr char RestrictedProfiles::name[];
constexpr char RestrictedProfiles::IsAllowed_t::name[];

View File

@ -2312,58 +2312,6 @@ public:
template<class Impl> class Natives;
};
class PrefsHelper : public mozilla::jni::Class<PrefsHelper>
{
public:
typedef mozilla::jni::Ref<PrefsHelper> Ref;
typedef mozilla::jni::LocalRef<PrefsHelper> LocalRef;
typedef mozilla::jni::GlobalRef<PrefsHelper> GlobalRef;
typedef const mozilla::jni::Param<PrefsHelper>& Param;
static constexpr char name[] =
"org/mozilla/gecko/PrefsHelper";
protected:
PrefsHelper(jobject instance) : Class(instance) {}
public:
struct GetPrefsById_t {
typedef PrefsHelper Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
int32_t,
mozilla::jni::ObjectArray::Param,
bool> Args;
static constexpr char name[] = "getPrefsById";
static constexpr char signature[] =
"(I[Ljava/lang/String;Z)V";
static const bool isStatic = true;
static const bool isMultithreaded = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
public:
struct RemovePrefsObserver_t {
typedef PrefsHelper Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
int32_t> Args;
static constexpr char name[] = "removePrefsObserver";
static constexpr char signature[] =
"(I)V";
static const bool isStatic = true;
static const bool isMultithreaded = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
public:
template<class Impl> class Natives;
};
class RestrictedProfiles : public mozilla::jni::Class<RestrictedProfiles>
{
public:

View File

@ -1,78 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PrefsHelper_h
#define PrefsHelper_h
#include "GeneratedJNINatives.h"
#include "MainThreadUtils.h"
#include "nsAppShell.h"
#include "mozilla/UniquePtr.h"
namespace mozilla {
struct PrefsHelper
: widget::PrefsHelper::Natives<PrefsHelper>
, UsesGeckoThreadProxy
{
PrefsHelper() = delete;
static void GetPrefsById(const jni::ClassObject::LocalRef& cls,
int32_t requestId,
jni::ObjectArray::Param prefNames,
bool observe)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(nsAppShell::gAppShell);
nsTArray<jni::Object::LocalRef> namesRefArray(prefNames.GetElements());
const size_t len = namesRefArray.Length();
// Java strings are not null-terminated, but XPCOM expects
// null-terminated strings, so we copy the strings to nsString to
// ensure null-termination.
nsTArray<nsString> namesStrArray;
nsTArray<const char16_t*> namesPtrArray;
for (size_t i = 0; i < len; i++) {
if (!namesRefArray[i]) {
namesPtrArray.AppendElement(nullptr);
continue;
}
namesPtrArray.AppendElement(namesStrArray.AppendElement(
nsString(jni::String::LocalRef(
mozilla::Move(namesRefArray[i]))))->Data());
}
nsIAndroidBrowserApp* browserApp = nullptr;
nsAppShell::gAppShell->GetBrowserApp(&browserApp);
MOZ_ASSERT(browserApp);
if (observe) {
browserApp->ObservePreferences(
requestId, len ? &namesPtrArray[0] : nullptr, len);
} else {
browserApp->GetPreferences(
requestId, len ? &namesPtrArray[0] : nullptr, len);
}
}
static void RemovePrefsObserver(int32_t requestId)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(nsAppShell::gAppShell);
nsIAndroidBrowserApp* browserApp = nullptr;
nsAppShell::gAppShell->GetBrowserApp(&browserApp);
MOZ_ASSERT(browserApp);
browserApp->RemovePreferenceObservers(requestId);
}
};
} // namespace
#endif // PrefsHelper_h

View File

@ -8,7 +8,6 @@
#include "nsError.h" // for nsresult
#include "nsString.h"
#include "nsTArray.h"
namespace mozilla {
namespace jni {
@ -542,76 +541,6 @@ public:
};
// Ref specialization for jobjectArray.
template<>
class Ref<ObjectArray> : public RefBase<ObjectArray, jobjectArray>
{
friend class RefBase<ObjectArray, jobjectArray>;
friend class detail::TypeAdapter<Ref<ObjectArray>>;
typedef RefBase<ObjectArray, jobjectArray> Base;
protected:
Ref(jobject instance) : Base(instance) {}
Ref(const Ref& ref) : Base(ref.mInstance) {}
public:
MOZ_IMPLICIT Ref(decltype(nullptr)) : Base(nullptr) {}
// Get the length of the object array.
size_t Length() const
{
MOZ_ASSERT(ObjectArray::mInstance);
JNIEnv* const env = GetEnvForThread();
const size_t ret = env->GetArrayLength(jarray(ObjectArray::mInstance));
HandleUncaughtException(env);
return ret;
}
Object::LocalRef GetElement(size_t index) const
{
MOZ_ASSERT(ObjectArray::mInstance);
JNIEnv* const env = GetEnvForThread();
auto ret = Object::LocalRef::Adopt(env, env->GetObjectArrayElement(
jobjectArray(ObjectArray::mInstance), jsize(index)));
HandleUncaughtException(env);
return ret;
}
nsTArray<Object::LocalRef> GetElements() const
{
MOZ_ASSERT(ObjectArray::mInstance);
JNIEnv* const env = GetEnvForThread();
const jsize len = size_t(env->GetArrayLength(
jarray(ObjectArray::mInstance)));
nsTArray<Object::LocalRef> array((size_t(len)));
for (jsize i = 0; i < len; i++) {
array.AppendElement(Object::LocalRef::Adopt(
env, env->GetObjectArrayElement(
jobjectArray(ObjectArray::mInstance), i)));
HandleUncaughtException(env);
}
return array;
}
operator nsTArray<Object::LocalRef>() const
{
return GetElements();
}
void SetElement(size_t index, Object::Param element) const
{
MOZ_ASSERT(ObjectArray::mInstance);
JNIEnv* const env = GetEnvForThread();
env->SetObjectArrayElement(jobjectArray(ObjectArray::mInstance),
jsize(index), element.Get());
HandleUncaughtException(env);
}
};
// Ref specialization for jstring.
template<>
class Ref<String> : public RefBase<String, jstring>
@ -619,7 +548,7 @@ class Ref<String> : public RefBase<String, jstring>
friend class RefBase<String, jstring>;
friend struct detail::TypeAdapter<Ref<String>>;
typedef RefBase<String, jstring> Base;
typedef RefBase<TypedObject<jstring>, jstring> Base;
protected:
Ref(jobject instance) : Base(instance) {}

View File

@ -60,7 +60,6 @@
#endif
#include "ANRReporter.h"
#include "PrefsHelper.h"
#ifdef DEBUG_ANDROID_EVENTS
#define EVLOG(args...) ALOG(args)
@ -197,7 +196,6 @@ nsAppShell::nsAppShell()
AndroidBridge::ConstructBridge();
GeckoThreadNatives::Init();
mozilla::ANRReporter::Init();
mozilla::PrefsHelper::Init();
nsWindow::InitNatives();
widget::GeckoThread::SetState(widget::GeckoThread::State::JNI_READY());
@ -725,6 +723,27 @@ nsAppShell::LegacyGeckoEvent::Run()
nsAppShell::gAppShell->AddObserver(curEvent->Characters(), curEvent->Observer());
break;
case AndroidGeckoEvent::PREFERENCES_GET:
case AndroidGeckoEvent::PREFERENCES_OBSERVE: {
const nsTArray<nsString> &prefNames = curEvent->PrefNames();
size_t count = prefNames.Length();
nsAutoArrayPtr<const char16_t*> prefNamePtrs(new const char16_t*[count]);
for (size_t i = 0; i < count; ++i) {
prefNamePtrs[i] = prefNames[i].get();
}
if (curEvent->Type() == AndroidGeckoEvent::PREFERENCES_GET) {
nsAppShell::gAppShell->mBrowserApp->GetPreferences(curEvent->RequestId(), prefNamePtrs, count);
} else {
nsAppShell::gAppShell->mBrowserApp->ObservePreferences(curEvent->RequestId(), prefNamePtrs, count);
}
break;
}
case AndroidGeckoEvent::PREFERENCES_REMOVE_OBSERVERS:
nsAppShell::gAppShell->mBrowserApp->RemovePreferenceObservers(curEvent->RequestId());
break;
case AndroidGeckoEvent::LOW_MEMORY:
// TODO hook in memory-reduction stuff for different levels here
if (curEvent->MetaState() >= AndroidGeckoEvent::MEMORY_PRESSURE_MEDIUM) {