OLD | NEW |
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_GDATA_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // This class performs the operation for fetching and parsing JSON data content. | 186 // This class performs the operation for fetching and parsing JSON data content. |
187 class GetDataOperation : public UrlFetchOperationBase { | 187 class GetDataOperation : public UrlFetchOperationBase { |
188 public: | 188 public: |
189 GetDataOperation(GDataOperationRegistry* registry, | 189 GetDataOperation(GDataOperationRegistry* registry, |
190 Profile* profile, | 190 Profile* profile, |
191 const GetDataCallback& callback); | 191 const GetDataCallback& callback); |
192 virtual ~GetDataOperation(); | 192 virtual ~GetDataOperation(); |
193 | 193 |
194 // Parse GData JSON response. | 194 // Parse GData JSON response. |
195 virtual base::Value* ParseResponse(const std::string& data); | 195 virtual bool ParseResponse(GDataErrorCode fetch_error_code, |
| 196 const std::string& data); |
196 | 197 |
197 protected: | 198 protected: |
198 // Overridden from UrlFetchOperationBase. | 199 // Overridden from UrlFetchOperationBase. |
199 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) | 200 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) |
200 OVERRIDE; | 201 OVERRIDE; |
201 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 202 virtual void RunCallbackOnPrematureFailure( |
| 203 GDataErrorCode fetch_error_code) OVERRIDE; |
| 204 |
| 205 void RunCallback(GDataErrorCode fetch_error_code, |
| 206 scoped_ptr<base::Value> value); |
202 | 207 |
203 private: | 208 private: |
| 209 void OnDataParsed(GDataErrorCode fetch_error_code, |
| 210 scoped_ptr<base::Value>* value); |
| 211 |
204 GetDataCallback callback_; | 212 GetDataCallback callback_; |
| 213 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; |
| 214 |
205 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); | 215 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); |
206 }; | 216 }; |
207 | 217 |
208 //============================ GetDocumentsOperation =========================== | 218 //============================ GetDocumentsOperation =========================== |
209 | 219 |
210 // This class performs the operation for fetching a document list. | 220 // This class performs the operation for fetching a document list. |
211 class GetDocumentsOperation : public GetDataOperation { | 221 class GetDocumentsOperation : public GetDataOperation { |
212 public: | 222 public: |
213 GetDocumentsOperation(GDataOperationRegistry* registry, | 223 GetDocumentsOperation(GDataOperationRegistry* registry, |
214 Profile* profile, | 224 Profile* profile, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 virtual bool GetContentData(std::string* upload_content_type, | 446 virtual bool GetContentData(std::string* upload_content_type, |
437 std::string* upload_content) OVERRIDE; | 447 std::string* upload_content) OVERRIDE; |
438 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 448 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
439 | 449 |
440 // Overridden from GetDataOperation. | 450 // Overridden from GetDataOperation. |
441 virtual GURL GetURL() const OVERRIDE; | 451 virtual GURL GetURL() const OVERRIDE; |
442 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 452 virtual bool ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
443 | 453 |
444 // Must override GetDataOperation's ParseResponse because the response is XML | 454 // Must override GetDataOperation's ParseResponse because the response is XML |
445 // not JSON. | 455 // not JSON. |
446 virtual base::Value* ParseResponse(const std::string& data) OVERRIDE; | 456 virtual bool ParseResponse(GDataErrorCode code, |
| 457 const std::string& data) OVERRIDE; |
447 private: | 458 private: |
448 std::string app_id_; | 459 std::string app_id_; |
449 GURL document_url_; | 460 GURL document_url_; |
450 | 461 |
451 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); | 462 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); |
452 }; | 463 }; |
453 | 464 |
454 //======================= AddResourceToDirectoryOperation ====================== | 465 //======================= AddResourceToDirectoryOperation ====================== |
455 | 466 |
456 // This class performs the operation for adding a document/file/directory | 467 // This class performs the operation for adding a document/file/directory |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 ResumeUploadCallback callback_; | 586 ResumeUploadCallback callback_; |
576 ResumeUploadParams params_; | 587 ResumeUploadParams params_; |
577 bool last_chunk_completed_; | 588 bool last_chunk_completed_; |
578 | 589 |
579 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); | 590 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); |
580 }; | 591 }; |
581 | 592 |
582 } // namespace gdata | 593 } // namespace gdata |
583 | 594 |
584 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 595 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
OLD | NEW |