Exemplo n.º 1
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;
}
Exemplo n.º 2
0
void BuyoutManager::SetRefreshLocked(const ItemLocation &loc) {
    refresh_locked_.insert(loc.GetUniqueHash());
}
Exemplo n.º 3
0
bool BuyoutManager::GetRefreshLocked(const ItemLocation &loc) const {
    return refresh_locked_.count(loc.GetUniqueHash());
}
Exemplo n.º 4
0
bool BuyoutManager::GetRefreshChecked(const ItemLocation &loc) const {
    auto it = refresh_checked_.find(loc.GetUniqueHash());
    bool refresh_checked = (it != refresh_checked_.end()) ? it->second : true;
    return (refresh_checked || GetRefreshLocked(loc));
}
Exemplo n.º 5
0
void BuyoutManager::SetRefreshChecked(const ItemLocation &loc, bool value) {
    save_needed_ = true;
    refresh_checked_[loc.GetUniqueHash()] = value;
}
Exemplo n.º 6
0
void TabCache::AddManualRefresh( const ItemLocation &location) {
    if (location.IsValid())
        manual_refresh_.insert(location.GetUniqueHash());
}