| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/browser/chromeos/gdata/auth_service.h" | |
| 13 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | |
| 14 #include "chrome/browser/chromeos/gdata/gdata_operations.h" | |
| 15 | |
| 16 class FilePath; | |
| 17 class GURL; | |
| 18 class Profile; | |
| 19 | |
| 20 namespace gdata { | |
| 21 | |
| 22 class OperationRunner; | |
| 23 | |
| 24 // This class provides documents feed service calls for Drive V2 API. | |
| 25 // Details of API call are abstracted in each operation class and this class | |
| 26 // works as a thin wrapper for the API. | |
| 27 class DriveAPIService : public DriveServiceInterface { | |
| 28 public: | |
| 29 // Instance is usually created by DriveSystemServiceFactory and owned by | |
| 30 // DriveFileSystem. | |
| 31 DriveAPIService(); | |
| 32 virtual ~DriveAPIService(); | |
| 33 | |
| 34 // DriveServiceInterface Overrides | |
| 35 virtual void Initialize(Profile* profile) OVERRIDE; | |
| 36 virtual OperationRegistry* operation_registry() const OVERRIDE; | |
| 37 virtual void CancelAll() OVERRIDE; | |
| 38 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | |
| 39 virtual bool HasAccessToken() const OVERRIDE; | |
| 40 virtual bool HasRefreshToken() const OVERRIDE; | |
| 41 virtual void GetDocuments(const GURL& feed_url, | |
| 42 int64 start_changestamp, | |
| 43 const std::string& search_query, | |
| 44 const std::string& directory_resource_id, | |
| 45 const GetDataCallback& callback) OVERRIDE; | |
| 46 virtual void GetDocumentEntry(const std::string& resource_id, | |
| 47 const GetDataCallback& callback) OVERRIDE; | |
| 48 | |
| 49 virtual void GetAccountMetadata(const GetDataCallback& callback) OVERRIDE; | |
| 50 virtual void GetApplicationInfo(const GetDataCallback& callback) OVERRIDE; | |
| 51 virtual void DeleteDocument(const GURL& document_url, | |
| 52 const EntryActionCallback& callback) OVERRIDE; | |
| 53 virtual void DownloadDocument( | |
| 54 const FilePath& virtual_path, | |
| 55 const FilePath& local_cache_path, | |
| 56 const GURL& content_url, | |
| 57 DocumentExportFormat format, | |
| 58 const DownloadActionCallback& callback) OVERRIDE; | |
| 59 virtual void DownloadFile( | |
| 60 const FilePath& virtual_path, | |
| 61 const FilePath& local_cache_path, | |
| 62 const GURL& content_url, | |
| 63 const DownloadActionCallback& download_action_callback, | |
| 64 const GetContentCallback& get_content_callback) OVERRIDE; | |
| 65 virtual void CopyDocument(const std::string& resource_id, | |
| 66 const FilePath::StringType& new_name, | |
| 67 const GetDataCallback& callback) OVERRIDE; | |
| 68 virtual void RenameResource(const GURL& document_url, | |
| 69 const FilePath::StringType& new_name, | |
| 70 const EntryActionCallback& callback) OVERRIDE; | |
| 71 virtual void AddResourceToDirectory( | |
| 72 const GURL& parent_content_url, | |
| 73 const GURL& resource_url, | |
| 74 const EntryActionCallback& callback) OVERRIDE; | |
| 75 virtual void RemoveResourceFromDirectory( | |
| 76 const GURL& parent_content_url, | |
| 77 const GURL& resource_url, | |
| 78 const std::string& resource_id, | |
| 79 const EntryActionCallback& callback) OVERRIDE; | |
| 80 virtual void CreateDirectory(const GURL& parent_content_url, | |
| 81 const FilePath::StringType& directory_name, | |
| 82 const GetDataCallback& callback) OVERRIDE; | |
| 83 virtual void InitiateUpload(const InitiateUploadParams& params, | |
| 84 const InitiateUploadCallback& callback) OVERRIDE; | |
| 85 virtual void ResumeUpload(const ResumeUploadParams& params, | |
| 86 const ResumeUploadCallback& callback) OVERRIDE; | |
| 87 virtual void AuthorizeApp(const GURL& resource_url, | |
| 88 const std::string& app_id, | |
| 89 const GetDataCallback& callback) OVERRIDE; | |
| 90 | |
| 91 private: | |
| 92 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 | |
| 93 // API. If this URL is empty the call will use the default URL. Specify |url| | |
| 94 // when pagenated request should be issued. | |
| 95 // |start_changestamp| specifies the starting point of change list or 0 if | |
| 96 // all changes are necessary. | |
| 97 // Upon completion, invokes |callback| with results on calling thread. | |
| 98 virtual void GetChangelist(const GURL& url, | |
| 99 int64 start_changestamp, | |
| 100 const GetDataCallback& callback); | |
| 101 | |
| 102 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If | |
| 103 // this URL is empty the call will use the default URL. Specify |url| when | |
| 104 // pagenated request should be issued. | |
| 105 // |search_query| specifies query string, whose syntax is described at | |
| 106 // https://developers.google.com/drive/search-parameters | |
| 107 virtual void GetFilelist(const GURL& url, | |
| 108 const std::string& search_query, | |
| 109 const GetDataCallback& callback); | |
| 110 | |
| 111 Profile* profile_; | |
| 112 scoped_ptr<OperationRunner> runner_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | |
| 115 }; | |
| 116 | |
| 117 } // namespace gdata | |
| 118 | |
| 119 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ | |
| OLD | NEW |