summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-11-07 17:42:06 -0800
committerJohn Reck <jreck@google.com>2011-11-07 17:42:06 -0800
commitaefc28a1b666f3e9b19eb5a8955e70297119f03d (patch)
tree400733d1f80bdac06719d470d9cd60bf5656323e /core
parent99f7b7b7b2295e6b919b773fc68ed719376d9ce9 (diff)
downloadframeworks_base-aefc28a1b666f3e9b19eb5a8955e70297119f03d.zip
frameworks_base-aefc28a1b666f3e9b19eb5a8955e70297119f03d.tar.gz
frameworks_base-aefc28a1b666f3e9b19eb5a8955e70297119f03d.tar.bz2
Remove unnecessary memory allocations
Bug: 5581637 Also delete some dead, unused code Change-Id: If6efd11f5032141dadbfcd0b3215e89b464e5f35
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/BrowserFrame.java7
-rw-r--r--core/java/android/webkit/JWebCoreJavaBridge.java2
-rw-r--r--core/java/android/webkit/LoadListener.java4
-rw-r--r--core/java/android/webkit/PerfChecker.java49
-rw-r--r--core/java/android/webkit/WebView.java57
5 files changed, 25 insertions, 94 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index 2cc928f..388920c 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -813,8 +813,6 @@ class BrowserFrame extends Handler {
boolean synchronous,
String username,
String password) {
- PerfChecker checker = new PerfChecker();
-
if (mSettings.getCacheMode() != WebSettings.LOAD_DEFAULT) {
cacheMode = mSettings.getCacheMode();
}
@@ -872,11 +870,6 @@ class BrowserFrame extends Handler {
|| headers.containsKey("If-None-Match") ?
WebSettings.LOAD_NO_CACHE : cacheMode);
// Set referrer to current URL?
- if (!loader.executeLoad()) {
- checker.responseAlert("startLoadingResource fail");
- }
- checker.responseAlert("startLoadingResource succeed");
-
return !synchronous ? loadListener : null;
}
diff --git a/core/java/android/webkit/JWebCoreJavaBridge.java b/core/java/android/webkit/JWebCoreJavaBridge.java
index 5b78586..b498435 100644
--- a/core/java/android/webkit/JWebCoreJavaBridge.java
+++ b/core/java/android/webkit/JWebCoreJavaBridge.java
@@ -87,11 +87,9 @@ final class JWebCoreJavaBridge extends Handler {
* Call native timer callbacks.
*/
private void fireSharedTimer() {
- PerfChecker checker = new PerfChecker();
// clear the flag so that sharedTimerFired() can set a new timer
mHasInstantTimer = false;
sharedTimerFired();
- checker.responseAlert("sharedTimer");
}
/**
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index 04af738..37e8bc0 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -1136,7 +1136,6 @@ class LoadListener extends Handler implements EventHandler {
// Give the data to WebKit now. We don't have to synchronize on
// mDataBuilder here because pulling each chunk removes it from the
// internal list so it cannot be modified.
- PerfChecker checker = new PerfChecker();
ByteArrayBuilder.Chunk c;
while (true) {
c = mDataBuilder.getFirstChunk();
@@ -1152,7 +1151,6 @@ class LoadListener extends Handler implements EventHandler {
} else {
c.release();
}
- checker.responseAlert("res nativeAddData");
}
}
@@ -1173,13 +1171,11 @@ class LoadListener extends Handler implements EventHandler {
WebViewWorker.MSG_REMOVE_CACHE, this).sendToTarget();
}
if (mNativeLoader != 0) {
- PerfChecker checker = new PerfChecker();
if (!mSetNativeResponse) {
setNativeResponse();
}
nativeFinished();
- checker.responseAlert("res nativeFinished");
clearNativeLoader();
}
}
diff --git a/core/java/android/webkit/PerfChecker.java b/core/java/android/webkit/PerfChecker.java
deleted file mode 100644
index 8c5f86e..0000000
--- a/core/java/android/webkit/PerfChecker.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.webkit;
-
-import android.os.SystemClock;
-import android.util.Log;
-
-class PerfChecker {
-
- private long mTime;
- private static final long mResponseThreshold = 2000; // 2s
-
- public PerfChecker() {
- if (false) {
- mTime = SystemClock.uptimeMillis();
- }
- }
-
- /**
- * @param what log string
- * Logs given string if mResponseThreshold time passed between either
- * instantiation or previous responseAlert call
- */
- public void responseAlert(String what) {
- if (false) {
- long upTime = SystemClock.uptimeMillis();
- long time = upTime - mTime;
- if (time > mResponseThreshold) {
- Log.w("webkit", what + " used " + time + " ms");
- }
- // Reset mTime, to permit reuse
- mTime = upTime;
- }
- }
-}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f0dc732..55f345f 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -683,7 +683,6 @@ public class WebView extends AbsoluteLayout
private static final int SWITCH_TO_LONGPRESS = 4;
private static final int RELEASE_SINGLE_TAP = 5;
private static final int REQUEST_FORM_DATA = 6;
- private static final int RESUME_WEBCORE_PRIORITY = 7;
private static final int DRAG_HELD_MOTIONLESS = 8;
private static final int AWAKEN_SCROLL_BARS = 9;
private static final int PREVENT_DEFAULT_TIMEOUT = 10;
@@ -2850,46 +2849,47 @@ public class WebView extends AbsoluteLayout
// Used to avoid sending many visible rect messages.
private Rect mLastVisibleRectSent;
private Rect mLastGlobalRect;
+ private Rect mVisibleRect = new Rect();
+ private Rect mGlobalVisibleRect = new Rect();
+ private Point mScrollOffset = new Point();
Rect sendOurVisibleRect() {
if (mZoomManager.isPreventingWebkitUpdates()) return mLastVisibleRectSent;
- Rect rect = new Rect();
- calcOurContentVisibleRect(rect);
+ calcOurContentVisibleRect(mVisibleRect);
// Rect.equals() checks for null input.
- if (!rect.equals(mLastVisibleRectSent)) {
+ if (!mVisibleRect.equals(mLastVisibleRectSent)) {
if (!mBlockWebkitViewMessages) {
- Point pos = new Point(rect.left, rect.top);
+ mScrollOffset.set(mVisibleRect.left, mVisibleRect.top);
mWebViewCore.removeMessages(EventHub.SET_SCROLL_OFFSET);
mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,
- nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, pos);
+ nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, mScrollOffset);
}
- mLastVisibleRectSent = rect;
+ mLastVisibleRectSent = mVisibleRect;
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
}
- Rect globalRect = new Rect();
- if (getGlobalVisibleRect(globalRect)
- && !globalRect.equals(mLastGlobalRect)) {
+ if (getGlobalVisibleRect(mGlobalVisibleRect)
+ && !mGlobalVisibleRect.equals(mLastGlobalRect)) {
if (DebugFlags.WEB_VIEW) {
- Log.v(LOGTAG, "sendOurVisibleRect=(" + globalRect.left + ","
- + globalRect.top + ",r=" + globalRect.right + ",b="
- + globalRect.bottom);
+ Log.v(LOGTAG, "sendOurVisibleRect=(" + mGlobalVisibleRect.left + ","
+ + mGlobalVisibleRect.top + ",r=" + mGlobalVisibleRect.right + ",b="
+ + mGlobalVisibleRect.bottom);
}
// TODO: the global offset is only used by windowRect()
// in ChromeClientAndroid ; other clients such as touch
// and mouse events could return view + screen relative points.
if (!mBlockWebkitViewMessages) {
- mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, globalRect);
+ mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, mGlobalVisibleRect);
}
- mLastGlobalRect = globalRect;
+ mLastGlobalRect = mGlobalVisibleRect;
}
- return rect;
+ return mVisibleRect;
}
+ private Point mGlobalVisibleOffset = new Point();
// Sets r to be the visible rectangle of our webview in view coordinates
private void calcOurVisibleRect(Rect r) {
- Point p = new Point();
- getGlobalVisibleRect(r, p);
- r.offset(-p.x, -p.y);
+ getGlobalVisibleRect(r, mGlobalVisibleOffset);
+ r.offset(-mGlobalVisibleOffset.x, -mGlobalVisibleOffset.y);
}
// Sets r to be our visible rectangle in content coordinates
@@ -2905,21 +2905,21 @@ public class WebView extends AbsoluteLayout
r.bottom = viewToContentY(r.bottom);
}
+ private Rect mContentVisibleRect = new Rect();
// Sets r to be our visible rectangle in content coordinates. We use this
// method on the native side to compute the position of the fixed layers.
// Uses floating coordinates (necessary to correctly place elements when
// the scale factor is not 1)
private void calcOurContentVisibleRectF(RectF r) {
- Rect ri = new Rect(0,0,0,0);
- calcOurVisibleRect(ri);
- r.left = viewToContentXf(ri.left);
+ calcOurVisibleRect(mContentVisibleRect);
+ r.left = viewToContentXf(mContentVisibleRect.left);
// viewToContentY will remove the total height of the title bar. Add
// the visible height back in to account for the fact that if the title
// bar is partially visible, the part of the visible rect which is
// displaying our content is displaced by that amount.
- r.top = viewToContentYf(ri.top + getVisibleTitleHeightImpl());
- r.right = viewToContentXf(ri.right);
- r.bottom = viewToContentYf(ri.bottom);
+ r.top = viewToContentYf(mContentVisibleRect.top + getVisibleTitleHeightImpl());
+ r.right = viewToContentXf(mContentVisibleRect.right);
+ r.bottom = viewToContentYf(mContentVisibleRect.bottom);
}
static class ViewSizeData {
@@ -3569,7 +3569,6 @@ public class WebView extends AbsoluteLayout
mScrollingLayerRect.top = y;
}
abortAnimation();
- mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
nativeSetIsScrolling(false);
if (!mBlockWebkitViewMessages) {
WebViewCore.resumePriority();
@@ -5992,7 +5991,6 @@ public class WebView extends AbsoluteLayout
mScroller.abortAnimation();
mTouchMode = TOUCH_DRAG_START_MODE;
mConfirmMove = true;
- mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
nativeSetIsScrolling(false);
} else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) {
mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
@@ -7329,7 +7327,6 @@ public class WebView extends AbsoluteLayout
mLastTouchTime = eventTime;
if (!mScroller.isFinished()) {
abortAnimation();
- mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
}
mSnapScrollMode = SNAP_NONE;
mVelocityTracker = VelocityTracker.obtain();
@@ -8461,10 +8458,6 @@ public class WebView extends AbsoluteLayout
mWebTextView.setAdapterCustom(adapter);
}
break;
- case RESUME_WEBCORE_PRIORITY:
- WebViewCore.resumePriority();
- WebViewCore.resumeUpdatePicture(mWebViewCore);
- break;
case LONG_PRESS_CENTER:
// as this is shared by keydown and trackballdown, reset all