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

Unified Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 664263002: Restructure SDCH layering to allow more separation (observer/1->[0,n] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd to p300953. Created 6 years, 2 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/base/sdch_dictionary_fetcher.h b/net/url_request/sdch_dictionary_fetcher.h
similarity index 65%
rename from net/base/sdch_dictionary_fetcher.h
rename to net/url_request/sdch_dictionary_fetcher.h
index d74f64341e77803a4ec2aa62316ad69cfd6c2ca0..5437307d84ce64bd2da0c214a4422f50500a4fb7 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 implementaiton of authentication.
Ryan Sleevi 2014/11/04 21:40:44 s/implementaiton/implementation/
Randy Smith (Not in Mondays) 2014/11/05 20:35:02 Done.
+// 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,32 @@ 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.
+// 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 SdchFetcher,
- public URLRequest::Delegate,
+ : public URLRequest::Delegate,
Ryan Sleevi 2014/11/04 21:40:45 Compare with how you indented the other class. Pre
Randy Smith (Not in Mondays) 2014/11/05 20:35:02 Agreed; believed made consistent via the git cl fo
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 +77,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 +105,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 +116,4 @@ class NET_EXPORT SdchDictionaryFetcher
} // namespace net
-#endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_
+#endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698