void WebRequest::start() { ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); #ifdef LOG_REQUESTS android_printLog(ANDROID_LOG_DEBUG, "KM", "(%p) start (%d) (%s)", this, ++remaining, m_url.c_str()); time(&m_startTime); #endif m_loadState = Started; if (m_interceptResponse != NULL) return handleInterceptedURL(); // Handle data urls before we send it off to the http stack if (m_request->url().SchemeIs("data")) return handleDataURL(m_request->url()); if (m_request->url().SchemeIs("browser")) return handleBrowserURL(m_request->url()); // Update load flags with settings from WebSettings int loadFlags = m_request->load_flags(); updateLoadFlags(loadFlags); m_request->set_load_flags(loadFlags); m_request->Start(); }
void WebRequest::handleBrowserURL(GURL url) { std::string data("data:text/html;charset=utf-8,"); if (url.spec() == "browser:incognito") { AssetManager* assetManager = globalAssetManager(); Asset* asset = assetManager->open("webkit/incognito_mode_start_page.html", Asset::ACCESS_BUFFER); if (asset) { data.append((const char*)asset->getBuffer(false), asset->getLength()); delete asset; } } GURL dataURL(data.c_str()); handleDataURL(dataURL); }
void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>*) { RefPtr<ResourceHandle> protector(this); deref(); // balances ref in start if (firstRequest().url().protocolIsData()) { handleDataURL(this); return; } String fileName = firstRequest().url().fileSystemPath(); HANDLE fileHandle = CreateFileW(fileName.charactersWithNullTermination(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (fileHandle == INVALID_HANDLE_VALUE) { client()->didFail(this, ResourceError()); return; } ResourceResponse response; int dotPos = fileName.reverseFind('.'); int slashPos = fileName.reverseFind('/'); if (slashPos < dotPos && dotPos != -1) { String ext = fileName.substring(dotPos + 1); response.setMimeType(MIMETypeRegistry::getMIMETypeForExtension(ext)); } client()->didReceiveResponse(this, response); bool result = false; DWORD bytesRead = 0; do { const int bufferSize = 8192; char buffer[bufferSize]; result = ReadFile(fileHandle, &buffer, bufferSize, &bytesRead, 0); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=19793 // -1 means we do not provide any data about transfer size to inspector so it would use // Content-Length headers or content size to show transfer size. if (result && bytesRead) client()->didReceiveData(this, buffer, bytesRead, -1); // Check for end of file. } while (result && bytesRead); CloseHandle(fileHandle); client()->didFinishLoading(this, 0); }
void WebRequest::start(bool isMainResource, bool isMainFrame) //SAMSUNG_CHANGES { ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); #ifdef LOG_REQUESTS android_printLog(ANDROID_LOG_DEBUG, "KM", "(%p) start (%d) (%s)", this, ++remaining, m_url.c_str()); time(&m_startTime); #endif // SAMSUNG CHANGES : add_network_log LOGIFDEBUG("start() url(%s) isMainFrame(%d) isMainResource(%d)", m_url.c_str(), isMainResource, isMainFrame); //SAMSUNG_CHANGES >> m_isMainResource = isMainResource; m_isMainFrame = isMainFrame; //SAMSUNG_CHANGES << m_loadState = Started; if (m_interceptResponse != NULL) return handleInterceptedURL(); // Handle data urls before we send it off to the http stack if (m_request->url().SchemeIs("data")) return handleDataURL(m_request->url()); if (m_request->url().SchemeIs("browser")) return handleBrowserURL(m_request->url()); // Update load flags with settings from WebSettings int loadFlags = m_request->load_flags(); updateLoadFlags(loadFlags); m_request->set_load_flags(loadFlags); m_request->Start(); // SAMSUNG CHANGE: read timer start timer_.Start(base::TimeDelta::FromSeconds(kWebRequestReadTimeoutInSeconds), this, &WebRequest::OnReadTimeout); // SAMSUNG CHANGE }