Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 881413003: Make SDCH dictionaries persistent across browser restart. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First round of persistence tests. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/sdch/sdch_owner_unittest.cc ('k') | net/url_request/sdch_dictionary_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/sdch_dictionary_fetcher.h
diff --git a/net/url_request/sdch_dictionary_fetcher.h b/net/url_request/sdch_dictionary_fetcher.h
index 79d87782e13ece5ef53f671d86409daed0745897..01fb8a092bcdc785e25a4d2babc846131ed3a003 100644
--- a/net/url_request/sdch_dictionary_fetcher.h
+++ b/net/url_request/sdch_dictionary_fetcher.h
@@ -41,15 +41,18 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
OnDictionaryFetchedCallback;
// The consumer must guarantee that |*context| outlives this object.
- // |callback| will be called on successful dictionary fetch
- // requested through Schedule(). |callback| will not be called
- // after object destruction.
- SdchDictionaryFetcher(URLRequestContext* context,
- const OnDictionaryFetchedCallback& callback);
+ SdchDictionaryFetcher(URLRequestContext* context);
~SdchDictionaryFetcher() override;
- // Request a new dictionary fetch.
- void Schedule(const GURL& dictionary_url);
+ // Request a new dictionary fetch. The callback will be called
+ // only if the dictionary is successfully fetched.
+ void Schedule(const GURL& dictionary_url,
+ const OnDictionaryFetchedCallback& callback);
+
+ // Request a dictionary fetch from cache only. The callback will be called
+ // only if the dictionary is successfully fetched.
+ void ScheduleReload(const GURL& dictionary_url,
+ const OnDictionaryFetchedCallback& callback);
// Cancel any in-progress requests.
void Cancel();
@@ -67,6 +70,30 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
STATE_REQUEST_COMPLETE,
};
+ struct QueuedInfo {
+ const GURL url;
+ bool download_only_from_cache;
+ OnDictionaryFetchedCallback callback;
+
+ QueuedInfo();
+ QueuedInfo(const GURL& url,
+ bool download_only_from_cache,
+ const OnDictionaryFetchedCallback& callback);
+ QueuedInfo(const QueuedInfo& rhs) = default;
+ QueuedInfo& operator=(const QueuedInfo& rhs) = default;
+
+ ~QueuedInfo();
+ };
+
+ // Schedule implementation.
+ void ScheduleInternal(const GURL& dictionary_url,
+ bool reload,
+ const OnDictionaryFetchedCallback& callback);
+
+ // Null out the current request and push the state machine to the
+ // next request, if any.
+ void ResetRequest();
+
// State machine implementation.
int DoLoop(int rv);
int DoDispatchRequest(int rv);
@@ -78,12 +105,15 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
bool in_loop_;
// A queue of URLs that are being used to download dictionaries.
- std::queue<GURL> fetch_queue_;
+ // |fetch_queue_[n].second| indicated whether the download should occur
+ // only from cache.
+ std::queue<QueuedInfo> fetch_queue_;
- // The request and buffer used for getting the current dictionary
- // Both are null when a fetch is not in progress.
+ // The request, buffer, and consumer supplied data used for getting
+ // the current dictionary. All are null when a fetch is not in progress.
scoped_ptr<URLRequest> current_request_;
scoped_refptr<IOBuffer> buffer_;
+ OnDictionaryFetchedCallback current_callback_;
// The currently accumulating dictionary.
std::string dictionary_;
@@ -107,8 +137,6 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
// use while fetching.
URLRequestContext* const context_;
- const OnDictionaryFetchedCallback dictionary_fetched_callback_;
-
base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
« no previous file with comments | « net/sdch/sdch_owner_unittest.cc ('k') | net/url_request/sdch_dictionary_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698