| 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..4c2db840dac6dc979f087134c91a2d626a6d717f 100644
|
| --- a/net/url_request/sdch_dictionary_fetcher.h
|
| +++ b/net/url_request/sdch_dictionary_fetcher.h
|
| @@ -35,8 +35,14 @@ class URLRequestThrottlerEntryInterface;
|
| class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
|
| public base::NonThreadSafe {
|
| public:
|
| + class Data {
|
| + public:
|
| + virtual ~Data() {}
|
| + };
|
| +
|
| typedef base::Callback<void(const std::string& dictionary_text,
|
| const GURL& dictionary_url,
|
| + scoped_ptr<Data> extra_data,
|
| const BoundNetLog& net_log)>
|
| OnDictionaryFetchedCallback;
|
|
|
| @@ -48,8 +54,14 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
|
| const OnDictionaryFetchedCallback& callback);
|
| ~SdchDictionaryFetcher() override;
|
|
|
| - // Request a new dictionary fetch.
|
| - void Schedule(const GURL& dictionary_url);
|
| + // Request a new dictionary fetch. |extra_data| is data that will be
|
| + // returned in the OnDictionaryFetchedCallback if the dictionary fetch
|
| + // succeeds; otherwise it will be destroyed.
|
| + void Schedule(const GURL& dictionary_url, scoped_ptr<Data> extra_data);
|
| +
|
| + // Request a dictionary fetch from cache only. See comment above
|
| + // for information on |extra_data|.
|
| + void ScheduleReload(const GURL& dictionary_url, scoped_ptr<Data> extra_data);
|
|
|
| // Cancel any in-progress requests.
|
| void Cancel();
|
| @@ -67,6 +79,32 @@ class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
|
| STATE_REQUEST_COMPLETE,
|
| };
|
|
|
| + struct QueuedInfo {
|
| + const GURL url;
|
| + bool download_only_from_cache;
|
| +
|
| + // Owned by |fetch_queue_|; must be destroyed if queue entry is
|
| + // dropped. Not a scoped_ptr<> as std::queue requires copyable
|
| + // types.
|
| + Data* extra_data;
|
| +
|
| + QueuedInfo() : download_only_from_cache(false), extra_data(nullptr) {}
|
| + QueuedInfo(const GURL& url,
|
| + bool download_only_from_cache,
|
| + scoped_ptr<Data> extra_data);
|
| + QueuedInfo(const QueuedInfo& rhs) = default;
|
| + QueuedInfo& operator=(const QueuedInfo& rhs) = default;
|
| + };
|
| +
|
| + // Schedule implementation.
|
| + void ScheduleInternal(const GURL& dictionary_url,
|
| + bool reload,
|
| + scoped_ptr<Data> extra_data);
|
| +
|
| + // 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 +116,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_;
|
| + scoped_ptr<Data> current_extra_data_;
|
|
|
| // The currently accumulating dictionary.
|
| std::string dictionary_;
|
|
|