am b40f5d72: am 2524fd28: Merge "Fix leak of inspectorClient when INSPECTOR disabled"

* commit 'b40f5d724d7ee13d54246f5794375c3c9945f90a':
  Fix leak of inspectorClient when INSPECTOR disabled
diff --git a/Android.mk b/Android.mk
index ecff19e..3d59ea7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -298,7 +298,6 @@
 	libicuuc \
 	libicui18n \
 	libmedia \
-	libmedia_native \
 	libnativehelper \
 	libskia \
 	libsqlite \
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 10eb822..c2bbd42 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -699,8 +699,7 @@
 	platform/graphics/android/rendering/TilesProfiler.cpp \
 	platform/graphics/android/rendering/TransferQueue.cpp \
 	\
-	platform/graphics/android/utils/ClassTracker.cpp \
-	platform/graphics/android/utils/LinearAllocator.cpp
+	platform/graphics/android/utils/ClassTracker.cpp
 
 ifeq ($(ENABLE_SVG), true)
 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
index ab6e676..d24ce35 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
@@ -28,12 +28,12 @@
 #include "GraphicsOperation.h"
 
 #include "AndroidLog.h"
-#include "LinearAllocator.h"
+#include <utils/LinearAllocator.h>
 
 namespace WebCore {
 namespace GraphicsOperation {
 
-void* Operation::operator new(size_t size, LinearAllocator* allocator)
+void* Operation::operator new(size_t size, android::LinearAllocator* allocator)
 {
     return allocator->alloc(size);
 }
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
index edcdc35..c3f54d6 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
@@ -50,10 +50,13 @@
 #define TYPE(x)
 #endif
 
+namespace android {
+class LinearAllocator;
+}
+
 namespace WebCore {
 
 class CanvasState;
-class LinearAllocator;
 
 namespace GraphicsOperation {
 
@@ -64,7 +67,7 @@
         , m_canvasState(0)
     {}
 
-    void* operator new(size_t size, LinearAllocator* allocator);
+    void* operator new(size_t size, android::LinearAllocator* allocator);
 
     // Purposely not implemented - use a LinearAllocator please
     void* operator new(size_t size);
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index 10bf363..d296b75 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -35,7 +35,6 @@
 #include "Font.h"
 #include "GraphicsContext.h"
 #include "GraphicsOperation.h"
-#include "LinearAllocator.h"
 #include "PlatformGraphicsContextSkia.h"
 #include "RTree.h"
 #include "SkDevice.h"
@@ -44,6 +43,8 @@
 #include "wtf/HashSet.h"
 #include "wtf/StringHasher.h"
 
+#include <utils/LinearAllocator.h>
+
 #define NEW_OP(X) new (heap()) GraphicsOperation::X
 
 #define USE_CLIPPING_PAINTER true
@@ -194,7 +195,7 @@
         return m_isTransparencyLayer;
     }
 
-    void* operator new(size_t size, LinearAllocator* la) {
+    void* operator new(size_t size, android::LinearAllocator* la) {
         return la->alloc(size);
     }
 
@@ -210,7 +211,7 @@
     // Careful, ordering matters here. Ordering is first constructed == last destroyed,
     // so we have to make sure our Heap is the first thing listed so that it is
     // the last thing destroyed.
-    LinearAllocator m_heap;
+    android::LinearAllocator m_heap;
 public:
     RecordingImpl()
         : m_tree(&m_heap)
@@ -287,7 +288,7 @@
         toState->playback(context, fromId, toId);
     }
 
-    LinearAllocator* heap() { return &m_heap; }
+    android::LinearAllocator* heap() { return &m_heap; }
 
     RTree::RTree m_tree;
     int m_nodeCount;
@@ -1080,7 +1081,7 @@
     mRecordingStateStack.last().mCanvasState->adoptAndAppend(data);
 }
 
-LinearAllocator* PlatformGraphicsContextRecording::heap()
+android::LinearAllocator* PlatformGraphicsContextRecording::heap()
 {
     return mRecording->recording()->heap();
 }
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index eefd270..1a703cf 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -31,13 +31,16 @@
 #include "RecordingContextCanvasProxy.h"
 #include "SkRefCnt.h"
 
+namespace android {
+class LinearAllocator;
+}
+
 namespace WebCore {
 namespace GraphicsOperation {
 class Operation;
 }
 
 class CanvasState;
-class LinearAllocator;
 class RecordingImpl;
 class PlatformGraphicsContextSkia;
 class RecordingData;
@@ -161,7 +164,7 @@
     void popMatrix();
     IntRect calculateFinalBounds(FloatRect bounds);
     IntRect calculateCoveredBounds(FloatRect bounds);
-    LinearAllocator* heap();
+    android::LinearAllocator* heap();
 
     SkPicture* mPicture;
     SkMatrix* mCurrentMatrix;
diff --git a/Source/WebCore/platform/graphics/android/context/RTree.cpp b/Source/WebCore/platform/graphics/android/context/RTree.cpp
index 2e24c34..1e11f58 100644
--- a/Source/WebCore/platform/graphics/android/context/RTree.cpp
+++ b/Source/WebCore/platform/graphics/android/context/RTree.cpp
@@ -31,11 +31,11 @@
 #include "RTree.h"
 
 #include "AndroidLog.h"
-#include "LinearAllocator.h"
+#include <utils/LinearAllocator.h>
 
 namespace WebCore {
 
-void* RecordingData::operator new(size_t size, LinearAllocator* allocator)
+void* RecordingData::operator new(size_t size, android::LinearAllocator* allocator)
 {
     return allocator->alloc(size);
 }
@@ -132,7 +132,7 @@
 //
 //////////////////////////////////////////////////////////////////////
 
-RTree::RTree(WebCore::LinearAllocator* allocator, int M)
+RTree::RTree(android::LinearAllocator* allocator, int M)
     : m_allocator(allocator)
 {
     m_maxChildren = M;
diff --git a/Source/WebCore/platform/graphics/android/context/RTree.h b/Source/WebCore/platform/graphics/android/context/RTree.h
index 50962ef..8d9a359 100644
--- a/Source/WebCore/platform/graphics/android/context/RTree.h
+++ b/Source/WebCore/platform/graphics/android/context/RTree.h
@@ -30,9 +30,11 @@
 #include "IntRect.h"
 #include "GraphicsOperation.h"
 
-namespace WebCore {
-
+namespace android {
 class LinearAllocator;
+}
+
+namespace WebCore {
 
 class RecordingData {
 public:
@@ -47,7 +49,7 @@
     size_t m_orderBy;
     GraphicsOperation::Operation* m_operation;
 
-    void* operator new(size_t size, LinearAllocator* allocator);
+    void* operator new(size_t size, android::LinearAllocator* allocator);
 
     // Purposely not implemented - use a LinearAllocator please
     void* operator new(size_t size);
@@ -64,7 +66,7 @@
 class RTree {
 public:
     // M -- max number of children per node
-    RTree(WebCore::LinearAllocator* allocator, int M = 10);
+    RTree(android::LinearAllocator* allocator, int M = 10);
     ~RTree();
 
     void insert(WebCore::IntRect& bounds, WebCore::RecordingData* payload);
@@ -84,7 +86,7 @@
     unsigned m_maxChildren;
     ElementList* m_listA;
     ElementList* m_listB;
-    WebCore::LinearAllocator* m_allocator;
+    android::LinearAllocator* m_allocator;
 
     friend class Node;
 };
diff --git a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
deleted file mode 100644
index 636c30c..0000000
--- a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2012, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "LinearAllocator"
-#define LOG_NDEBUG 1
-
-#include "config.h"
-#include "LinearAllocator.h"
-
-#include "AndroidLog.h"
-
-namespace WebCore {
-
-// The ideal size of a page allocation (these need to be multiples of 4)
-#define INITIAL_PAGE_SIZE ((size_t)4096) // 4kb
-#define MAX_PAGE_SIZE ((size_t)131072) // 128kb
-
-// The maximum amount of wasted space we can have per page
-// Allocations exceeding this will have their own dedicated page
-// If this is too low, we will malloc too much
-// Too high, and we may waste too much space
-// Must be smaller than INITIAL_PAGE_SIZE
-#define MAX_WASTE_SIZE ((size_t)1024)
-
-#if CPU(MIPS)
-#define ALIGN_SZ (sizeof(double))
-#else
-#define ALIGN_SZ (sizeof(int))
-#endif
-
-#define ALIGN(x) ((x + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1))
-#define ALIGN_PTR(p) ((void*)(ALIGN((unsigned int)p)))
-
-#if LOG_NDEBUG
-#define ADD_ALLOCATION(size)
-#define RM_ALLOCATION(size)
-#else
-#include <utils/Thread.h>
-static size_t s_totalAllocations = 0;
-static double s_lastLogged = 0;
-static android::Mutex s_mutex;
-
-static void _logUsageLocked() {
-    double now = currentTimeMS();
-    if (now - s_lastLogged > 5) {
-        s_lastLogged = now;
-        ALOGV("Total memory usage: %d kb", s_totalAllocations / 1024);
-    }
-}
-
-static void _addAllocation(size_t size) {
-    android::AutoMutex lock(s_mutex);
-    s_totalAllocations += size;
-    _logUsageLocked();
-}
-
-#define ADD_ALLOCATION(size) _addAllocation(size);
-#define RM_ALLOCATION(size) _addAllocation(-size);
-#endif
-
-class LinearAllocator::Page {
-public:
-    Page* next() { return m_nextPage; }
-    void setNext(Page* next) { m_nextPage = next; }
-
-    Page()
-        : m_nextPage(0)
-    {}
-
-    void* start()
-    {
-        return (void*) (((unsigned)this) + sizeof(LinearAllocator::Page));
-    }
-
-    void* end(int pageSize)
-    {
-        return (void*) (((unsigned)start()) + pageSize);
-    }
-
-private:
-    Page(const Page& other) {}
-    Page* m_nextPage;
-};
-
-LinearAllocator::LinearAllocator()
-    : m_pageSize(INITIAL_PAGE_SIZE)
-    , m_maxAllocSize(MAX_WASTE_SIZE)
-    , m_next(0)
-    , m_currentPage(0)
-    , m_pages(0)
-    , m_totalAllocated(0)
-    , m_wastedSpace(0)
-    , m_pageCount(0)
-    , m_dedicatedPageCount(0)
-{
-}
-
-LinearAllocator::~LinearAllocator(void)
-{
-    Page* p = m_pages;
-    while (p) {
-        Page* next = p->next();
-        delete p;
-        RM_ALLOCATION(m_pageSize);
-        p = next;
-    }
-}
-
-void* LinearAllocator::start(Page* p)
-{
-    return ALIGN_PTR(((char*)p) + sizeof(Page));
-}
-
-void* LinearAllocator::end(Page* p)
-{
-    return ((char*)p) + m_pageSize;
-}
-
-bool LinearAllocator::fitsInCurrentPage(size_t size)
-{
-    return m_next && ((char*)m_next + size) <= end(m_currentPage);
-}
-
-void LinearAllocator::ensureNext(size_t size)
-{
-    if (fitsInCurrentPage(size))
-        return;
-    if (m_currentPage && m_pageSize < MAX_PAGE_SIZE) {
-        m_pageSize = std::min(MAX_PAGE_SIZE, m_pageSize * 2);
-        m_pageSize = ALIGN(m_pageSize);
-    }
-    m_wastedSpace += m_pageSize;
-    Page* p = newPage(m_pageSize);
-    if (m_currentPage)
-        m_currentPage->setNext(p);
-    m_currentPage = p;
-    if (!m_pages)
-        m_pages = m_currentPage;
-    m_next = start(m_currentPage);
-}
-
-void* LinearAllocator::alloc(size_t size)
-{
-    size = ALIGN(size);
-    if (size > m_maxAllocSize && !fitsInCurrentPage(size)) {
-        ALOGV("Exceeded max size %d > %d", size, m_maxAllocSize);
-        // Allocation is too large, create a dedicated page for the allocation
-        Page* page = newPage(size);
-        m_dedicatedPageCount++;
-        page->setNext(m_pages);
-        m_pages = page;
-        if (!m_currentPage)
-            m_currentPage = m_pages;
-        return start(page);
-    }
-    ensureNext(size);
-    void* ptr = m_next;
-    m_next = ((char*)m_next) + size;
-    m_wastedSpace -= size;
-    return ptr;
-}
-
-void LinearAllocator::rewindIfLastAlloc(void* ptr, size_t allocSize)
-{
-    // Don't bother rewinding across pages
-    allocSize = ALIGN(allocSize);
-    if (ptr >= start(m_currentPage) && ptr < end(m_currentPage)
-            && ptr == ((char*)m_next - allocSize)) {
-        m_totalAllocated -= allocSize;
-        m_wastedSpace += allocSize;
-        m_next = ptr;
-    }
-}
-
-LinearAllocator::Page* LinearAllocator::newPage(size_t pageSize)
-{
-    pageSize = ALIGN(pageSize + sizeof(LinearAllocator::Page));
-    ADD_ALLOCATION(pageSize);
-    m_totalAllocated += pageSize;
-    m_pageCount++;
-    void* buf = malloc(pageSize);
-    return new (buf) Page();
-}
-
-static const char* toSize(size_t value, float& result)
-{
-    if (value < 2000) {
-        result = value;
-        return "B";
-    }
-    if (value < 2000000) {
-        result = value / 1024.0f;
-        return "KB";
-    }
-    result = value / 1048576.0f;
-    return "MB";
-}
-
-void LinearAllocator::dumpMemoryStats(const char* prefix)
-{
-    float prettySize;
-    const char* prettySuffix;
-    prettySuffix = toSize(m_totalAllocated, prettySize);
-    ALOGD("%sTotal allocated: %.2f%s", prefix, prettySize, prettySuffix);
-    prettySuffix = toSize(m_wastedSpace, prettySize);
-    ALOGD("%sWasted space: %.2f%s (%.1f%%)", prefix, prettySize, prettySuffix,
-          (float) m_wastedSpace / (float) m_totalAllocated * 100.0f);
-    ALOGD("%sPages %d (dedicated %d)", prefix, m_pageCount, m_dedicatedPageCount);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h
deleted file mode 100644
index 8cabf7c..0000000
--- a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2012, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LinearAllocator_h
-#define LinearAllocator_h
-
-namespace WebCore {
-
-class LinearAllocator
-{
-public:
-    LinearAllocator();
-    ~LinearAllocator();
-
-    void* alloc(size_t size);
-    void rewindIfLastAlloc(void* ptr, size_t allocSize);
-
-    void dumpMemoryStats(const char* prefix = "");
-
-private:
-    LinearAllocator(const LinearAllocator& other);
-
-    class Page;
-
-    Page* newPage(size_t pageSize);
-    bool fitsInCurrentPage(size_t size);
-    void ensureNext(size_t size);
-    void* start(Page *p);
-    void* end(Page* p);
-
-    size_t m_pageSize;
-    size_t m_maxAllocSize;
-    void* m_next;
-    Page* m_currentPage;
-    Page* m_pages;
-
-    // Memory usage tracking
-    size_t m_totalAllocated;
-    size_t m_wastedSpace;
-    size_t m_pageCount;
-    size_t m_dedicatedPageCount;
-};
-
-} // namespace WebCore
-
-#endif // LinearAllocator_h
diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk
index 07634b6..d440899 100644
--- a/Source/WebKit/Android.mk
+++ b/Source/WebKit/Android.mk
@@ -58,7 +58,6 @@
 	android/content/PhoneEmailDetector.cpp \
 	\
 	android/jni/AndroidHitTestResult.cpp \
-	android/jni/CacheManager.cpp \
 	android/jni/CookieManager.cpp \
 	android/jni/DeviceMotionAndOrientationManager.cpp \
 	android/jni/DeviceMotionClientImpl.cpp \
diff --git a/Source/WebKit/android/jni/CacheManager.cpp b/Source/WebKit/android/jni/CacheManager.cpp
deleted file mode 100644
index b34776d..0000000
--- a/Source/WebKit/android/jni/CacheManager.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "ChromiumIncludes.h"
-#include "WebCache.h"
-#include "WebCoreJni.h"
-
-#include <JNIHelp.h>
-#include <platform/FileSystem.h>
-#include <platform/text/Base64.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-using namespace WebCore;
-using namespace base;
-using namespace disk_cache;
-using namespace net;
-using namespace std;
-
-namespace android {
-
-// JNI for android.webkit.CacheManager
-static const char* javaCacheManagerClass = "android/webkit/CacheManager";
-
-static void setStringField(JNIEnv* env, const jobject& object, const jfieldID& field, const String& str)
-{
-    jstring jstr = wtfStringToJstring(env, str);
-    env->SetObjectField(object, field, jstr);
-    env->DeleteLocalRef(jstr);
-}
-
-static void setFieldFromHeaderIfPresent(CacheResult* result, const char* header, JNIEnv* env, const jobject& object, const jfieldID& field, bool allowEmptyString)
-{
-  String value;
-  if (result->firstResponseHeader(header, &value, allowEmptyString))
-      setStringField(env, object, field, value);
-}
-
-static String getCacheFileBaseDir(JNIEnv* env)
-{
-    static String baseDir;
-    if (baseDir.isEmpty()) {
-        jclass cacheManagerClass = env->FindClass("android/webkit/CacheManager");
-        jmethodID getCacheFileBaseDirMethod = env->GetStaticMethodID(cacheManagerClass, "getCacheFileBaseDir", "()Ljava/io/File;");
-        jclass fileClass = env->FindClass("java/io/File");
-        jmethodID getPathMethod = env->GetMethodID(fileClass, "getPath", "()Ljava/lang/String;");
-        jobject fileObject = env->CallStaticObjectMethod(cacheManagerClass, getCacheFileBaseDirMethod);
-        baseDir = jstringToWtfString(env, static_cast<jstring>(env->CallObjectMethod(fileObject, getPathMethod)));
-    }
-    return baseDir;
-}
-
-static jobject getCacheResult(JNIEnv* env, jobject, jstring url)
-{
-    // This is called on the UI thread.
-    scoped_refptr<CacheResult> result = WebCache::get(false /*privateBrowsing*/)->getCacheResult(jstringToWtfString(env, url));
-    if (!result)
-        return 0;
-
-    // We create and populate a file with the cache entry. This allows us to
-    // replicate the behaviour of the Android HTTP stack in the Java
-    // CacheManager, which opens the cache file and provides an input stream to
-    // the file as part of the Java CacheResult object!
-    String urlWtfString = jstringToWtfString(env, url);
-    Vector<char> encodedUrl;
-    base64Encode(urlWtfString.utf8().data(), urlWtfString.length(), encodedUrl, false /*insertLFs*/);
-    encodedUrl.append('\0');
-    String filePath = pathByAppendingComponent(getCacheFileBaseDir(env), encodedUrl.data());
-    if (!result->writeToFile(filePath))
-        return 0;
-
-    jclass cacheResultClass = env->FindClass("android/webkit/CacheManager$CacheResult");
-    jmethodID constructor = env->GetMethodID(cacheResultClass, "<init>", "()V");
-    // We only bother with the fields that are made accessible through the public API.
-    jfieldID contentdispositionField = env->GetFieldID(cacheResultClass, "contentdisposition", "Ljava/lang/String;");
-    jfieldID contentLengthField = env->GetFieldID(cacheResultClass, "contentLength", "J");
-    jfieldID etagField = env->GetFieldID(cacheResultClass, "etag", "Ljava/lang/String;");
-    jfieldID encodingField = env->GetFieldID(cacheResultClass, "encoding", "Ljava/lang/String;");
-    jfieldID expiresField = env->GetFieldID(cacheResultClass, "expires", "J");
-    jfieldID expiresStringField = env->GetFieldID(cacheResultClass, "expiresString", "Ljava/lang/String;");
-    jfieldID httpStatusCodeField = env->GetFieldID(cacheResultClass, "httpStatusCode", "I");
-    jfieldID lastModifiedField = env->GetFieldID(cacheResultClass, "lastModified", "Ljava/lang/String;");
-    jfieldID localPathField = env->GetFieldID(cacheResultClass, "localPath", "Ljava/lang/String;");
-    jfieldID locationField = env->GetFieldID(cacheResultClass, "location", "Ljava/lang/String;");
-    jfieldID mimeTypeField = env->GetFieldID(cacheResultClass, "mimeType", "Ljava/lang/String;");
-
-    jobject javaResult = env->NewObject(cacheResultClass, constructor);
-    setFieldFromHeaderIfPresent(result.get(), "content-disposition", env, javaResult, contentdispositionField, true);
-    env->SetLongField(javaResult, contentLengthField, result->contentSize());
-    setFieldFromHeaderIfPresent(result.get(), "etag", env, javaResult, etagField, false);
-    setStringField(env, javaResult, encodingField, "TODO"); // TODO: Where does the Android stack set this?
-    env->SetLongField(javaResult, expiresField, result->expires());
-    env->SetIntField(javaResult, httpStatusCodeField, result->responseCode());
-    setFieldFromHeaderIfPresent(result.get(), "last-modified", env, javaResult, lastModifiedField, false);
-    setStringField(env, javaResult, localPathField, encodedUrl.data());
-    setFieldFromHeaderIfPresent(result.get(), "location", env, javaResult, locationField, false);
-    setStringField(env, javaResult, mimeTypeField, result->mimeType());
-
-    return javaResult;
-}
-
-static JNINativeMethod gCacheManagerMethods[] = {
-    { "nativeGetCacheResult", "(Ljava/lang/String;)Landroid/webkit/CacheManager$CacheResult;", (void*) getCacheResult },
-};
-
-int registerCacheManager(JNIEnv* env)
-{
-#ifndef NDEBUG
-    jclass cacheManager = env->FindClass(javaCacheManagerClass);
-    ALOG_ASSERT(cacheManager, "Unable to find class");
-    env->DeleteLocalRef(cacheManager);
-#endif
-    return jniRegisterNativeMethods(env, javaCacheManagerClass, gCacheManagerMethods, NELEM(gCacheManagerMethods));
-}
-
-} // namespace android
diff --git a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
index ec052f1..d4b1ddb 100644
--- a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
+++ b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
@@ -91,7 +91,6 @@
 #endif
 extern int registerDeviceMotionAndOrientationManager(JNIEnv*);
 extern int registerCookieManager(JNIEnv*);
-extern int registerCacheManager(JNIEnv*);
 
 }
 
@@ -120,7 +119,6 @@
 #endif
     { "DeviceMotionAndOrientationManager", android::registerDeviceMotionAndOrientationManager },
     { "CookieManager", android::registerCookieManager },
-    { "CacheManager", android::registerCacheManager },
 };
 
 EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
diff --git a/Source/WebKit/android/plugins/ANPSoundInterface.cpp b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
index 929832b..0ea9b07 100644
--- a/Source/WebKit/android/plugins/ANPSoundInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
@@ -36,6 +36,7 @@
     void*                mUser;
     ANPAudioCallbackProc mProc;
     android::AudioTrack* mTrack;
+    int                  mChannelCount;
 };
 
 static ANPSampleFormat toANPFormat(audio_format_t fm) {
@@ -70,8 +71,8 @@
             
             src = reinterpret_cast<android::AudioTrack::Buffer*>(info);
             dst.bufferData      = src->raw;
-            dst.channelCount    = src->channelCount;
-            dst.format          = toANPFormat((audio_format_t) src->format);
+            dst.channelCount    = track->mChannelCount;
+            dst.format          = toANPFormat(AUDIO_FORMAT_PCM_16_BIT);
             dst.size            = src->size;
             track->mProc(kMoreData_ANPAudioEvent, track->mUser, &dst);
             // return the updated size field
@@ -106,6 +107,7 @@
                                             callbackProc,
                                             track,
                                             0);
+    track->mChannelCount = channelCount;
     
     if (track->mTrack->initCheck() != 0) {  // failure
         delete track->mTrack;