Esempio n. 1
0
void NativeFile::setMode(Flags const &newMode)
{
    DENG2_GUARD(this);

    close();
    File::setMode(newMode);

    if (newMode.testFlag(Truncate))
    {
        d->needTruncation = true;
    }
}
Esempio n. 2
0
SqlQueryPtr AbstractDb::execListArg(const QString& query, const QList<QVariant>& args, Flags flags)
{
    if (!isOpenInternal())
        return SqlQueryPtr(new SqlErrorResults(SqlErrorCode::DB_NOT_OPEN, tr("Cannot execute query on closed database.")));

    QString newQuery = query;
    SqlQueryPtr queryStmt = prepare(newQuery);
    queryStmt->setArgs(args);
    queryStmt->setFlags(flags);
    queryStmt->execute();

    if (flags.testFlag(Flag::PRELOAD))
        queryStmt->preload();

    return queryStmt;
}
Esempio n. 3
0
QNetworkRequest TabCache::Request(const QUrl &url, const ItemLocation &location, Flags flags) {
    QNetworkRequest request{url};

    // The cache policy exists so it can override normal behavior for a given refresh.
    // Based on the current policy we may ignore refresh requests, or force refreshes
    // even if none was specifed with 'flags'.
    switch (cache_policy_) {
    case DefaultCache:
        // This is the default policy, where we honor cache policy as specified by 'flags'
        // Evict this request from the cache if refresh is requested
        if (flags.testFlag(Refresh))
            remove(url);
        break;
    case AlwaysCache:
        // By default we always try to hit in the cache, so this policy just allows
        // the normal cache mechanism to do its job and it will basically grab everything
        // from the cache that is available for all network requests
        break;
    case NeverCache:
        // We've already fully flushed the cache in OnPolicyUpdate, so nothing to do here.
        break;
    case ManualCache:
        // The case involves refreshing only an explicitily specified set of named tabs, customers
        // use AddManualRefresh to indicate what set of tabs to refresh before triggering a refresh
        // all other network requests will come from the cache if available
        if (location.IsValid() && manual_refresh_.count(location.GetUniqueHash()))
            remove(url);
        break;
    default:
        QLOG_ERROR() << "TabCache::Request Failed to handle all cache policy cases";
        break;
    };

    // At this point we've evicted any request that should be refreshed, so we always
    // tell the 'real' request to prefer but not require the entry be in the cache.
    // If it is not in the cache it will be fetched from the network regardless.
    request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, QNetworkRequest::PreferCache);

    return request;
}
Esempio n. 4
0
ReadWriteLocker::Mode AbstractDb::getLockingMode(const QString &query, Flags flags)
{
    return ReadWriteLocker::getMode(query, getDialect(), flags.testFlag(Flag::NO_LOCK));
}