Skip to content
Browse files

webkit: networking optimizations

networking features:
- memory cache
- request queue priority
- event collection mechanism

Change-Id: I19b3dbe97ceddf3651f3549dfa937577149e86d7
  • Loading branch information...
1 parent a235c4e commit 46db31e656790853824a6a359375ea6f8aaea1d9 Ebrahem Qassem committed with Whitehawkx Nov 20, 2011
View
26 Source/WebCore/dom/Document.cpp
@@ -7,6 +7,7 @@
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2008, 2009 Google Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -156,6 +157,8 @@
#include <wtf/PassRefPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringBuffer.h>
+#include <wtf/text/CString.h>
+#include <cutils/properties.h>
#if ENABLE(SHARED_WORKERS)
#include "SharedWorkerRepository.h"
@@ -226,6 +229,8 @@ using namespace std;
using namespace WTF;
using namespace Unicode;
+#include <StatHubCmdApi.h>
+
namespace WebCore {
using namespace HTMLNames;
@@ -440,6 +445,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
, m_writingModeSetOnDocumentElement(false)
, m_writeRecursionIsTooDeep(false)
, m_writeRecursionDepth(0)
+ , m_externalJs(0)
+ , m_doObjPrfth(true)
+ , m_doJsCssPrfth(false)
{
m_document = this;
@@ -512,6 +520,12 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
#if ENABLE(XHTMLMP)
m_shouldProcessNoScriptElement = !(m_frame && m_frame->script()->canExecuteScripts(NotAboutToExecuteScript));
#endif
+
+ m_doObjPrfth = StatHubIsProcReady("pp_plugin");
+ char value[PROPERTY_VALUE_MAX] = {'\0'};
+ property_get("stathub.pp.prfthmod", value, "0");
+ if (atoi(value) == 1)
+ m_doJsCssPrfth = true;
}
Document::~Document()
@@ -570,6 +584,7 @@ Document::~Document()
if (m_implementation)
m_implementation->ownerDocumentDestroyed();
+ m_externalJs = 0;
}
void Document::removedLastRef()
@@ -2319,12 +2334,23 @@ void Document::logExceptionToConsole(const String& errorMessage, int lineNumber,
addMessage(JSMessageSource, messageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL, callStack);
}
+static void updateDocumentUrl(const KURL& url) {
+
+ unsigned short main_url_len = url.string().length();
+
+ if (main_url_len && url.protocolInHTTPFamily()) {
+ StatHubUpdateMainUrl(url.string().latin1().data());
+ }
+}
+
void Document::setURL(const KURL& url)
{
const KURL& newURL = url.isEmpty() ? blankURL() : url;
if (newURL == m_url)
return;
+ updateDocumentUrl(url);
+
m_url = newURL;
m_documentURI = m_url.string();
updateBaseURL();
View
11 Source/WebCore/dom/Document.h
@@ -6,6 +6,7 @@
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -1102,6 +1103,12 @@ class Document : public TreeScope, public ScriptExecutionContext {
ContentSecurityPolicy* contentSecurityPolicy() { return m_contentSecurityPolicy.get(); }
+ int getNumExternalJs() const { return m_externalJs; }
+ void incrementNumExternalJs() { m_externalJs++; }
+
+ bool doObjectPrefetch() const { return m_doObjPrfth; }
+ bool doJsCssPrefetch() const { return m_doJsCssPrfth; }
+
protected:
Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
@@ -1402,6 +1409,10 @@ class Document : public TreeScope, public ScriptExecutionContext {
bool m_writeRecursionIsTooDeep;
unsigned m_writeRecursionDepth;
+ int m_externalJs;
+ bool m_doObjPrfth;
+ bool m_doJsCssPrfth;
+
#if ENABLE(REQUEST_ANIMATION_FRAME)
OwnPtr<ScriptedAnimationController> m_scriptedAnimationController;
#endif
View
20 Source/WebCore/html/parser/HTMLScriptRunner.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,6 +42,10 @@
#include "ScriptElement.h"
#include "ScriptSourceCode.h"
+#include <wtf/text/CString.h>
+
+#include <StatHubCmdApi.h>
+
namespace WebCore {
using namespace HTMLNames;
@@ -295,6 +300,13 @@ void HTMLScriptRunner::runScript(Element* script, const TextPosition1& scriptSta
if (!scriptElement->willBeParserExecuted())
return;
+ String currentUrl;
+ if (script->hasAttribute(srcAttr)) {
+ const String attrUrl = script->getAttribute(srcAttr);
+ currentUrl = script->document()->completeURL(attrUrl).string();
+ } else {
+ currentUrl = "inline script";
+ }
if (scriptElement->willExecuteWhenDocumentFinishedParsing())
requestDeferredScript(script);
@@ -306,8 +318,14 @@ void HTMLScriptRunner::runScript(Element* script, const TextPosition1& scriptSta
ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), scriptStartPosition);
scriptElement->executeScript(sourceCode);
}
- } else
+ } else {
requestParsingBlockingScript(script);
+ // updating JS execution
+ m_document->incrementNumExternalJs();
+ StatHubCmd(INPUT_CMD_WK_JS_SEQ,
+ (void*) currentUrl.latin1().data(), currentUrl.length()+1,
+ (void*) m_document->getNumExternalJs(), 0);
+ }
}
}
View
6 Source/WebCore/loader/MainResourceLoader.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,9 +52,12 @@
#include "SchemeRegistry.h"
#include "Settings.h"
#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
// FIXME: More that is in common with SubresourceLoader should move up into ResourceLoader.
+#include <StatHubCmdApi.h>
+
namespace WebCore {
MainResourceLoader::MainResourceLoader(Frame* frame)
@@ -478,6 +482,8 @@ void MainResourceLoader::didFinishLoading(double finishTime)
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
dl->applicationCacheHost()->finishedLoadingMainResource();
#endif
+
+ StatHubMainUrlLoaded(url().string().latin1().data());
}
void MainResourceLoader::didFail(const ResourceError& error)
View
19 Source/WebCore/loader/cache/CachedResource.cpp
@@ -4,6 +4,7 @@
Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -43,6 +44,9 @@
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+
+#include <StatHubCmdApi.h>
using namespace WTF;
@@ -108,6 +112,7 @@ CachedResource::CachedResource(const String& url, Type type)
#ifndef NDEBUG
cachedResourceLeakCounter.increment();
#endif
+ m_statHubHash = StatHubHash(url.latin1().data());
}
CachedResource::~CachedResource()
@@ -166,6 +171,20 @@ void CachedResource::error(CachedResource::Status status)
void CachedResource::finish()
{
m_status = Cached;
+ if (m_statHubHash) {
+ UrlProperty urlProperty;
+ urlProperty.bf.cacheable = canUseCacheValidator();
+ urlProperty.bf.mime_type = (unsigned int) type();
+ StatHubCmd(INPUT_CMD_WK_RES_LOAD_FINISHED, (void*)m_statHubHash, 0,
+ (void*) urlProperty.value, 0);
+ }
+}
+
+void CachedResource::setInCache(bool inCache) {
+ m_inCache = inCache;
+ if (m_statHubHash) {
+ StatHubCmd(INPUT_CMD_WK_RES_MMC_STATUS, (void*)m_statHubHash, 0, (void*)m_inCache, 0);
+ }
}
bool CachedResource::isExpired() const
View
7 Source/WebCore/loader/cache/CachedResource.h
@@ -3,6 +3,7 @@
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -150,7 +151,7 @@ class CachedResource {
// while still being referenced. This means the object should delete itself
// if the number of clients observing it ever drops to 0.
// The resource can be brought back to cache after successful revalidation.
- void setInCache(bool inCache) { m_inCache = inCache; }
+ void setInCache(bool inCache);
bool inCache() const { return m_inCache; }
void setInLiveDecodedResourcesList(bool b) { m_inLiveDecodedResourcesList = b; }
@@ -210,7 +211,7 @@ class CachedResource {
// triggering a load. We should make it protected again if we can find a
// better way to handle the archive case.
bool makePurgeable(bool purgeable);
-
+
// HTTP revalidation support methods for CachedResourceLoader.
void setResourceToRevalidate(CachedResource*);
void switchClientsToRevalidatedResource();
@@ -293,6 +294,8 @@ class CachedResource {
// These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
HashSet<CachedResourceHandleBase*> m_handlesToRevalidate;
+
+ unsigned int m_statHubHash;
};
}
View
21 Source/WebCore/loader/cache/CachedResourceLoader.cpp
@@ -4,6 +4,7 @@
Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
+ Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -53,8 +54,22 @@
#define PRELOAD_DEBUG 0
+#include <StatHubCmdApi.h>
+
namespace WebCore {
+static void SaveSubURL(CachedResourceLoader* cachedResourceLoader, CachedResource* resource) {
+ if (NULL != resource && NULL!=cachedResourceLoader) {
+ unsigned short main_url_len = cachedResourceLoader->document()->url().string().length();
+ unsigned short sub_url_len = resource->url().length();
+ if (sub_url_len && main_url_len && cachedResourceLoader->document()->url().protocolInHTTPFamily() && KURL(ParsedURLString,resource->url()).protocolInHTTPFamily()) {
+ //FIXME: the url type should have been set here, as an additional parameter to StatHubUpdateSubUrl. But now a seperate update call
+ // is issued when the resource load finsishes in CachedResource::finish()
+ StatHubUpdateSubUrl(cachedResourceLoader->document()->url().string().latin1().data(), resource->url().latin1().data());
+ }
+ }
+}
+
static CachedResource* createResource(CachedResource::Type type, const KURL& url, const String& charset)
{
switch (type) {
@@ -356,6 +371,8 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type,
if (!resource)
return 0;
+ SaveSubURL(this, resource);
+
ASSERT(resource->url() == url.string());
m_documentResources.set(resource->url(), resource);
@@ -680,10 +697,10 @@ void CachedResourceLoader::preload(CachedResource::Type type, const String& url,
{
// FIXME: Rip this out when we are sure it is no longer necessary (even for mobile).
UNUSED_PARAM(referencedFromBody);
-
+ // Only preload immediately if we are doing JS/CSS prefetch
bool hasRendering = m_document->body() && m_document->body()->renderer();
bool canBlockParser = type == CachedResource::Script || type == CachedResource::CSSStyleSheet;
- if (!hasRendering && !canBlockParser) {
+ if (!hasRendering && !canBlockParser && !document()->doJsCssPrefetch()) {
// Don't preload subresources that can't block the parser before we have something to draw.
// This helps prevent preloads from delaying first display when bandwidth is limited.
PendingPreload pendingPreload = { type, url, charset };
View
5 Source/WebCore/loader/cache/MemoryCache.cpp
@@ -3,6 +3,7 @@
Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -42,6 +43,8 @@
#include <wtf/CurrentTime.h>
#include <wtf/text/CString.h>
+#include <StatHubCmdApi.h>
+
using namespace std;
namespace WebCore {
@@ -636,6 +639,8 @@ MemoryCache::Statistics MemoryCache::getStatistics()
void MemoryCache::setDisabled(bool disabled)
{
+ StatHubCmd(INPUT_CMD_WK_MMC_CLEAR, NULL, 0, NULL, 0);
+
m_disabled = disabled;
if (!m_disabled)
return;
View
35 Source/WebKit/android/WebCoreSupport/StatHubCmdApi.h
@@ -0,0 +1,35 @@
+/** ---------------------------------------------------------------------------
+Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+
+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.
+ * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+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 StatHubCmdApi_h
+#define StatHubCmdApi_h
+
+#include <net/disk_cache/stat_hub_cmd_api.h>
+
+#endif
View
9 Source/WebKit/android/WebCoreSupport/WebCache.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +33,8 @@
#include "WebUrlLoaderClient.h"
#include "net/http/http_network_session.h"
#include <wtf/text/CString.h>
+#include <net/host_resolver_helper/dyn_lib_loader.h>
+#include <net/host_resolver_helper/host_resolver_helper.h>
using namespace WTF;
using namespace disk_cache;
@@ -96,8 +99,10 @@ WebCache::WebCache(bool isPrivateBrowsing)
scoped_refptr<base::MessageLoopProxy> cacheMessageLoopProxy = ioThread->message_loop_proxy();
static const int kMaximumCacheSizeBytes = 20 * 1024 * 1024;
- m_hostResolver = net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 0, 0);
-
+ m_hostResolver = net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 0, 0,ioThread->message_loop());
+ if (!isPrivateBrowsing) {
+ m_hostPreresolver = CreateResolverIPObserver(m_hostResolver.get());
+ }
m_proxyConfigService = new ProxyConfigServiceAndroid();
net::HttpCache::BackendFactory* backendFactory;
if (isPrivateBrowsing)
View
2 Source/WebKit/android/WebCoreSupport/WebCache.h
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -68,6 +69,7 @@ class WebCache : public base::RefCountedThreadSafe<WebCache> {
void onGetEntryDone(int);
OwnPtr<net::HostResolver> m_hostResolver;
+ OwnPtr<net::HostResolver::HostnameResolverExt> m_hostPreresolver;
OwnPtr<net::HttpCache> m_cache;
// This is owned by the ProxyService, which is owned by the HttpNetworkLayer,
// which is owned by the HttpCache, which is owned by this class.
View
74 Source/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -40,6 +41,7 @@
#include <openssl/x509.h>
#include <string>
#include <androidfw/AssetManager.h>
+#include <cutils/properties.h>
extern android::AssetManager* globalAssetManager();
@@ -79,6 +81,25 @@ base::LazyInstance<RequestPackageName> s_packageName(base::LINKER_INITIALIZED);
}
+static bool ShouldSetRequestPriority()
+{
+ static bool isInitialized = false;
+ static int setPriority = 0;
+
+ if (isInitialized == false)
+ {
+ char value[10] = {'0', '\0'};
+ property_get("net.webkit.setpri", value, "1");
+ setPriority = (unsigned)atoi(value);
+
+ isInitialized = true;
+
+ __android_log_print(ANDROID_LOG_DEBUG, "netstack", "netstack: Request Priority is %s", setPriority?"ON":"OFF");
+ }
+
+ return (setPriority != 0);
+}
+
WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& webResourceRequest)
: m_urlLoader(loader)
, m_url(webResourceRequest.url())
@@ -100,6 +121,12 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web
m_request->set_referrer(webResourceRequest.referrer());
m_request->set_method(webResourceRequest.method());
m_request->set_load_flags(webResourceRequest.loadFlags());
+
+ if (ShouldSetRequestPriority())
+ {
+ ResourceType::Type chromiumTargetType = convertWebkitTargetTypeToChromiumTargetType(webResourceRequest.target_type());
+ m_request->set_priority(net::DetermineRequestPriority(chromiumTargetType));
+ }
}
// This is a special URL for Android. Query the Java InputStream
@@ -563,4 +590,51 @@ void WebRequest::OnReadCompleted(net::URLRequest* request, int bytesRead)
}
}
+// Webkit and Chromium Network Stack target type enums are not ordered in the same manner
+// An explicit conversion is needed
+ResourceType::Type WebRequest::convertWebkitTargetTypeToChromiumTargetType(WebCore::ResourceRequestBase::TargetType webkitType)
+{
+ switch (webkitType)
+ {
+ case WebCore::ResourceRequestBase::TargetIsMainFrame:
+ return ResourceType::MAIN_FRAME;
+
+ case WebCore::ResourceRequestBase::TargetIsSubframe:
+ return ResourceType::SUB_FRAME;
+
+ case WebCore::ResourceRequestBase::TargetIsSubresource:
+ return ResourceType::SUB_RESOURCE;
+
+ case WebCore::ResourceRequestBase::TargetIsStyleSheet:
+ return ResourceType::STYLESHEET;
+
+ case WebCore::ResourceRequestBase::TargetIsScript:
+ return ResourceType::SCRIPT;
+
+ case WebCore::ResourceRequestBase::TargetIsFontResource:
+ return ResourceType::FONT_RESOURCE;
+
+ case WebCore::ResourceRequestBase::TargetIsImage:
+ return ResourceType::IMAGE;
+
+ case WebCore::ResourceRequestBase::TargetIsObject:
+ return ResourceType::OBJECT;
+
+ case WebCore::ResourceRequestBase::TargetIsMedia:
+ return ResourceType::MEDIA;
+
+ case WebCore::ResourceRequestBase::TargetIsWorker:
+ return ResourceType::WORKER;
+
+ case WebCore::ResourceRequestBase::TargetIsSharedWorker:
+ return ResourceType::SHARED_WORKER;
+
+ case WebCore::ResourceRequestBase::TargetIsPrefetch:
+ return ResourceType::PREFETCH;
+
+ default:
+ return ResourceType::SUB_RESOURCE;
+ }
+}
+
} // namespace android
View
4 Source/WebKit/android/WebCoreSupport/WebRequest.h
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
#define WebRequest_h
#include "ChromiumIncludes.h"
+#include "ResourceRequestBase.h"
#include <wtf/Vector.h>
class MessageLoop;
@@ -103,6 +105,8 @@ class WebRequest : public net::URLRequest::Delegate, public base::RefCountedThre
void finish(bool success);
void updateLoadFlags(int& loadFlags);
+ ResourceType::Type convertWebkitTargetTypeToChromiumTargetType(WebCore::ResourceRequestBase::TargetType webkitType);
+
scoped_refptr<WebUrlLoaderClient> m_urlLoader;
OwnPtr<net::URLRequest> m_request;
scoped_refptr<net::IOBuffer> m_networkBuffer;
View
2 Source/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -113,6 +114,7 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
m_userAgent = resourceRequest.httpUserAgent().utf8().data();
m_url = resourceRequest.url().string().utf8().data();
+ m_type = resourceRequest.targetType();
}
} // namespace android
View
8 Source/WebKit/android/WebCoreSupport/WebResourceRequest.h
@@ -1,5 +1,6 @@
/*
* Copyright 2010, The Android Open Source Project
+ * Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +28,7 @@
#define WebResourceRequest_h
#include "ChromiumIncludes.h"
+#include "ResourceRequestBase.h"
#include <string>
@@ -71,13 +73,19 @@ class WebResourceRequest {
return m_loadFlags;
}
+ WebCore::ResourceRequestBase::TargetType target_type() const
+ {
+ return m_type;
+ }
+
private:
std::string m_method;
std::string m_referrer;
std::string m_userAgent;
net::HttpRequestHeaders m_requestHeaders;
std::string m_url;
int m_loadFlags;
+ WebCore::ResourceRequestBase::TargetType m_type;
};
} // namespace android
View
24 Source/WebKit/android/jni/JavaBridge.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2006, The Android Open Source Project
+ * Copyright (C) 2011, 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -52,6 +53,7 @@
#include <wtf/Platform.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/AtomicString.h>
+#include <cutils/properties.h>
namespace android {
@@ -375,7 +377,27 @@ void JavaBridge::SharedTimerFired(JNIEnv* env, jobject)
void JavaBridge::SetCacheSize(JNIEnv* env, jobject obj, jint bytes)
{
- WebCore::memoryCache()->setCapacities(0, bytes/2, bytes);
+ unsigned minDeadSize = 0;
+ unsigned maxDeadSize = bytes/2;
+
+ if (bytes) {
+ char value[PROPERTY_VALUE_MAX] = {'\0'};
+
+ property_get("net.webkit.cache.mindeadsize", value, "0");
+ minDeadSize = (unsigned)atoi(value);
+ if (property_get("net.webkit.cache.maxdeadsize", value, NULL) > 0) {
+ maxDeadSize = (unsigned)atoi(value);
+ }
+ // If properties are not set correctly, revert to default values
+ if (!(minDeadSize <= maxDeadSize && maxDeadSize <= (unsigned)bytes)) {
+ minDeadSize = 0;
+ maxDeadSize = bytes/2;
+ }
+ }
+
+ SLOGD("netstack: Memory Cache feature is %s", (0 == minDeadSize)?"OFF":"ON");
+
+ WebCore::memoryCache()->setCapacities(minDeadSize, maxDeadSize, bytes);
}
void JavaBridge::SetNetworkOnLine(JNIEnv* env, jobject obj, jboolean online)
View
40 Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2006, The Android Open Source Project
+ * Copyright (c) 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -107,17 +108,25 @@
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
+#include <cutils/properties.h>
+
+extern "C" void SetCloseUnUsedSocketsFlag();
+
#if ENABLE(WEB_AUTOFILL)
#include "autofill/WebAutofill.h"
#endif
+#include <StatHubCmdApi.h>
+
using namespace JSC::Bindings;
static String* gUploadFileLabel;
static String* gResetLabel;
static String* gSubmitLabel;
static String* gNoFileChosenLabel;
+static int gPageLoadCounter = 0;
+
String* WebCore::PlatformBridge::globalLocalizedName(
WebCore::PlatformBridge::rawResId resId)
{
@@ -318,6 +327,14 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mUserAgent = WTF::String();
mBlockNetworkLoads = false;
m_renderSkins = 0;
+
+ mPageLoadStarted = false;
+ mCloseUnusedSocketsEnabled = false;
+ char netCloseUnusedSocketsSystemProperty[PROPERTY_VALUE_MAX];
+ if(property_get("net.close.unused.sockets",
+ netCloseUnusedSocketsSystemProperty, "1")) {
+ mCloseUnusedSocketsEnabled = (bool)atoi(netCloseUnusedSocketsSystemProperty);
+ }
}
WebFrame::~WebFrame()
@@ -472,6 +489,16 @@ WebFrame::loadStarted(WebCore::Frame* frame)
bool isMainFrame = (!frame->tree() || !frame->tree()->parent());
WebCore::FrameLoadType loadType = frame->loader()->loadType();
+ if (isMainFrame) {
+ StatHubCmd(INPUT_CMD_WK_START_PAGE_LOAD, (void*)url.string().utf8().data(), strlen( url.string().utf8().data())+1, (void*)frame, 0);
+ if (true == mCloseUnusedSocketsEnabled) {
+ if (false == mPageLoadStarted) {
+ gPageLoadCounter++;
+ mPageLoadStarted = true;
+ }
+ }
+ }
+
if (loadType == WebCore::FrameLoadTypeReplace ||
(loadType == WebCore::FrameLoadTypeRedirectWithLockedBackForwardList &&
!isMainFrame))
@@ -548,6 +575,19 @@ WebFrame::didFinishLoad(WebCore::Frame* frame)
env->CallVoidMethod(javaFrame.get(), mJavaFrame->mLoadFinished, urlStr, static_cast<int>(loadType), isMainFrame);
checkException(env);
env->DeleteLocalRef(urlStr);
+
+ if (isMainFrame) {
+ StatHubCmd(INPUT_CMD_WK_FINISH_PAGE_LOAD, (void*)url.string().utf8().data(), strlen( url.string().utf8().data())+1, (void*)frame, 0);
+ if (true == mCloseUnusedSocketsEnabled) {
+ if ((gPageLoadCounter > 0) && (true == mPageLoadStarted)) {
+ mPageLoadStarted = false;
+ gPageLoadCounter--;
+ if(0 == gPageLoadCounter) {
+ SetCloseUnUsedSocketsFlag();
+ }
+ }
+ }
+ }
}
void
View
3 Source/WebKit/android/jni/WebCoreFrameBridge.h
@@ -1,5 +1,6 @@
/*
* Copyright 2006, The Android Open Source Project
+ * Copyright (c) 2012 Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -157,6 +158,8 @@ class WebFrame : public WebCoreRefObject {
WTF::String mUserAgent;
bool mBlockNetworkLoads;
WebCore::RenderSkinAndroid* m_renderSkins;
+ bool mPageLoadStarted;
+ bool mCloseUnusedSocketsEnabled;
};
} // namespace android

0 comments on commit 46db31e

Please sign in to comment.
Something went wrong with that request. Please try again.