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

Unified Diff: chrome/browser/web_resource/web_resource_service.h

Issue 10690096: Extracted inner class doing process dispatch. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding comment. Created 8 years, 5 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: chrome/browser/web_resource/web_resource_service.h
diff --git a/chrome/browser/web_resource/web_resource_service.h b/chrome/browser/web_resource/web_resource_service.h
index af44a477d30478b9d37aedbf8246598d312133f3..cc27b581ef8ac62ff58dcf058a1a54c9d82d1863 100644
--- a/chrome/browser/web_resource/web_resource_service.h
+++ b/chrome/browser/web_resource/web_resource_service.h
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/web_resource/json_asynchronous_unpacker.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -28,8 +29,9 @@ class URLFetcher;
// A WebResourceService fetches JSON data from a web server and periodically
// refreshes it.
class WebResourceService
- : public base::RefCountedThreadSafe<WebResourceService>,
- public net::URLFetcherDelegate {
+ : public net::URLFetcherDelegate,
+ public JSONAsynchronousUnpackerDelegate,
+ public base::RefCountedThreadSafe<WebResourceService> {
public:
WebResourceService(PrefService* prefs,
const GURL& web_resource_server,
@@ -43,9 +45,14 @@ class WebResourceService
// Then begin updating resources.
void StartAfterDelay();
+ // JSONAsynchronousUnpackerDelegate methods.
+ virtual void OnUnpackFinished(const DictionaryValue& parsed_json) OVERRIDE;
+ virtual void OnUnpackError(const std::string& error_message) OVERRIDE;
+
protected:
virtual ~WebResourceService();
+ // For the subclasses to process the result of a fetch.
virtual void Unpack(const base::DictionaryValue& parsed_json) = 0;
PrefService* prefs_;
@@ -73,6 +80,10 @@ class WebResourceService
// The tool that fetches the url data from the server.
scoped_ptr<net::URLFetcher> url_fetcher_;
+ // The tool that parses and transform the json data. Weak reference as it
+ // deletes itself once the unpack is done.
+ JSONAsynchronousUnpacker* json_unpacker_;
+
// True if we are currently fetching or unpacking data. If we are asked to
// start a fetch when we are still fetching resource data, schedule another
// one in |cache_update_delay_ms_| time, and silently exit.
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | chrome/browser/web_resource/web_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698