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_DRIVE_API_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_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/gdata/drive_service_interface.h" | 12 #include "chrome/browser/chromeos/gdata/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/gdata_operations.h" | 14 #include "chrome/browser/google_apis/gdata_operations.h" |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 class GURL; | 17 class GURL; |
18 class Profile; | 18 class Profile; |
19 | 19 |
20 namespace gdata { | 20 namespace gdata { |
21 | 21 |
22 class OperationRunner; | 22 class OperationRunner; |
23 | 23 |
24 // This class provides documents feed service calls for Drive V2 API. | 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 | 25 // Details of API call are abstracted in each operation class and this class |
26 // works as a thin wrapper for the API. | 26 // works as a thin wrapper for the API. |
27 class DriveAPIService : public DriveServiceInterface, | 27 class DriveAPIService : public DriveServiceInterface, |
28 public AuthService::Observer { | 28 public AuthService::Observer, |
| 29 public OperationRegistry::Observer { |
29 public: | 30 public: |
30 // Instance is usually created by DriveSystemServiceFactory and owned by | 31 // Instance is usually created by DriveSystemServiceFactory and owned by |
31 // DriveFileSystem. | 32 // DriveFileSystem. |
32 DriveAPIService(); | 33 DriveAPIService(); |
33 virtual ~DriveAPIService(); | 34 virtual ~DriveAPIService(); |
34 | 35 |
35 // DriveServiceInterface Overrides | 36 // DriveServiceInterface Overrides |
36 virtual void Initialize(Profile* profile) OVERRIDE; | 37 virtual void Initialize(Profile* profile) OVERRIDE; |
37 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; | 38 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; |
38 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; | 39 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; |
39 virtual OperationRegistry* operation_registry() const OVERRIDE; | |
40 virtual bool CanStartOperation() const OVERRIDE; | 40 virtual bool CanStartOperation() const OVERRIDE; |
41 virtual void CancelAll() OVERRIDE; | 41 virtual void CancelAll() OVERRIDE; |
| 42 virtual bool CancelForFilePath(const FilePath& file_path) OVERRIDE; |
| 43 virtual OperationProgressStatusList GetProgressStatusList() const OVERRIDE; |
42 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 44 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; |
43 virtual bool HasAccessToken() const OVERRIDE; | 45 virtual bool HasAccessToken() const OVERRIDE; |
44 virtual bool HasRefreshToken() const OVERRIDE; | 46 virtual bool HasRefreshToken() const OVERRIDE; |
45 virtual void GetDocuments(const GURL& feed_url, | 47 virtual void GetDocuments(const GURL& feed_url, |
46 int64 start_changestamp, | 48 int64 start_changestamp, |
47 const std::string& search_query, | 49 const std::string& search_query, |
48 const std::string& directory_resource_id, | 50 const std::string& directory_resource_id, |
49 const GetDataCallback& callback) OVERRIDE; | 51 const GetDataCallback& callback) OVERRIDE; |
50 virtual void GetDocumentEntry(const std::string& resource_id, | 52 virtual void GetDocumentEntry(const std::string& resource_id, |
51 const GetDataCallback& callback) OVERRIDE; | 53 const GetDataCallback& callback) OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const GetDataCallback& callback) OVERRIDE; | 88 const GetDataCallback& callback) OVERRIDE; |
87 virtual void InitiateUpload(const InitiateUploadParams& params, | 89 virtual void InitiateUpload(const InitiateUploadParams& params, |
88 const InitiateUploadCallback& callback) OVERRIDE; | 90 const InitiateUploadCallback& callback) OVERRIDE; |
89 virtual void ResumeUpload(const ResumeUploadParams& params, | 91 virtual void ResumeUpload(const ResumeUploadParams& params, |
90 const ResumeUploadCallback& callback) OVERRIDE; | 92 const ResumeUploadCallback& callback) OVERRIDE; |
91 virtual void AuthorizeApp(const GURL& resource_url, | 93 virtual void AuthorizeApp(const GURL& resource_url, |
92 const std::string& app_id, | 94 const std::string& app_id, |
93 const GetDataCallback& callback) OVERRIDE; | 95 const GetDataCallback& callback) OVERRIDE; |
94 | 96 |
95 private: | 97 private: |
| 98 OperationRegistry* operation_registry() const; |
| 99 |
96 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 | 100 // Fetches a changelist from |url| with |start_changestamp|, using Drive V2 |
97 // API. If this URL is empty the call will use the default URL. Specify |url| | 101 // API. If this URL is empty the call will use the default URL. Specify |url| |
98 // when pagenated request should be issued. | 102 // when pagenated request should be issued. |
99 // |start_changestamp| specifies the starting point of change list or 0 if | 103 // |start_changestamp| specifies the starting point of change list or 0 if |
100 // all changes are necessary. | 104 // all changes are necessary. |
101 // Upon completion, invokes |callback| with results on calling thread. | 105 // Upon completion, invokes |callback| with results on calling thread. |
102 void GetChangelist(const GURL& url, | 106 void GetChangelist(const GURL& url, |
103 int64 start_changestamp, | 107 int64 start_changestamp, |
104 const GetDataCallback& callback); | 108 const GetDataCallback& callback); |
105 | 109 |
106 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If | 110 // Fetches a filelist from |url| with |search_query|, using Drive V2 API. If |
107 // this URL is empty the call will use the default URL. Specify |url| when | 111 // this URL is empty the call will use the default URL. Specify |url| when |
108 // pagenated request should be issued. | 112 // pagenated request should be issued. |
109 // |search_query| specifies query string, whose syntax is described at | 113 // |search_query| specifies query string, whose syntax is described at |
110 // https://developers.google.com/drive/search-parameters | 114 // https://developers.google.com/drive/search-parameters |
111 void GetFilelist(const GURL& url, | 115 void GetFilelist(const GURL& url, |
112 const std::string& search_query, | 116 const std::string& search_query, |
113 const GetDataCallback& callback); | 117 const GetDataCallback& callback); |
114 | 118 |
115 // AuthService::Observer override. | 119 // AuthService::Observer override. |
116 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 120 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
117 | 121 |
| 122 // DriveServiceObserver Overrides |
| 123 virtual void OnProgressUpdate( |
| 124 const OperationProgressStatusList& list) OVERRIDE; |
| 125 virtual void OnAuthenticationFailed() OVERRIDE; |
| 126 |
118 Profile* profile_; | 127 Profile* profile_; |
119 scoped_ptr<OperationRunner> runner_; | 128 scoped_ptr<OperationRunner> runner_; |
120 ObserverList<DriveServiceObserver> observers_; | 129 ObserverList<DriveServiceObserver> observers_; |
121 | 130 |
122 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 131 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
123 }; | 132 }; |
124 | 133 |
125 } // namespace gdata | 134 } // namespace gdata |
126 | 135 |
127 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ | 136 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_SERVICE_H_ |
OLD | NEW |