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_DRIVE_DRIVE_API_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/chromeos/drive/drive_service_interface.h" | 12 #include "chrome/browser/chromeos/drive/drive_service_interface.h" |
13 #include "chrome/browser/google_apis/auth_service.h" | 13 #include "chrome/browser/google_apis/auth_service.h" |
14 #include "chrome/browser/google_apis/auth_service_observer.h" | 14 #include "chrome/browser/google_apis/auth_service_observer.h" |
15 #include "chrome/browser/google_apis/gdata_operations.h" | 15 #include "chrome/browser/google_apis/gdata_operations.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 class GURL; | 18 class GURL; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 namespace gdata { | 21 namespace gdata { |
22 class OperationRunner; | |
23 } | |
22 | 24 |
23 class OperationRunner; | 25 namespace drive { |
24 | 26 |
25 // This class provides documents feed service calls for Drive V2 API. | 27 // This class provides documents feed service calls for Drive V2 API. |
26 // Details of API call are abstracted in each operation class and this class | 28 // Details of API call are abstracted in each operation class and this class |
27 // works as a thin wrapper for the API. | 29 // works as a thin wrapper for the API. |
28 class DriveAPIService : public DriveServiceInterface, | 30 class DriveAPIService : public DriveServiceInterface, |
29 public AuthServiceObserver, | 31 public gdata::AuthServiceObserver, |
30 public OperationRegistryObserver { | 32 public gdata::OperationRegistryObserver { |
31 public: | 33 public: |
32 // Instance is usually created by DriveSystemServiceFactory and owned by | 34 // Instance is usually created by DriveSystemServiceFactory and owned by |
33 // DriveFileSystem. | 35 // DriveFileSystem. |
34 DriveAPIService(); | 36 DriveAPIService(); |
35 virtual ~DriveAPIService(); | 37 virtual ~DriveAPIService(); |
36 | 38 |
37 // DriveServiceInterface Overrides | 39 // DriveServiceInterface Overrides |
38 virtual void Initialize(Profile* profile) OVERRIDE; | 40 virtual void Initialize(Profile* profile) OVERRIDE; |
39 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; | 41 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; |
40 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; | 42 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; |
41 virtual bool CanStartOperation() const OVERRIDE; | 43 virtual bool CanStartOperation() const OVERRIDE; |
42 virtual void CancelAll() OVERRIDE; | 44 virtual void CancelAll() OVERRIDE; |
43 virtual bool CancelForFilePath(const FilePath& file_path) OVERRIDE; | 45 virtual bool CancelForFilePath(const FilePath& file_path) OVERRIDE; |
44 virtual OperationProgressStatusList GetProgressStatusList() const OVERRIDE; | 46 virtual gdata::OperationProgressStatusList GetProgressStatusList() |
hashimoto
2012/10/12 04:57:46
nit: Can we have a newline just after '(' like Aut
satorux1
2012/10/12 05:32:56
tried but looked awkward without parameters.
| |
45 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 47 const OVERRIDE; |
48 virtual void Authenticate( | |
49 const gdata::AuthStatusCallback& callback) OVERRIDE; | |
46 virtual bool HasAccessToken() const OVERRIDE; | 50 virtual bool HasAccessToken() const OVERRIDE; |
47 virtual bool HasRefreshToken() const OVERRIDE; | 51 virtual bool HasRefreshToken() const OVERRIDE; |
48 virtual void GetDocuments(const GURL& feed_url, | 52 virtual void GetDocuments(const GURL& feed_url, |
49 int64 start_changestamp, | 53 int64 start_changestamp, |
50 const std::string& search_query, | 54 const std::string& search_query, |
51 const std::string& directory_resource_id, | 55 const std::string& directory_resource_id, |
52 const GetDataCallback& callback) OVERRIDE; | 56 const gdata::GetDataCallback& callback) OVERRIDE; |
53 virtual void GetDocumentEntry(const std::string& resource_id, | 57 virtual void GetDocumentEntry( |
54 const GetDataCallback& callback) OVERRIDE; | 58 const std::string& resource_id, |
59 const gdata::GetDataCallback& callback) OVERRIDE; | |
55 | 60 |
56 virtual void GetAccountMetadata(const GetDataCallback& callback) OVERRIDE; | 61 virtual void GetAccountMetadata( |
57 virtual void GetApplicationInfo(const GetDataCallback& callback) OVERRIDE; | 62 const gdata::GetDataCallback& callback) OVERRIDE; |
58 virtual void DeleteDocument(const GURL& document_url, | 63 virtual void GetApplicationInfo( |
59 const EntryActionCallback& callback) OVERRIDE; | 64 const gdata::GetDataCallback& callback) OVERRIDE; |
65 virtual void DeleteDocument( | |
66 const GURL& document_url, | |
67 const gdata::EntryActionCallback& callback) OVERRIDE; | |
60 virtual void DownloadDocument( | 68 virtual void DownloadDocument( |
61 const FilePath& virtual_path, | 69 const FilePath& virtual_path, |
62 const FilePath& local_cache_path, | 70 const FilePath& local_cache_path, |
63 const GURL& content_url, | 71 const GURL& content_url, |
64 DocumentExportFormat format, | 72 DocumentExportFormat format, |
65 const DownloadActionCallback& callback) OVERRIDE; | 73 const gdata::DownloadActionCallback& callback) OVERRIDE; |
66 virtual void DownloadFile( | 74 virtual void DownloadFile( |
67 const FilePath& virtual_path, | 75 const FilePath& virtual_path, |
68 const FilePath& local_cache_path, | 76 const FilePath& local_cache_path, |
69 const GURL& content_url, | 77 const GURL& content_url, |
70 const DownloadActionCallback& download_action_callback, | 78 const gdata::DownloadActionCallback& download_action_callback, |
71 const GetContentCallback& get_content_callback) OVERRIDE; | 79 const gdata::GetContentCallback& get_content_callback) OVERRIDE; |
72 virtual void CopyDocument(const std::string& resource_id, | 80 virtual void CopyDocument(const std::string& resource_id, |
73 const FilePath::StringType& new_name, | 81 const FilePath::StringType& new_name, |
74 const GetDataCallback& callback) OVERRIDE; | 82 const gdata::GetDataCallback& callback) OVERRIDE; |
75 virtual void RenameResource(const GURL& document_url, | 83 virtual void RenameResource( |
76 const FilePath::StringType& new_name, | 84 const GURL& document_url, |
77 const EntryActionCallback& callback) OVERRIDE; | 85 const FilePath::StringType& new_name, |
86 const gdata::EntryActionCallback& callback) OVERRIDE; | |
78 virtual void AddResourceToDirectory( | 87 virtual void AddResourceToDirectory( |
79 const GURL& parent_content_url, | 88 const GURL& parent_content_url, |
80 const GURL& resource_url, | 89 const GURL& resource_url, |
81 const EntryActionCallback& callback) OVERRIDE; | 90 const gdata::EntryActionCallback& callback) OVERRIDE; |
82 virtual void RemoveResourceFromDirectory( | 91 virtual void RemoveResourceFromDirectory( |
83 const GURL& parent_content_url, | 92 const GURL& parent_content_url, |
84 const GURL& resource_url, | 93 const GURL& resource_url, |
85 const std::string& resource_id, | 94 const std::string& resource_id, |
86 const EntryActionCallback& callback) OVERRIDE; | 95 const gdata::EntryActionCallback& callback) OVERRIDE; |
87 virtual void CreateDirectory(const GURL& parent_content_url, | 96 virtual void CreateDirectory( |
88 const FilePath::StringType& directory_name, | 97 const GURL& parent_content_url, |
89 const GetDataCallback& callback) OVERRIDE; | 98 const FilePath::StringType& directory_name, |
90 virtual void InitiateUpload(const InitiateUploadParams& params, | 99 const gdata::GetDataCallback& callback) OVERRIDE; |
91 const InitiateUploadCallback& callback) OVERRIDE; | 100 virtual void InitiateUpload( |
92 virtual void ResumeUpload(const ResumeUploadParams& params, | 101 const gdata::InitiateUploadParams& params, |
93 const ResumeUploadCallback& callback) OVERRIDE; | 102 const gdata::InitiateUploadCallback& callback) OVERRIDE; |
103 virtual void ResumeUpload( | |
104 const gdata::ResumeUploadParams& params, | |
105 const gdata::ResumeUploadCallback& callback) OVERRIDE; | |
94 virtual void AuthorizeApp(const GURL& resource_url, | 106 virtual void AuthorizeApp(const GURL& resource_url, |
95 const std::string& app_id, | 107 const std::string& app_id, |
96 const GetDataCallback& callback) OVERRIDE; | 108 const gdata::GetDataCallback& callback) OVERRIDE; |
97 | 109 |
98 private: | 110 private: |
99 OperationRegistry* operation_registry() const; | 111 gdata::OperationRegistry* operation_registry() const; |
100 | 112 |
101 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 | 113 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 |
102 // API. If this URL is empty the call will use the default URL. Specify |url| | 114 // API. If this URL is empty the call will use the default URL. Specify |url| |
103 // when pagenated request should be issued. | 115 // when pagenated request should be issued. |
104 // |start_changestamp| specifies the starting point of change list or 0 if | 116 // |start_changestamp| specifies the starting point of change list or 0 if |
105 // all changes are necessary. | 117 // all changes are necessary. |
106 // Upon completion, invokes |callback| with results on calling thread. | 118 // Upon completion, invokes |callback| with results on calling thread. |
107 void GetChangelist(const GURL& url, | 119 void GetChangelist(const GURL& url, |
108 int64 start_changestamp, | 120 int64 start_changestamp, |
109 const GetDataCallback& callback); | 121 const gdata::GetDataCallback& callback); |
110 | 122 |
111 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If | 123 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If |
112 // this URL is empty the call will use the default URL. Specify |url| when | 124 // this URL is empty the call will use the default URL. Specify |url| when |
113 // pagenated request should be issued. | 125 // pagenated request should be issued. |
114 // |search_query| specifies query string, whose syntax is described at | 126 // |search_query| specifies query string, whose syntax is described at |
115 // https://developers.google.com/drive/search-parameters | 127 // https://developers.google.com/drive/search-parameters |
116 void GetFilelist(const GURL& url, | 128 void GetFilelist(const GURL& url, |
117 const std::string& search_query, | 129 const std::string& search_query, |
118 const GetDataCallback& callback); | 130 const gdata::GetDataCallback& callback); |
119 | 131 |
120 // AuthService::Observer override. | 132 // AuthService::Observer override. |
121 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 133 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
122 | 134 |
123 // DriveServiceObserver Overrides | 135 // DriveServiceObserver Overrides |
124 virtual void OnProgressUpdate( | 136 virtual void OnProgressUpdate( |
125 const OperationProgressStatusList& list) OVERRIDE; | 137 const gdata::OperationProgressStatusList& list) OVERRIDE; |
126 virtual void OnAuthenticationFailed(GDataErrorCode error) OVERRIDE; | 138 virtual void OnAuthenticationFailed(gdata::GDataErrorCode error) OVERRIDE; |
127 | 139 |
128 Profile* profile_; | 140 Profile* profile_; |
129 scoped_ptr<OperationRunner> runner_; | 141 scoped_ptr<gdata::OperationRunner> runner_; |
130 ObserverList<DriveServiceObserver> observers_; | 142 ObserverList<DriveServiceObserver> observers_; |
131 | 143 |
132 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 144 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
133 }; | 145 }; |
134 | 146 |
135 } // namespace gdata | 147 } // namespace drive |
136 | 148 |
137 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ | 149 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_API_SERVICE_H_ |
OLD | NEW |