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

Unified Diff: chrome/browser/chromeos/gdata/operations_base.h

Issue 10808027: gdrive: Get JSON feeds parsing off the UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Call NotifyFinish/NotifySuccess after parse. 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/chromeos/gdata/operations_base.h
diff --git a/chrome/browser/chromeos/gdata/operations_base.h b/chrome/browser/chromeos/gdata/operations_base.h
index cf8ee2c78eda275d794106450fff89f24c057c60..3cb5898abb775f7b3f3a0e81079e38ad73d655a0 100644
--- a/chrome/browser/chromeos/gdata/operations_base.h
+++ b/chrome/browser/chromeos/gdata/operations_base.h
@@ -20,6 +20,9 @@ class OAuth2AccessTokenFetcher;
namespace gdata {
+// Callback type for ProcessURLFetchResults.
+typedef base::Callback<void(bool result)> ProcessURLFetchResultsCallBack;
hashimoto 2012/07/20 04:07:37 nit: s/CallBack/Callback/ We use 'callback' as one
yoshiki 2012/07/24 16:58:32 Done
hashimoto 2012/07/25 06:14:21 How about making OnDataParsed() a private method o
+
//================================ AuthOperation ===============================
// OAuth2 authorization token retrieval operation.
@@ -111,7 +114,9 @@ class UrlFetchOperationBase : public GDataOperationInterface,
// Invoked by OnURLFetchComplete when the operation completes without an
// authentication error. Must be implemented by a derived class.
- virtual bool ProcessURLFetchResults(const net::URLFetcher* source) = 0;
+ virtual void ProcessURLFetchResults(
+ const net::URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& callback) = 0;
// Invoked when it needs to notify the status. Chunked operations that
// constructs a logically single operation from multiple physical operations
@@ -129,6 +134,9 @@ class UrlFetchOperationBase : public GDataOperationInterface,
// Overridden from URLFetcherDelegate.
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+ // Invoked when ProcessURLFetchResults() is completed.
+ void OnProcessURLFetchResultsComplete(bool result);
+
// Overridden from GDataOperationInterface.
virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE;
@@ -146,6 +154,7 @@ class UrlFetchOperationBase : public GDataOperationInterface,
FilePath output_file_path_;
scoped_ptr<net::URLFetcher> url_fetcher_;
bool started_;
+ base::WeakPtrFactory<UrlFetchOperationBase> weak_ptr_factory_;
hashimoto 2012/07/20 04:07:37 Can't this be private instead of protected?
yoshiki 2012/07/24 16:58:32 Done.
};
//============================ EntryActionOperation ============================
@@ -162,7 +171,9 @@ class EntryActionOperation : public UrlFetchOperationBase {
protected:
// Overridden from UrlFetchOperationBase.
- virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
+ virtual void ProcessURLFetchResults(
+ const net::URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& callback) OVERRIDE;
virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
const GURL& document_url() const { return document_url_; }
@@ -185,15 +196,24 @@ class GetDataOperation : public UrlFetchOperationBase {
virtual ~GetDataOperation();
// Parse GData JSON response.
- virtual base::Value* ParseResponse(const std::string& data);
+ virtual void ParseResponse(
+ GDataErrorCode fetch_error_code,
+ const std::string& data,
+ const ProcessURLFetchResultsCallBack& result_callback);
protected:
// Overridden from UrlFetchOperationBase.
- virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
- virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
+ virtual void ProcessURLFetchResults(
+ const net::URLFetcher* source,
+ const ProcessURLFetchResultsCallBack& callback) OVERRIDE;
+ virtual void RunCallbackOnPrematureFailure(
+ GDataErrorCode fetch_error_code) OVERRIDE;
+ void RunCallback(GDataErrorCode fetch_error_code,
+ scoped_ptr<base::Value> value);
private:
GetDataCallback callback_;
+
DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
};

Powered by Google App Engine
This is Rietveld 408576698