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