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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 std::string refresh_token_; | 176 std::string refresh_token_; |
177 std::string auth_token_; | 177 std::string auth_token_; |
178 ObserverList<Observer> observers_; | 178 ObserverList<Observer> observers_; |
179 | 179 |
180 content::NotificationRegistrar registrar_; | 180 content::NotificationRegistrar registrar_; |
181 base::WeakPtrFactory<GDataAuthService> weak_ptr_factory_; | 181 base::WeakPtrFactory<GDataAuthService> weak_ptr_factory_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(GDataAuthService); | 183 DISALLOW_COPY_AND_ASSIGN(GDataAuthService); |
184 }; | 184 }; |
185 | 185 |
186 // This defines an interface for sharing by DocumentService and | |
187 // MockDocumentService so that we can do testing of clients of DocumentService. | |
188 class DocumentsServiceInterface { | |
189 public: | |
190 DocumentsServiceInterface(); | |
191 virtual ~DocumentsServiceInterface(); | |
192 | |
193 // Initializes the documents service tied with |profile|. | |
194 virtual void Initialize(Profile* profile) = 0; | |
195 | |
196 // Cancels all in-flight operations. | |
197 virtual void CancelAll() = 0; | |
198 | |
199 // needed. |callback| will be run with the error code and the auth | |
zel
2012/03/08 00:02:03
bad cat and paste, make sure this matches the corr
Greg Spencer (Chromium)
2012/03/08 01:10:39
Done.
| |
200 // token, on the thread this function is run. | |
201 virtual void Authenticate(const AuthStatusCallback& callback) = 0; | |
202 | |
203 // Gets the document feed from |feed_url|. If this URL is empty, the | |
204 // call will fetch the default ('root') document feed. Upon | |
205 // completion, invokes |callback| with results. | |
206 virtual void GetDocuments(const GURL& feed_url, | |
207 const GetDataCallback& callback) = 0; | |
208 | |
209 // Delete a document identified by its 'self' |url| and |etag|. | |
210 // Upon completion, invokes |callback| with results. | |
211 virtual void DeleteDocument(const GURL& document_url, | |
212 const EntryActionCallback& callback) = 0; | |
213 | |
214 // Downloads a document identified by its |content_url| in a given | |
215 // |format|. Upon completion, invokes |callback| with results. | |
216 virtual void DownloadDocument(const GURL& content_url, | |
217 DocumentExportFormat format, | |
218 const DownloadActionCallback& callback) = 0; | |
219 | |
220 // Creates new collection with |directory_name| under parent | |
221 // directory identified with |parent_content_url|. If | |
222 // |parent_content_url| is empty, the new collection will be created | |
223 // in the root. Upon completion, invokes |callback| and passes newly | |
224 // created entry. | |
225 virtual void CreateDirectory(const GURL& parent_content_url, | |
226 const FilePath::StringType& directory_name, | |
227 const GetDataCallback& callback) = 0; | |
228 | |
229 // Downloads a file identified by its |content_url|. Upon | |
230 // completion, invokes |callback| with results. | |
231 virtual void DownloadFile(const GURL& content_url, | |
232 const DownloadActionCallback& callback) = 0; | |
233 | |
234 // Initiate uploading of a document/file. | |
235 virtual void InitiateUpload(const InitiateUploadParams& upload_file_info, | |
236 const InitiateUploadCallback& callback) = 0; | |
237 | |
238 // Resume uploading of a document/file. | |
239 virtual void ResumeUpload(const ResumeUploadParams& upload_file_info, | |
240 const ResumeUploadCallback& callback) = 0; | |
241 }; | |
242 | |
186 // This class provides documents feed service calls. | 243 // This class provides documents feed service calls. |
187 class DocumentsService : public GDataAuthService::Observer { | 244 class DocumentsService |
245 : public DocumentsServiceInterface, | |
246 public GDataAuthService::Observer { | |
188 public: | 247 public: |
189 // DocumentsService is usually owned and created by GDataFileSystem. | 248 // DocumentsService is usually owned and created by GDataFileSystem. |
190 DocumentsService(); | 249 DocumentsService(); |
191 virtual ~DocumentsService(); | 250 virtual ~DocumentsService(); |
192 | 251 |
193 // Initializes the documents service tied with |profile|. | 252 // Initializes the documents service tied with |profile|. |
194 void Initialize(Profile* profile); | 253 void Initialize(Profile* profile); |
195 | 254 |
196 // Cancels all in-flight operations. | 255 // Cancels all in-flight operations. |
197 void CancelAll(); | 256 void CancelAll(); |
198 | 257 |
199 // Authenticates the user by fetching the auth token as | 258 // Authenticates the user by fetching the auth token as |
200 // needed. |callback| will be run with the error code and the auth | 259 // needed. |callback| will be run with the error code and the auth |
201 // token, on the thread this function is run. | 260 // token, on the thread this function is run. |
202 // | 261 // |
203 // Must be called on UI thread. | 262 // Must be called on UI thread. |
204 void Authenticate(const AuthStatusCallback& callback); | 263 void Authenticate(const AuthStatusCallback& callback); |
zel
2012/03/08 00:02:03
1. add comments that you are overriding DocumentsS
Greg Spencer (Chromium)
2012/03/08 01:10:39
Yeah, I had it this way, and lost it all in the la
| |
205 | 264 |
206 // Gets the document feed from |feed_url|. If this URL is empty, the call | 265 // Gets the document feed from |feed_url|. If this URL is empty, the call |
207 // will fetch the default ('root') document feed. Upon completion, | 266 // will fetch the default ('root') document feed. Upon completion, |
208 // invokes |callback| with results on the calling thread. | 267 // invokes |callback| with results on the calling thread. |
209 // | 268 // |
210 // Can be called on any thread. | 269 // Can be called on any thread. |
211 void GetDocuments(const GURL& feed_url, const GetDataCallback& callback); | 270 void GetDocuments(const GURL& feed_url, const GetDataCallback& callback); |
212 | 271 |
213 // Delete a document identified by its 'self' |url| and |etag|. | 272 // Delete a document identified by its 'self' |url| and |etag|. |
214 // Upon completion, invokes |callback| with results on the calling thread. | 273 // Upon completion, invokes |callback| with results on the calling thread. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 scoped_ptr<GDataOperationRegistry> operation_registry_; | 351 scoped_ptr<GDataOperationRegistry> operation_registry_; |
293 base::WeakPtrFactory<DocumentsService> weak_ptr_factory_; | 352 base::WeakPtrFactory<DocumentsService> weak_ptr_factory_; |
294 base::WeakPtr<DocumentsService> weak_ptr_bound_to_ui_thread_; | 353 base::WeakPtr<DocumentsService> weak_ptr_bound_to_ui_thread_; |
295 | 354 |
296 DISALLOW_COPY_AND_ASSIGN(DocumentsService); | 355 DISALLOW_COPY_AND_ASSIGN(DocumentsService); |
297 }; | 356 }; |
298 | 357 |
299 } // namespace gdata | 358 } // namespace gdata |
300 | 359 |
301 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ | 360 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ |
OLD | NEW |