void PageCache::releaseAutoreleasedPagesNow() { m_autoreleaseTimer.stop(); // Postpone dead pruning until all our resources have gone dead. memoryCache()->setPruneEnabled(false); CachedPageSet tmp; tmp.swap(m_autoreleaseSet); CachedPageSet::iterator end = tmp.end(); for (CachedPageSet::iterator it = tmp.begin(); it != end; ++it) (*it)->destroy(); // Now do the prune. memoryCache()->setPruneEnabled(true); memoryCache()->prune(); }
void SubresourceLoader::didFail(const ResourceError& error) { if (m_state != Initialized) return; ASSERT(!reachedTerminalState()); LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data()); RefPtr<SubresourceLoader> protect(this); CachedResourceHandle<CachedResource> protectResource(m_resource); m_state = Finishing; if (m_resource->resourceToRevalidate()) memoryCache()->revalidationFailed(m_resource); m_resource->setResourceError(error); m_resource->error(CachedResource::LoadError); if (!m_resource->isPreloaded()) memoryCache()->remove(m_resource); ResourceLoader::didFail(error); }
void ImageLoader::willRemoveClient(ImageLoaderClient& client) { if (client.requestsHighLiveResourceCachePriority()) { ASSERT(m_highPriorityClientCount); m_highPriorityClientCount--; if (m_image && !m_highPriorityClientCount) memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropertyChange, MemoryCacheLiveResourcePriorityLow); } }
TEST_F(ResourceFetcherTest, RevalidateDeferedResourceFromTwoInitiators) { KURL url(ParsedURLString, "http://127.0.0.1:8000/font.woff"); ResourceResponse response; response.setURL(url); response.setHTTPStatusCode(200); response.setHTTPHeaderField(HTTPNames::ETag, "1234567890"); Platform::current()->getURLLoaderMockFactory()->registerURL( url, WrappedResourceResponse(response), ""); ResourceFetcherTestMockFetchContext* context = ResourceFetcherTestMockFetchContext::create(); ResourceFetcher* fetcher = ResourceFetcher::create(context); // Fetch to cache a resource. ResourceRequest request1(url); FetchRequest fetchRequest1 = FetchRequest(request1, FetchInitiatorInfo()); Resource* resource1 = FontResource::fetch(fetchRequest1, fetcher); ASSERT_TRUE(resource1); fetcher->startLoad(resource1); Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); EXPECT_TRUE(resource1->isLoaded()); EXPECT_FALSE(resource1->errorOccurred()); // Set the context as it is on reloads. context->setLoadComplete(true); context->setCachePolicy(CachePolicyRevalidate); // Revalidate the resource. ResourceRequest request2(url); FetchRequest fetchRequest2 = FetchRequest(request2, FetchInitiatorInfo()); Resource* resource2 = FontResource::fetch(fetchRequest2, fetcher); ASSERT_TRUE(resource2); EXPECT_EQ(resource1, resource2); EXPECT_TRUE(resource2->isCacheValidator()); EXPECT_TRUE(resource2->stillNeedsLoad()); // Fetch the same resource again before actual load operation starts. ResourceRequest request3(url); FetchRequest fetchRequest3 = FetchRequest(request3, FetchInitiatorInfo()); Resource* resource3 = FontResource::fetch(fetchRequest3, fetcher); ASSERT_TRUE(resource3); EXPECT_EQ(resource2, resource3); EXPECT_TRUE(resource3->isCacheValidator()); EXPECT_TRUE(resource3->stillNeedsLoad()); // startLoad() can be called from any initiator. Here, call it from the // latter. fetcher->startLoad(resource3); Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); EXPECT_TRUE(resource3->isLoaded()); EXPECT_FALSE(resource3->errorOccurred()); EXPECT_TRUE(resource2->isLoaded()); EXPECT_FALSE(resource2->errorOccurred()); memoryCache()->remove(resource1); }
void WebProcess::platformSetCacheModel(CacheModel cacheModel) { #if USE(CFNETWORK) RetainPtr<CFStringRef> cfurlCacheDirectory; if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession()) cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(defaultStorageSession)); else cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(0)); if (!cfurlCacheDirectory) cfurlCacheDirectory = WebCore::localUserSpecificStorageDirectory().createCFString(); // As a fudge factor, use 1000 instead of 1024, in case the reported byte // count doesn't align exactly to a megabyte boundary. uint64_t memSize = memorySize() / 1024 / 1000; uint64_t diskFreeSize = volumeFreeSize(cfurlCacheDirectory.get()) / 1024 / 1000; unsigned cacheTotalCapacity = 0; unsigned cacheMinDeadCapacity = 0; unsigned cacheMaxDeadCapacity = 0; double deadDecodedDataDeletionInterval = 0; unsigned pageCacheCapacity = 0; unsigned long urlCacheMemoryCapacity = 0; unsigned long urlCacheDiskCapacity = 0; calculateCacheSizes(cacheModel, memSize, diskFreeSize, cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); pageCache()->setCapacity(pageCacheCapacity); RetainPtr<CFURLCacheRef> cfurlCache; if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession()) cfurlCache.adoptCF(wkCopyURLCache(defaultStorageSession)); else cfurlCache.adoptCF(CFURLCacheCopySharedURLCache()); CFURLCacheSetMemoryCapacity(cfurlCache.get(), urlCacheMemoryCapacity); CFURLCacheSetDiskCapacity(cfurlCache.get(), max<unsigned long>(urlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()))); // Don't shrink a big disk cache, since that would cause churn. #endif }
void Resource::cancelTimerFired(Timer<Resource>* timer) { ASSERT_UNUSED(timer, timer == &m_cancelTimer); if (hasClients() || !m_loader) return; ResourcePtr<Resource> protect(this); m_loader->cancelIfNotFinishing(); if (m_status != Cached) memoryCache()->remove(this); }
void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId) { RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(m_pageAgent->mainFrame()->document()); String actualRequestId = requestId; XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId); if (!xhrReplayData) return; CachedResource* cachedResource = memoryCache()->resourceForURL(xhrReplayData->url()); if (cachedResource) memoryCache()->remove(cachedResource); xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->async(), IGNORE_EXCEPTION); HTTPHeaderMap::const_iterator end = xhrReplayData->headers().end(); for (HTTPHeaderMap::const_iterator it = xhrReplayData->headers().begin(); it!= end; ++it) xhr->setRequestHeader(it->key, it->value, IGNORE_EXCEPTION); xhr->sendFromInspector(xhrReplayData->formData(), IGNORE_EXCEPTION); }
bool ImageLoader::shouldLoadImmediately(const KURL& url) const { // We force any image loads which might require alt content through the asynchronous path so that we can add the shadow DOM // for the alt-text content when style recalc is over and DOM mutation is allowed again. if (!url.isNull()) { Resource* resource = memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier()); if (resource && !resource->errorOccurred()) return true; } return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || url.protocolIsData()); }
TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) { KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); // Try to request a url. The request should fail, no resource should be returned, // and no resource should be present in the cache. RefPtrWillBeRawPtr<ResourceFetcher> fetcher = ResourceFetcher::create(FetchContext::create()); FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchInitiatorInfo()); ResourcePtr<ImageResource> image = fetcher->fetchImage(fetchRequest); EXPECT_EQ(image.get(), static_cast<ImageResource*>(0)); EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(0)); }
static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandidate*>& imageCandidates, unsigned winner, Document* document) { if (!document) return winner; for (unsigned i = imageCandidates.size() - 1; i > winner; --i) { KURL url = document->completeURL(stripLeadingAndTrailingHTMLSpaces(imageCandidates[i]->url())); if (memoryCache()->resourceForURL(url, document->fetcher()->getCacheIdentifier())) return i; } return winner; }
void WebCache::getResourceTypeStats(ResourceTypeStats* result) { MemoryCache* cache = memoryCache(); if (cache) { MemoryCache::Statistics stats = cache->getStatistics(); ToResourceTypeStat(stats.images, result->images); ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets); ToResourceTypeStat(stats.scripts, result->scripts); ToResourceTypeStat(stats.fonts, result->fonts); } else memset(result, 0, sizeof(WebCache::ResourceTypeStats)); }
void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet) { DCHECK(sheet); DCHECK(sheet->isCacheableForResource()); if (!memoryCache()->contains(this)) { // This stylesheet resource did conflict with another resource and was not // added to the cache. setParsedStyleSheetCache(nullptr); return; } setParsedStyleSheetCache(sheet); }
Resource::~Resource() { ASSERT(canDelete()); RELEASE_ASSERT(!memoryCache()->contains(this)); RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this)); assertAlive(); #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK m_deleted = true; #endif InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); }
void ImageLoader::addClient(ImageLoaderClient* client) { if (client->requestsHighLiveResourceCachePriority()) { if (m_image && !m_highPriorityClientCount++) memoryCache()->updateDecodedResource(m_image.get(), UpdateForPropertyChange, MemoryCacheLiveResourcePriorityHigh); } #if ENABLE(OILPAN) m_clients.add(client, adoptPtr(new ImageLoaderClientRemover(*this, *client))); #else m_clients.add(client); #endif }
TEST_F(MemoryCacheTest, ResourcePruningAtEndOfTask_MultipleResourceMaps) { { Resource* resource1 = FakeDecodedResource::create( ResourceRequest("http://test/resource1"), Resource::Raw); Resource* resource2 = FakeDecodedResource::create( ResourceRequest("http://test/resource2"), Resource::Raw); resource1->setCacheIdentifier("foo"); testResourcePruningAtEndOfTask(resource1, resource2); memoryCache()->evictResources(); } { Resource* resource1 = FakeDecodedResource::create( ResourceRequest("http://test/resource1"), Resource::Raw); Resource* resource2 = FakeDecodedResource::create( ResourceRequest("http://test/resource2"), Resource::Raw); resource1->setCacheIdentifier("foo"); resource2->setCacheIdentifier("bar"); testResourcePruningAtEndOfTask(resource1, resource2); memoryCache()->evictResources(); } }
Resource* MemoryCacheCorrectnessTestHelper::resourceFromResourceRequest( ResourceRequest request) { if (request.url().isNull()) request.setURL(KURL(ParsedURLString, kResourceURL)); Resource* resource = createResource(request, Resource::Raw); resource->setResponse(ResourceResponse(KURL(ParsedURLString, kResourceURL), "text/html", 0, nullAtom, String())); resource->finish(); memoryCache()->add(resource); return resource; }
PassOwnPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoader* cachedResourceLoader, CachedResource* resource, bool incremental, SecurityCheckPolicy securityCheck, const ResourceLoaderOptions& options) { OwnPtr<CachedResourceRequest> request = adoptPtr(new CachedResourceRequest(cachedResourceLoader, resource, incremental)); ResourceRequest resourceRequest = resource->resourceRequest(); #if PLATFORM(CHROMIUM) resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type())); #endif if (!resource->accept().isEmpty()) resourceRequest.setHTTPAccept(resource->accept()); if (resource->isCacheValidator()) { CachedResource* resourceToRevalidate = resource->resourceToRevalidate(); ASSERT(resourceToRevalidate->canUseCacheValidator()); ASSERT(resourceToRevalidate->isLoaded()); const String& lastModified = resourceToRevalidate->response().httpHeaderField("Last-Modified"); const String& eTag = resourceToRevalidate->response().httpHeaderField("ETag"); if (!lastModified.isEmpty() || !eTag.isEmpty()) { ASSERT(cachedResourceLoader->cachePolicy() != CachePolicyReload); if (cachedResourceLoader->cachePolicy() == CachePolicyRevalidate) resourceRequest.setHTTPHeaderField("Cache-Control", "max-age=0"); if (!lastModified.isEmpty()) resourceRequest.setHTTPHeaderField("If-Modified-Since", lastModified); if (!eTag.isEmpty()) resourceRequest.setHTTPHeaderField("If-None-Match", eTag); } } #if ENABLE(LINK_PREFETCH) if (resource->type() == CachedResource::LinkPrefetch || resource->type() == CachedResource::LinkPrerender || resource->type() == CachedResource::LinkSubresource) resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); #endif ResourceLoadPriority priority = resource->loadPriority(); resourceRequest.setPriority(priority); RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), request.get(), resourceRequest, priority, securityCheck, options); if (!loader || loader->reachedTerminalState()) { // FIXME: What if resources in other frames were waiting for this revalidation? LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().string().latin1().data()); if (resource->resourceToRevalidate()) memoryCache()->revalidationFailed(resource); resource->error(CachedResource::LoadError); //+EAWebKitChange //10/19/2012 return PassOwnPtr<CachedResourceRequest>(std::nullptr_t()) ; //-EAWebKitChange } request->m_loader = loader; return request.release(); }
void run() override { // The resource size has to be nonzero for this test to be meaningful, but // we do not rely on it having any particular value. ASSERT_GT(m_live->size(), 0u); ASSERT_GT(m_dead->size(), 0u); ASSERT_EQ(0u, memoryCache()->deadSize()); ASSERT_EQ(0u, memoryCache()->liveSize()); memoryCache()->add(m_dead); memoryCache()->add(m_live.get()); memoryCache()->updateDecodedResource(m_live.get(), UpdateForPropertyChange); ASSERT_EQ(m_dead->size(), memoryCache()->deadSize()); ASSERT_EQ(m_live->size(), memoryCache()->liveSize()); ASSERT_GT(m_live->decodedSize(), 0u); memoryCache()->prune(); // Dead resources are pruned immediately ASSERT_EQ(m_dead->size(), memoryCache()->deadSize()); ASSERT_EQ(m_live->size(), memoryCache()->liveSize()); ASSERT_GT(m_live->decodedSize(), 0u); }
CachedCSSStyleSheet* CachedResourceLoader::requestUserCSSStyleSheet(const String& requestURL, const String& charset) { KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(KURL(KURL(), requestURL)); if (CachedResource* existing = memoryCache()->resourceForURL(url)) { if (existing->type() == CachedResource::CSSStyleSheet) return static_cast<CachedCSSStyleSheet*>(existing); memoryCache()->remove(existing); } CachedCSSStyleSheet* userSheet = new CachedCSSStyleSheet(url, charset); bool inCache = memoryCache()->add(userSheet); if (!inCache) userSheet->setInCache(true); userSheet->load(this, /*incremental*/ false, SkipSecurityCheck, /*sendResourceLoadCallbacks*/ false); if (!inCache) userSheet->setInCache(false); return userSheet; }
virtual void TearDown() { // Garbage collection is required prior to switching out the // test's memory cache; image resources are released, evicting // them from the cache. Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Heap::ForcedForTesting); // Regain the ownership of testing memory cache, so that it will be // destroyed. m_testingMemoryCache = adoptPtr(memoryCache()); // Yield the ownership of the global memory cache back. setMemoryCacheForTesting(m_globalMemoryCache.leakPtr()); }
static void getWebCoreMemoryCacheStatistics(Vector<HashMap<String, uint64_t> >& result) { DEFINE_STATIC_LOCAL(String, imagesString, (ASCIILiteral("Images"))); DEFINE_STATIC_LOCAL(String, cssString, (ASCIILiteral("CSS"))); DEFINE_STATIC_LOCAL(String, xslString, (ASCIILiteral("XSL"))); DEFINE_STATIC_LOCAL(String, javaScriptString, (ASCIILiteral("JavaScript"))); MemoryCache::Statistics memoryCacheStatistics = memoryCache()->getStatistics(); HashMap<String, uint64_t> counts; counts.set(imagesString, memoryCacheStatistics.images.count); counts.set(cssString, memoryCacheStatistics.cssStyleSheets.count); counts.set(xslString, memoryCacheStatistics.xslStyleSheets.count); counts.set(javaScriptString, memoryCacheStatistics.scripts.count); result.append(counts); HashMap<String, uint64_t> sizes; sizes.set(imagesString, memoryCacheStatistics.images.size); sizes.set(cssString, memoryCacheStatistics.cssStyleSheets.size); sizes.set(xslString, memoryCacheStatistics.xslStyleSheets.size); sizes.set(javaScriptString, memoryCacheStatistics.scripts.size); result.append(sizes); HashMap<String, uint64_t> liveSizes; liveSizes.set(imagesString, memoryCacheStatistics.images.liveSize); liveSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.liveSize); liveSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.liveSize); liveSizes.set(javaScriptString, memoryCacheStatistics.scripts.liveSize); result.append(liveSizes); HashMap<String, uint64_t> decodedSizes; decodedSizes.set(imagesString, memoryCacheStatistics.images.decodedSize); decodedSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.decodedSize); decodedSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.decodedSize); decodedSizes.set(javaScriptString, memoryCacheStatistics.scripts.decodedSize); result.append(decodedSizes); HashMap<String, uint64_t> purgeableSizes; purgeableSizes.set(imagesString, memoryCacheStatistics.images.purgeableSize); purgeableSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.purgeableSize); purgeableSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.purgeableSize); purgeableSizes.set(javaScriptString, memoryCacheStatistics.scripts.purgeableSize); result.append(purgeableSizes); HashMap<String, uint64_t> purgedSizes; purgedSizes.set(imagesString, memoryCacheStatistics.images.purgedSize); purgedSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.purgedSize); purgedSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.purgedSize); purgedSizes.set(javaScriptString, memoryCacheStatistics.scripts.purgedSize); result.append(purgedSizes); }
TEST_F(MemoryCacheTest, RemoveDuringRevalidation) { FakeResource* resource1 = FakeResource::create( ResourceRequest("http://test/resource"), Resource::Raw); memoryCache()->add(resource1); FakeResource* resource2 = FakeResource::create( ResourceRequest("http://test/resource"), Resource::Raw); memoryCache()->remove(resource1); memoryCache()->add(resource2); EXPECT_TRUE(memoryCache()->contains(resource2)); EXPECT_FALSE(memoryCache()->contains(resource1)); FakeResource* resource3 = FakeResource::create( ResourceRequest("http://test/resource"), Resource::Raw); memoryCache()->remove(resource2); memoryCache()->add(resource3); EXPECT_TRUE(memoryCache()->contains(resource3)); EXPECT_FALSE(memoryCache()->contains(resource2)); }
void WebCache::getUsageStats(UsageStats* result) { ASSERT(result); MemoryCache* cache = memoryCache(); if (cache) { result->minDeadCapacity = cache->minDeadCapacity(); result->maxDeadCapacity = cache->maxDeadCapacity(); result->capacity = cache->capacity(); result->liveSize = cache->liveSize(); result->deadSize = cache->deadSize(); } else memset(result, 0, sizeof(UsageStats)); }
bool Resource::unlock() { if (!m_data) return false; if (!m_data->isLocked()) return true; if (!memoryCache()->contains(this) || hasClients() || m_handleCount > 1 || !m_revalidatingRequest.isNull() || !m_loadFinishTime || !isSafeToUnlock()) return false; m_data->unlock(); return true; }
void WebProcess::terminate() { #ifndef NDEBUG gcController().garbageCollectNow(); memoryCache()->setDisabled(true); #endif m_webConnection->invalidate(); m_webConnection = nullptr; platformTerminate(); ChildProcess::terminate(); }
TEST(RawResourceTest, RevalidationSucceeded) { // Create two RawResources and set one to revalidate the other. RawResource* oldResourcePointer = new RawResource(ResourceRequest("data:text/html,"), Resource::Raw); RawResource* newResourcePointer = new RawResource(ResourceRequest("data:text/html,"), Resource::Raw); newResourcePointer->setResourceToRevalidate(oldResourcePointer); ResourcePtr<Resource> oldResource = oldResourcePointer; ResourcePtr<Resource> newResource = newResourcePointer; memoryCache()->add(oldResource.get()); memoryCache()->remove(oldResource.get()); memoryCache()->add(newResource.get()); // Simulate a successful revalidation. // The revalidated resource (oldResource) should now be in the cache, newResource // should have been sliently switched to point to the revalidated resource, and // we shouldn't hit any ASSERTs. ResourceResponse response; response.setHTTPStatusCode(304); newResource->responseReceived(response, nullptr); EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/html,")), oldResource.get()); EXPECT_EQ(oldResource.get(), newResource.get()); EXPECT_NE(newResource.get(), newResourcePointer); }
void SubresourceLoader::didFail(const ResourceError& error) { if (m_state != Initialized) return; ASSERT(!reachedTerminalState()); LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data()); Ref<SubresourceLoader> protect(*this); CachedResourceHandle<CachedResource> protectResource(m_resource); m_state = Finishing; m_activityAssertion.clear(); if (m_resource->resourceToRevalidate()) memoryCache()->revalidationFailed(m_resource); m_resource->setResourceError(error); if (!m_resource->isPreloaded()) memoryCache()->remove(m_resource); m_resource->error(CachedResource::LoadError); cleanupForError(error); notifyDone(); if (reachedTerminalState()) return; releaseResources(); }
void NetworkProcessConnection::didCacheResource(const ResourceRequest& request, const ShareableResource::Handle& handle) { CachedResource* resource = memoryCache()->resourceForRequest(request); if (!resource) return; RefPtr<SharedBuffer> buffer = handle.tryWrapInSharedBuffer(); if (!buffer) { LOG_ERROR("Unabled to create SharedBuffer from ShareableResource handle for resource url %s", request.url().string().utf8().data()); return; } resource->tryReplaceEncodedData(buffer.release()); }
void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId) { RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(*m_pageAgent->mainFrame()->document()); String actualRequestId = requestId; XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId); if (!xhrReplayData) return; ResourceRequest request(xhrReplayData->url()); #if ENABLE(CACHE_PARTITIONING) request.setCachePartition(m_pageAgent->mainFrame()->document()->topOrigin()->cachePartition()); #endif CachedResource* cachedResource = memoryCache()->resourceForRequest(request, m_pageAgent->page()->sessionID()); if (cachedResource) memoryCache()->remove(cachedResource); xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->async(), IGNORE_EXCEPTION); for (const auto& header : xhrReplayData->headers()) xhr->setRequestHeader(header.key, header.value, IGNORE_EXCEPTION); xhr->sendForInspectorXHRReplay(xhrReplayData->formData(), IGNORE_EXCEPTION); }
virtual void SetUp() { ASSERT_TRUE(m_bitmap.allocN32Pixels(10, 10)); m_bitmap.eraseColor(0xFFFFFFFF); ASSERT_TRUE(m_bitmap2.allocN32Pixels(5, 5)); m_bitmap2.eraseColor(0xAAAAAAAA); // Save the global memory cache to restore it upon teardown. m_globalMemoryCache = adoptPtr(memoryCache()); // Create the test memory cache instance and hook it in. m_testingMemoryCache = adoptPtr(new MemoryCache()); setMemoryCacheForTesting(m_testingMemoryCache.leakPtr()); }