From 80e68b43c3da64848db8edc7d8e8fe095888e42e Mon Sep 17 00:00:00 2001 From: Andrei Popescu Date: Tue, 8 Dec 2009 18:37:43 +0000 Subject: Break the WebCore -> WebKit dependency in ResourceHandleAndroid.cpp. --- WebKit/android/benchmark/Intercept.cpp | 41 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'WebKit/android/benchmark/Intercept.cpp') diff --git a/WebKit/android/benchmark/Intercept.cpp b/WebKit/android/benchmark/Intercept.cpp index 90cf1e1..d657353 100644 --- a/WebKit/android/benchmark/Intercept.cpp +++ b/WebKit/android/benchmark/Intercept.cpp @@ -39,14 +39,21 @@ #include #include -void MyResourceLoader::handleRequest() { +PassRefPtr MyResourceLoader::create(ResourceHandle* handle, String url) +{ + return adoptRef(new MyResourceLoader(handle, url)); +} + +void MyResourceLoader::handleRequest() +{ if (protocolIs(m_url, "data")) loadData(m_url.substring(5)); // 5 for data: else if (protocolIs(m_url, "file")) loadFile(m_url.substring(7)); // 7 for file:// } -void MyResourceLoader::loadData(const String& data) { +void MyResourceLoader::loadData(const String& data) +{ LOGD("Loading data (%s) ...", data.latin1().data()); ResourceHandleClient* client = m_handle->client(); int index = data.find(','); @@ -105,7 +112,8 @@ void MyResourceLoader::loadData(const String& data) { } client->didFinishLoading(m_handle); } -static String mimeTypeForExtension(const String& file) { +static String mimeTypeForExtension(const String& file) +{ static HashMap extensionToMime; if (extensionToMime.isEmpty()) { extensionToMime.set("txt", "text/plain"); @@ -128,7 +136,8 @@ static String mimeTypeForExtension(const String& file) { return mime; } -void MyResourceLoader::loadFile(const String& file) { +void MyResourceLoader::loadFile(const String& file) +{ LOGD("Loading file (%s) ...", file.latin1().data()); FILE* f = fopen(file.latin1().data(), "r"); ResourceHandleClient* client = m_handle->client(); @@ -152,25 +161,25 @@ void MyResourceLoader::loadFile(const String& file) { } } -WebCoreResourceLoader* MyWebFrame::startLoadingResource(ResourceHandle* handle, - const ResourceRequest& req, bool ignore) { - MyResourceLoader* loader = new MyResourceLoader(handle, req.url().string()); - Retain(loader); +PassRefPtr MyWebFrame::startLoadingResource(ResourceHandle* handle, + const ResourceRequest& req, bool ignore) +{ + RefPtr loader = MyResourceLoader::create(handle, req.url().string()); m_requests.append(loader); if (!m_timer.isActive()) m_timer.startOneShot(0); - return loader; + return loader.release(); } -void MyWebFrame::timerFired(Timer*) { +void MyWebFrame::timerFired(Timer*) +{ LOGD("Handling requests..."); - Vector reqs; + Vector > reqs; reqs.swap(m_requests); - Vector::iterator i = reqs.begin(); - Vector::iterator end = reqs.end(); - for (; i != end; i++) { + Vector >::iterator i = reqs.begin(); + Vector >::iterator end = reqs.end(); + for (; i != end; i++) (*i)->handleRequest(); - Release(*i); - } + LOGD("...done"); } -- cgit v1.1