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

Unified Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/tools/tld_cleanup/tld_cleanup_util_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/base/sdch_dictionary_fetcher.h b/net/url_request/sdch_dictionary_fetcher.h
similarity index 63%
rename from net/base/sdch_dictionary_fetcher.h
rename to net/url_request/sdch_dictionary_fetcher.h
index d74f64341e77803a4ec2aa62316ad69cfd6c2ca0..5b6f269e56cfc6e1d6800e7fc7beea310c666f21 100644
--- a/net/base/sdch_dictionary_fetcher.h
+++ b/net/url_request/sdch_dictionary_fetcher.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// TODO(rdsmith): This class needs to be moved out to the net/ embedder and
-// hooked into whatever mechanisms the embedder uses for authentication.
-// Specifically, this class needs methods overriding
-// URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested} and can't
-// implement them at the net/ layer.
+// TODO(rdsmith): This class needs to delegate URLRequest::Delegate methods
+// to the net/ embedder for correct implementation of authentication.
+// Specifically, this class needs the embedder to provide functionality
+// corresponding to
+// URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested}.
-#ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_
-#define NET_BASE_SDCH_DICTIONARY_FETCHER_H_
+#ifndef NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
+#define NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
#include <queue>
#include <set>
@@ -27,25 +27,31 @@ namespace net {
class URLRequest;
class URLRequestThrottlerEntryInterface;
-// This class implements the SdchFetcher interface. It queues requests
-// for dictionaries and dispatches them serially, implementing
-// the URLRequest::Delegate interface to handle callbacks (but see above
-// TODO). It tracks all requests, only attempting to fetch each dictionary
-// once.
-class NET_EXPORT SdchDictionaryFetcher
- : public SdchFetcher,
- public URLRequest::Delegate,
- public base::NonThreadSafe {
+// This class is used by embedder SDCH policy object to fetch
+// dictionaries. It queues requests for dictionaries and dispatches
+// them serially, implementing the URLRequest::Delegate interface to
+// handle callbacks (but see above TODO). It tracks all requests, only
+// attempting to fetch each dictionary once.
+class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
+ public base::NonThreadSafe {
public:
- // The consumer must guarantee that |*consumer| and |*context| outlive
- // this object.
- SdchDictionaryFetcher(SdchFetcher::Delegate* consumer,
- URLRequestContext* context);
+ typedef base::Callback<void(const std::string& dictionary_text,
+ const GURL& dictionary_url)>
+ 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() override;
- // Implementation of SdchFetcher methods.
- void Schedule(const GURL& dictionary_url) override;
- void Cancel() override;
+ // Request a new dictionary fetch.
+ void Schedule(const GURL& dictionary_url);
+
+ // Cancel any in-progress requests.
+ void Cancel();
// Implementation of URLRequest::Delegate methods.
void OnResponseStarted(URLRequest* request) override;
@@ -70,8 +76,6 @@ class NET_EXPORT SdchDictionaryFetcher
State next_state_;
bool in_loop_;
- SdchFetcher::Delegate* const consumer_;
-
// A queue of URLs that are being used to download dictionaries.
std::queue<GURL> fetch_queue_;
@@ -100,7 +104,9 @@ class NET_EXPORT SdchDictionaryFetcher
// Store the URLRequestContext associated with the owning SdchManager for
// use while fetching.
- URLRequestContext* context_;
+ URLRequestContext* const context_;
+
+ const OnDictionaryFetchedCallback dictionary_fetched_callback_;
base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_;
@@ -109,4 +115,4 @@ class NET_EXPORT SdchDictionaryFetcher
} // namespace net
-#endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_
+#endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
« no previous file with comments | « net/tools/tld_cleanup/tld_cleanup_util_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