int AccessMap::mergeCruds(int crud1, int crud2) const { if ((crud1 == PROCEDURE_ONLY) || (crud2 == PROCEDURE_ONLY)) return PROCEDURE_ONLY; int crud = 0; if (canCreate(crud1) || canCreate(crud2)) crud += CREATE; if (canRead(crud1) || canRead(crud2)) crud += READ; if (canUpdate(crud1) || canUpdate(crud2)) crud += UPDATE; if (canDelete(crud1) || canDelete(crud2)) crud += DELETE; return crud; }
void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump) const { static const size_t kMaxURLReportLength = 128; static const int kMaxResourceClientToShowInMemoryInfra = 10; const String dumpName = getMemoryDumpName(); WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpName); dump->addScalar("encoded_size", "bytes", m_encodedSize); if (canDelete()) { dump->addScalar("dead_size", "bytes", m_encodedSize); } else { dump->addScalar("live_size", "bytes", m_encodedSize); } if (m_data) { dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0); m_data->onMemoryDump(dumpName, memoryDump); } if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { String urlToReport = url().string(); if (urlToReport.length() > kMaxURLReportLength) { urlToReport.truncate(kMaxURLReportLength); urlToReport = urlToReport + "..."; } dump->addString("url", "", urlToReport); dump->addString("reason_not_deletable", "", reasonNotDeletable()); Vector<String> clientNames; ResourceClientWalker<ResourceClient> walker(m_clients); while (ResourceClient* client = walker.next()) clientNames.append(client->debugName()); ResourceClientWalker<ResourceClient> walker2(m_clientsAwaitingCallback); while (ResourceClient* client = walker2.next()) clientNames.append("(awaiting) " + client->debugName()); ResourceClientWalker<ResourceClient> walker3(m_finishedClients); while (ResourceClient* client = walker3.next()) clientNames.append("(finished) " + client->debugName()); std::sort(clientNames.begin(), clientNames.end(), codePointCompareLessThan); StringBuilder builder; for (size_t i = 0; i < clientNames.size() && i < kMaxResourceClientToShowInMemoryInfra; ++i) { if (i > 0) builder.append(" / "); builder.append(clientNames[i]); } if (clientNames.size() > kMaxResourceClientToShowInMemoryInfra) { builder.append(" / and "); builder.appendNumber(clientNames.size() - kMaxResourceClientToShowInMemoryInfra); builder.append(" more"); } dump->addString("ResourceClient", "", builder.toString()); } const String overheadName = dumpName + "/metadata"; WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump(overheadName); overheadDump->addScalar("size", "bytes", overheadSize()); memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); }
void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump) const { static const size_t kMaxURLReportLength = 128; const String dumpName = getMemoryDumpName(); WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpName); dump->addScalar("encoded_size", "bytes", m_encodedSize); if (canDelete()) { dump->addScalar("dead_size", "bytes", m_encodedSize); } else { dump->addScalar("live_size", "bytes", m_encodedSize); } if (m_data) { dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0); m_data->onMemoryDump(dumpName, memoryDump); } if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { String urlToReport = url().string(); if (urlToReport.length() > kMaxURLReportLength) { urlToReport.truncate(kMaxURLReportLength); urlToReport = urlToReport + "..."; } dump->addString("url", "", urlToReport); } const String overheadName = dumpName + "/metadata"; WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump(overheadName); overheadDump->addScalar("size", "bytes", overheadSize()); memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); }
void CachedResource::setRequest(Request* request) { if (request && !m_request) m_status = Pending; m_request = request; if (canDelete() && !inCache()) delete this; }
bool CachedResource::deleteIfPossible() { if (canDelete() && !inCache()) { InspectorInstrumentation::willDestroyCachedResource(this); delete this; return true; } return false; }
/** * Set attributes of the node that represents this class * in the XMI document. * @param doc the xmi document * @param blockElement the xmi element holding the attributes */ void TextBlock::setAttributesOnNode(QDomDocument & doc, QDomElement & blockElement) { Q_UNUSED(doc); QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars(); blockElement.setAttribute("tag",getTag()); // only write these if different from defaults if (getIndentationLevel()) blockElement.setAttribute("indentLevel", QString::number(getIndentationLevel())); if (!m_text.isEmpty()) blockElement.setAttribute("text", encodeText(m_text, endLine)); if (!getWriteOutText()) blockElement.setAttribute("writeOutText", getWriteOutText()?"true":"false"); if (!canDelete()) blockElement.setAttribute("canDelete", canDelete()?"true":"false"); }
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); }
bool Resource::deleteIfPossible() { if (canDelete() && !memoryCache()->contains(this)) { InspectorInstrumentation::willDestroyResource(this); dispose(); memoryCache()->unregisterLiveResource(*this); #if !ENABLE(OILPAN) delete this; #endif return true; } return false; }
void CachedResource::deref(CachedResourceClient *c) { ASSERT(m_clients.contains(c)); m_clients.remove(c); if (canDelete() && !inCache()) delete this; else if (!referenced() && inCache()) { cache()->removeFromLiveResourcesSize(this); cache()->removeFromLiveDecodedResourcesList(this); allReferencesRemoved(); cache()->prune(); } }
bool CachedResource::deleteIfPossible() { if (canDelete()) { if (!inCache()) { InspectorInstrumentation::willDestroyCachedResource(*this); delete this; return true; } if (m_data) m_data->hintMemoryNotNeededSoon(); } return false; }
CachedResource::~CachedResource() { ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() checks this. ASSERT(canDelete()); ASSERT(!inCache()); ASSERT(!m_deleted); ASSERT(url().isNull() || memoryCache()->resourceForRequest(resourceRequest(), sessionID()) != this); #ifndef NDEBUG m_deleted = true; cachedResourceLeakCounter.decrement(); #endif if (m_owningCachedResourceLoader) m_owningCachedResourceLoader->removeCachedResource(this); }
void Editor::performDelete() { if (!canDelete()) return; deleteSelectionWithSmartDelete(canSmartCopyOrDelete()); }
bool Editor::canCut() const { return canCopy() && canDelete(); }