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_GOOGLE_APIS_DRIVE_API_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "chrome/browser/google_apis/auth_service_observer.h" | 12 #include "chrome/browser/google_apis/auth_service_observer.h" |
13 #include "chrome/browser/google_apis/drive_api_url_generator.h" | 13 #include "chrome/browser/google_apis/drive_api_url_generator.h" |
14 #include "chrome/browser/google_apis/drive_service_interface.h" | 14 #include "chrome/browser/google_apis/drive_service_interface.h" |
| 15 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
15 | 16 |
16 class GURL; | 17 class GURL; |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class FilePath; | 21 class FilePath; |
21 } | 22 } |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
25 } // namespace net | 26 } // namespace net |
26 | 27 |
27 namespace google_apis { | 28 namespace google_apis { |
28 class OperationRunner; | 29 class OperationRunner; |
29 | 30 |
30 // This class provides Drive operation calls using Drive V2 API. | 31 // This class provides Drive operation calls using Drive V2 API. |
31 // Details of API call are abstracted in each operation class and this class | 32 // Details of API call are abstracted in each operation class and this class |
32 // works as a thin wrapper for the API. | 33 // works as a thin wrapper for the API. |
33 class DriveAPIService : public DriveServiceInterface, | 34 class DriveAPIService : public DriveServiceInterface, |
34 public AuthServiceObserver, | 35 public AuthServiceObserver, |
35 public OperationRegistryObserver { | 36 public OperationRegistryObserver { |
36 public: | 37 public: |
37 // Instance is usually created by DriveSystemServiceFactory and owned by | 38 // Instance is usually created by DriveSystemServiceFactory and owned by |
38 // DriveFileSystem. | 39 // DriveFileSystem. |
39 // | 40 // |
40 // |url_request_context_getter| is used to initialize URLFetcher. | 41 // |url_request_context_getter| is used to initialize URLFetcher. |
41 // |base_url| is used to generate URLs for communication with the drive API. | 42 // |base_url| is used to generate URLs for communication with the drive API. |
| 43 // |wapi_base_url| is used to generate URLs for communication with |
| 44 // the GData WAPI server. Note that this should only be used for the hacky |
| 45 // workaround for the operations which is not-yet supported on Drive API v2. |
42 // |custom_user_agent| will be used for the User-Agent header in HTTP | 46 // |custom_user_agent| will be used for the User-Agent header in HTTP |
43 // requests issues through the service if the value is not empty. | 47 // requests issues through the service if the value is not empty. |
44 DriveAPIService( | 48 DriveAPIService( |
45 net::URLRequestContextGetter* url_request_context_getter, | 49 net::URLRequestContextGetter* url_request_context_getter, |
46 const GURL& base_url, | 50 const GURL& base_url, |
| 51 const GURL& wapi_base_url, |
47 const std::string& custom_user_agent); | 52 const std::string& custom_user_agent); |
48 virtual ~DriveAPIService(); | 53 virtual ~DriveAPIService(); |
49 | 54 |
50 // DriveServiceInterface Overrides | 55 // DriveServiceInterface Overrides |
51 virtual void Initialize(Profile* profile) OVERRIDE; | 56 virtual void Initialize(Profile* profile) OVERRIDE; |
52 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; | 57 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; |
53 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; | 58 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; |
54 virtual bool CanStartOperation() const OVERRIDE; | 59 virtual bool CanStartOperation() const OVERRIDE; |
55 virtual void CancelAll() OVERRIDE; | 60 virtual void CancelAll() OVERRIDE; |
56 virtual bool CancelForFilePath(const base::FilePath& file_path) OVERRIDE; | 61 virtual bool CancelForFilePath(const base::FilePath& file_path) OVERRIDE; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 173 |
169 // DriveServiceObserver Overrides | 174 // DriveServiceObserver Overrides |
170 virtual void OnProgressUpdate( | 175 virtual void OnProgressUpdate( |
171 const OperationProgressStatusList& list) OVERRIDE; | 176 const OperationProgressStatusList& list) OVERRIDE; |
172 | 177 |
173 net::URLRequestContextGetter* url_request_context_getter_; | 178 net::URLRequestContextGetter* url_request_context_getter_; |
174 Profile* profile_; | 179 Profile* profile_; |
175 scoped_ptr<OperationRunner> runner_; | 180 scoped_ptr<OperationRunner> runner_; |
176 ObserverList<DriveServiceObserver> observers_; | 181 ObserverList<DriveServiceObserver> observers_; |
177 DriveApiUrlGenerator url_generator_; | 182 DriveApiUrlGenerator url_generator_; |
| 183 GDataWapiUrlGenerator wapi_url_generator_; |
178 const std::string custom_user_agent_; | 184 const std::string custom_user_agent_; |
179 | 185 |
180 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 186 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
181 }; | 187 }; |
182 | 188 |
183 } // namespace google_apis | 189 } // namespace google_apis |
184 | 190 |
185 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_ | 191 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_SERVICE_H_ |
OLD | NEW |