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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual void Observe(int type, | 170 virtual void Observe(int type, |
171 const content::NotificationSource& source, | 171 const content::NotificationSource& source, |
172 const content::NotificationDetails& details) OVERRIDE; | 172 const content::NotificationDetails& details) OVERRIDE; |
173 | 173 |
174 // Sets the auth_token as specified. This should be used only for testing. | 174 // Sets the auth_token as specified. This should be used only for testing. |
175 void set_oauth2_auth_token_for_testing(const std::string& token) { | 175 void set_oauth2_auth_token_for_testing(const std::string& token) { |
176 auth_token_ = token; | 176 auth_token_ = token; |
177 } | 177 } |
178 | 178 |
179 private: | 179 private: |
180 | |
181 // Helper function for StartAuthentication() call. | 180 // Helper function for StartAuthentication() call. |
182 void StartAuthenticationOnUIThread( | 181 void StartAuthenticationOnUIThread( |
183 GDataOperationRegistry* registry, | 182 GDataOperationRegistry* registry, |
184 scoped_refptr<base::MessageLoopProxy> relay_proxy, | 183 scoped_refptr<base::MessageLoopProxy> relay_proxy, |
185 const AuthStatusCallback& callback); | 184 const AuthStatusCallback& callback); |
186 | 185 |
187 | 186 |
188 Profile* profile_; | 187 Profile* profile_; |
189 std::string refresh_token_; | 188 std::string refresh_token_; |
190 std::string auth_token_; | 189 std::string auth_token_; |
191 ObserverList<Observer> observers_; | 190 ObserverList<Observer> observers_; |
192 | 191 |
193 content::NotificationRegistrar registrar_; | 192 content::NotificationRegistrar registrar_; |
194 base::WeakPtrFactory<GDataAuthService> weak_ptr_factory_; | 193 base::WeakPtrFactory<GDataAuthService> weak_ptr_factory_; |
195 base::WeakPtr<GDataAuthService> weak_ptr_bound_to_ui_thread_; | 194 base::WeakPtr<GDataAuthService> weak_ptr_bound_to_ui_thread_; |
196 | 195 |
197 DISALLOW_COPY_AND_ASSIGN(GDataAuthService); | 196 DISALLOW_COPY_AND_ASSIGN(GDataAuthService); |
198 }; | 197 }; |
199 | 198 |
200 // This defines an interface for sharing by DocumentService and | 199 // This defines an interface for sharing by DocumentService and |
201 // MockDocumentService so that we can do testing of clients of DocumentService. | 200 // MockDocumentService so that we can do testing of clients of DocumentService. |
| 201 // |
| 202 // TODO(zel,benchan): Make the terminology/naming convention (e.g. file vs |
| 203 // document vs resource, directory vs collection) more consistent and precise. |
202 class DocumentsServiceInterface { | 204 class DocumentsServiceInterface { |
203 public: | 205 public: |
204 virtual ~DocumentsServiceInterface() {} | 206 virtual ~DocumentsServiceInterface() {} |
205 | 207 |
206 // Initializes the documents service tied with |profile|. | 208 // Initializes the documents service tied with |profile|. |
207 virtual void Initialize(Profile* profile) = 0; | 209 virtual void Initialize(Profile* profile) = 0; |
208 | 210 |
209 // Cancels all in-flight operations. | 211 // Cancels all in-flight operations. |
210 virtual void CancelAll() = 0; | 212 virtual void CancelAll() = 0; |
211 | 213 |
(...skipping 20 matching lines...) Expand all Loading... |
232 const EntryActionCallback& callback) = 0; | 234 const EntryActionCallback& callback) = 0; |
233 | 235 |
234 // Downloads a document identified by its |content_url| in a given |format|. | 236 // Downloads a document identified by its |content_url| in a given |format|. |
235 // Upon completion, invokes |callback| with results on the calling thread. | 237 // Upon completion, invokes |callback| with results on the calling thread. |
236 // | 238 // |
237 // Can be called on any thread. | 239 // Can be called on any thread. |
238 virtual void DownloadDocument(const GURL& content_url, | 240 virtual void DownloadDocument(const GURL& content_url, |
239 DocumentExportFormat format, | 241 DocumentExportFormat format, |
240 const DownloadActionCallback& callback) = 0; | 242 const DownloadActionCallback& callback) = 0; |
241 | 243 |
| 244 // Makes a copy of a document identified by its 'self' link |document_url|. |
| 245 // The copy is named as the UTF-8 encoded |new_name| and is not added to any |
| 246 // collection. Use AddResourceToDirectory() to add the copy to a collection |
| 247 // when needed. Upon completion, invokes |callback| with results on the |
| 248 // calling thread. |
| 249 // |
| 250 // Can be called on any thread. |
| 251 virtual void CopyDocument(const GURL& document_url, |
| 252 const FilePath::StringType& new_name, |
| 253 const GetDataCallback& callback) = 0; |
| 254 |
| 255 // Renames a document or collection identified by its 'self' link |
| 256 // |document_url| to the UTF-8 encoded |new_name|. Upon completion, |
| 257 // invokes |callback| with results on the calling thread. |
| 258 // |
| 259 // Can be called on any thread. |
| 260 virtual void RenameResource(const GURL& resource_url, |
| 261 const FilePath::StringType& new_name, |
| 262 const EntryActionCallback& callback) = 0; |
| 263 |
| 264 // Adds a resource (document, file, or collection) identified by its |
| 265 // 'self' link |resource_url| to a collection with a content link |
| 266 // |parent_content_url|. Upon completion, invokes |callback| with |
| 267 // results on the calling thread. |
| 268 // |
| 269 // Can be called on any thread. |
| 270 virtual void AddResourceToDirectory(const GURL& parent_content_url, |
| 271 const GURL& resource_url, |
| 272 const EntryActionCallback& callback) = 0; |
| 273 |
| 274 // Removes a resource (document, file, collection) identified by its |
| 275 // 'self' link |resource_url| from a collection with a content link |
| 276 // |parent_content_url|. Upon completion, invokes |callback| with |
| 277 // results on the calling thread. |
| 278 // |
| 279 // Can be called on any thread. |
| 280 virtual void RemoveResourceFromDirectory( |
| 281 const GURL& parent_content_url, |
| 282 const GURL& resource_url, |
| 283 const std::string& resource_id, |
| 284 const EntryActionCallback& callback) = 0; |
| 285 |
242 // Creates new collection with |directory_name| under parent directory | 286 // Creates new collection with |directory_name| under parent directory |
243 // identified with |parent_content_url|. If |parent_content_url| is empty, | 287 // identified with |parent_content_url|. If |parent_content_url| is empty, |
244 // the new collection will be created in the root. Upon completion, | 288 // the new collection will be created in the root. Upon completion, |
245 // invokes |callback| and passes newly created entry on the calling thread. | 289 // invokes |callback| and passes newly created entry on the calling thread. |
246 // | 290 // |
247 // Can be called on any thread. | 291 // Can be called on any thread. |
248 virtual void CreateDirectory(const GURL& parent_content_url, | 292 virtual void CreateDirectory(const GURL& parent_content_url, |
249 const FilePath::StringType& directory_name, | 293 const FilePath::StringType& directory_name, |
250 const GetDataCallback& callback) = 0; | 294 const GetDataCallback& callback) = 0; |
251 | 295 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 virtual void CancelAll() OVERRIDE; | 327 virtual void CancelAll() OVERRIDE; |
284 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 328 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; |
285 virtual void GetDocuments(const GURL& feed_url, | 329 virtual void GetDocuments(const GURL& feed_url, |
286 const GetDataCallback& callback) OVERRIDE; | 330 const GetDataCallback& callback) OVERRIDE; |
287 virtual void DeleteDocument(const GURL& document_url, | 331 virtual void DeleteDocument(const GURL& document_url, |
288 const EntryActionCallback& callback) OVERRIDE; | 332 const EntryActionCallback& callback) OVERRIDE; |
289 virtual void DownloadDocument( | 333 virtual void DownloadDocument( |
290 const GURL& content_url, | 334 const GURL& content_url, |
291 DocumentExportFormat format, | 335 DocumentExportFormat format, |
292 const DownloadActionCallback& callback) OVERRIDE; | 336 const DownloadActionCallback& callback) OVERRIDE; |
| 337 virtual void CopyDocument(const GURL& document_url, |
| 338 const FilePath::StringType& new_name, |
| 339 const GetDataCallback& callback) OVERRIDE; |
| 340 virtual void RenameResource(const GURL& document_url, |
| 341 const FilePath::StringType& new_name, |
| 342 const EntryActionCallback& callback) OVERRIDE; |
| 343 virtual void AddResourceToDirectory( |
| 344 const GURL& parent_content_url, |
| 345 const GURL& resource_url, |
| 346 const EntryActionCallback& callback) OVERRIDE; |
| 347 virtual void RemoveResourceFromDirectory( |
| 348 const GURL& parent_content_url, |
| 349 const GURL& resource_url, |
| 350 const std::string& resource_id, |
| 351 const EntryActionCallback& callback) OVERRIDE; |
293 virtual void CreateDirectory(const GURL& parent_content_url, | 352 virtual void CreateDirectory(const GURL& parent_content_url, |
294 const FilePath::StringType& directory_name, | 353 const FilePath::StringType& directory_name, |
295 const GetDataCallback& callback) OVERRIDE; | 354 const GetDataCallback& callback) OVERRIDE; |
296 virtual void DownloadFile(const GURL& content_url, | 355 virtual void DownloadFile(const GURL& content_url, |
297 const DownloadActionCallback& callback) OVERRIDE; | 356 const DownloadActionCallback& callback) OVERRIDE; |
298 virtual void InitiateUpload(const InitiateUploadParams& params, | 357 virtual void InitiateUpload(const InitiateUploadParams& params, |
299 const InitiateUploadCallback& callback) OVERRIDE; | 358 const InitiateUploadCallback& callback) OVERRIDE; |
300 virtual void ResumeUpload(const ResumeUploadParams& params, | 359 virtual void ResumeUpload(const ResumeUploadParams& params, |
301 const ResumeUploadCallback& callback) OVERRIDE; | 360 const ResumeUploadCallback& callback) OVERRIDE; |
302 | 361 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 scoped_ptr<GDataOperationRegistry> operation_registry_; | 397 scoped_ptr<GDataOperationRegistry> operation_registry_; |
339 base::WeakPtrFactory<DocumentsService> weak_ptr_factory_; | 398 base::WeakPtrFactory<DocumentsService> weak_ptr_factory_; |
340 base::WeakPtr<DocumentsService> weak_ptr_bound_to_ui_thread_; | 399 base::WeakPtr<DocumentsService> weak_ptr_bound_to_ui_thread_; |
341 | 400 |
342 DISALLOW_COPY_AND_ASSIGN(DocumentsService); | 401 DISALLOW_COPY_AND_ASSIGN(DocumentsService); |
343 }; | 402 }; |
344 | 403 |
345 } // namespace gdata | 404 } // namespace gdata |
346 | 405 |
347 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ | 406 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_H_ |
OLD | NEW |