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

Side by Side Diff: chrome/browser/chromeos/gdata/operations_base.h

Issue 10836011: Revert 148990 - gdrive: Get JSON feeds parsing off the UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // override this method to specify any extra headers needed for the request. 105 // override this method to specify any extra headers needed for the request.
106 virtual std::vector<std::string> GetExtraRequestHeaders() const; 106 virtual std::vector<std::string> GetExtraRequestHeaders() const;
107 // Used by a derived class to add any content data to the request. 107 // Used by a derived class to add any content data to the request.
108 // Returns true if |upload_content_type| and |upload_content| are updated 108 // Returns true if |upload_content_type| and |upload_content| are updated
109 // with the content type and data for the request. 109 // with the content type and data for the request.
110 virtual bool GetContentData(std::string* upload_content_type, 110 virtual bool GetContentData(std::string* upload_content_type,
111 std::string* upload_content); 111 std::string* upload_content);
112 112
113 // Invoked by OnURLFetchComplete when the operation completes without an 113 // Invoked by OnURLFetchComplete when the operation completes without an
114 // authentication error. Must be implemented by a derived class. 114 // authentication error. Must be implemented by a derived class.
115 virtual void ProcessURLFetchResults(const net::URLFetcher* source) = 0; 115 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) = 0;
116 116
117 // Invoked when it needs to notify the status. Chunked operations that 117 // Invoked when it needs to notify the status. Chunked operations that
118 // constructs a logically single operation from multiple physical operations 118 // constructs a logically single operation from multiple physical operations
119 // should notify resume/suspend instead of start/finish. 119 // should notify resume/suspend instead of start/finish.
120 virtual void NotifyStartToOperationRegistry(); 120 virtual void NotifyStartToOperationRegistry();
121 virtual void NotifySuccessToOperationRegistry(); 121 virtual void NotifySuccessToOperationRegistry();
122 122
123 // Invoked by this base class upon an authentication error or cancel by 123 // Invoked by this base class upon an authentication error or cancel by
124 // an user operation. Must be implemented by a derived class. 124 // an user operation. Must be implemented by a derived class.
125 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) = 0; 125 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) = 0;
126 126
127 // Implement GDataOperationRegistry::Operation 127 // Implement GDataOperationRegistry::Operation
128 virtual void DoCancel() OVERRIDE; 128 virtual void DoCancel() OVERRIDE;
129 129
130 // Overridden from URLFetcherDelegate. 130 // Overridden from URLFetcherDelegate.
131 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 131 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
132 132
133 // Invoked when ProcessURLFetchResults() is completed.
134 virtual void OnProcessURLFetchResultsComplete(bool result) OVERRIDE;
135
136 // Overridden from GDataOperationInterface. 133 // Overridden from GDataOperationInterface.
137 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE; 134 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE;
138 135
139 // Returns an appropriate GDataErrorCode based on the HTTP response code and 136 // Returns an appropriate GDataErrorCode based on the HTTP response code and
140 // the status of the URLFetcher. 137 // the status of the URLFetcher.
141 GDataErrorCode GetErrorCode(const net::URLFetcher* source) const; 138 GDataErrorCode GetErrorCode(const net::URLFetcher* source) const;
142 139
143 std::string GetResponseHeadersAsString( 140 std::string GetResponseHeadersAsString(
144 const net::URLFetcher* url_fetcher); 141 const net::URLFetcher* url_fetcher);
145 142
(...skipping 13 matching lines...) Expand all
159 class EntryActionOperation : public UrlFetchOperationBase { 156 class EntryActionOperation : public UrlFetchOperationBase {
160 public: 157 public:
161 EntryActionOperation(GDataOperationRegistry* registry, 158 EntryActionOperation(GDataOperationRegistry* registry,
162 Profile* profile, 159 Profile* profile,
163 const EntryActionCallback& callback, 160 const EntryActionCallback& callback,
164 const GURL& document_url); 161 const GURL& document_url);
165 virtual ~EntryActionOperation(); 162 virtual ~EntryActionOperation();
166 163
167 protected: 164 protected:
168 // Overridden from UrlFetchOperationBase. 165 // Overridden from UrlFetchOperationBase.
169 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 166 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
170 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; 167 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
171 168
172 const GURL& document_url() const { return document_url_; } 169 const GURL& document_url() const { return document_url_; }
173 170
174 private: 171 private:
175 EntryActionCallback callback_; 172 EntryActionCallback callback_;
176 GURL document_url_; 173 GURL document_url_;
177 174
178 DISALLOW_COPY_AND_ASSIGN(EntryActionOperation); 175 DISALLOW_COPY_AND_ASSIGN(EntryActionOperation);
179 }; 176 };
180 177
181 //============================== GetDataOperation ============================== 178 //============================== GetDataOperation ==============================
182 179
183 // This class performs the operation for fetching and parsing JSON data content. 180 // This class performs the operation for fetching and parsing JSON data content.
184 class GetDataOperation : public UrlFetchOperationBase { 181 class GetDataOperation : public UrlFetchOperationBase {
185 public: 182 public:
186 GetDataOperation(GDataOperationRegistry* registry, 183 GetDataOperation(GDataOperationRegistry* registry,
187 Profile* profile, 184 Profile* profile,
188 const GetDataCallback& callback); 185 const GetDataCallback& callback);
189 virtual ~GetDataOperation(); 186 virtual ~GetDataOperation();
190 187
191 // Parse GData JSON response. 188 // Parse GData JSON response.
192 virtual void ParseResponse(GDataErrorCode fetch_error_code, 189 virtual base::Value* ParseResponse(const std::string& data);
193 const std::string& data);
194 190
195 protected: 191 protected:
196 // Overridden from UrlFetchOperationBase. 192 // Overridden from UrlFetchOperationBase.
197 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 193 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
198 virtual void RunCallbackOnPrematureFailure( 194 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
199 GDataErrorCode fetch_error_code) OVERRIDE;
200 void RunCallback(GDataErrorCode fetch_error_code,
201 scoped_ptr<base::Value> value);
202 195
203 private: 196 private:
204 // Called when ParseJsonOnBlockingPool() is completed.
205 void OnDataParsed(gdata::GDataErrorCode fetch_error_code,
206 scoped_ptr<base::Value>* value);
207
208 GetDataCallback callback_; 197 GetDataCallback callback_;
209 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_;
210 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); 198 DISALLOW_COPY_AND_ASSIGN(GetDataOperation);
211 }; 199 };
212 200
213 } // namespace gdata 201 } // namespace gdata
214 202
215 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_ 203 #endif // CHROME_BROWSER_CHROMEOS_GDATA_OPERATIONS_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operations_unittest.cc ('k') | chrome/browser/chromeos/gdata/operations_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698