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

Unified Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 901303002: Make SDCH dictionaries persistent across browser restart. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes 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
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 4ca25034e8e5467a7082c9efd18b40e77017eb20..eb3a542d3cc717c2699cda28d6227612672e3a83 100644
--- a/net/url_request/sdch_dictionary_fetcher.h
+++ b/net/url_request/sdch_dictionary_fetcher.h
@@ -45,15 +45,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);
mmenke 2015/02/12 20:40:36 explicit
Elly Fong-Jones 2015/02/13 23:35:01 Done.
~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();
@@ -72,6 +75,30 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
STATE_REQUEST_COMPLETE,
};
+ struct QueuedInfo {
mmenke 2015/02/12 20:40:36 QueuedFetchInfo? And maybe a quick comment...
Elly Fong-Jones 2015/02/13 23:35:01 Done.
+ GURL url;
+ bool download_only_from_cache;
+ OnDictionaryFetchedCallback callback;
mmenke 2015/02/12 20:40:36 Member variables should go after methods.
Elly Fong-Jones 2015/02/13 23:35:01 Done.
+
+ QueuedInfo();
+ QueuedInfo(const GURL& url,
+ bool download_only_from_cache,
+ const OnDictionaryFetchedCallback& callback);
+ QueuedInfo(const QueuedInfo& rhs);
+ QueuedInfo& operator=(const QueuedInfo& rhs);
mmenke 2015/02/12 20:40:36 Hrm.... Per style guide, constructor and destruct
Elly Fong-Jones 2015/02/13 23:35:01 Done.
+
+ ~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 DoSendRequest(int rv);
@@ -84,12 +111,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
mmenke 2015/02/12 20:40:36 second -> download_only_from_cache
Elly Fong-Jones 2015/02/13 23:35:01 Done.
+ // 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_;
@@ -113,8 +143,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);

Powered by Google App Engine
This is Rietveld 408576698