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