| 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_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "chrome/browser/google_apis/drive_service_interface.h" | 15 #include "chrome/browser/google_apis/drive_service_interface.h" |
| 16 #include "chrome/browser/google_apis/drive_upload_error.h" | 16 #include "chrome/browser/google_apis/drive_upload_error.h" |
| 17 #include "chrome/browser/google_apis/gdata_errorcode.h" | 17 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 18 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 18 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 19 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 19 | 20 |
| 20 class GURL; | 21 class GURL; |
| 21 class Profile; | 22 class Profile; |
| 22 | 23 |
| 23 namespace google_apis { | 24 namespace google_apis { |
| 24 class DriveUploaderInterface; | 25 class DriveUploaderInterface; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace sync_file_system { | 28 namespace sync_file_system { |
| 28 | 29 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 DocumentEntryCallback; | 66 DocumentEntryCallback; |
| 66 | 67 |
| 67 explicit DriveFileSyncClient(Profile* profile); | 68 explicit DriveFileSyncClient(Profile* profile); |
| 68 virtual ~DriveFileSyncClient(); | 69 virtual ~DriveFileSyncClient(); |
| 69 | 70 |
| 70 void AddObserver(DriveFileSyncClientObserver* observer); | 71 void AddObserver(DriveFileSyncClientObserver* observer); |
| 71 void RemoveObserver(DriveFileSyncClientObserver* observer); | 72 void RemoveObserver(DriveFileSyncClientObserver* observer); |
| 72 | 73 |
| 73 static scoped_ptr<DriveFileSyncClient> CreateForTesting( | 74 static scoped_ptr<DriveFileSyncClient> CreateForTesting( |
| 74 Profile* profile, | 75 Profile* profile, |
| 76 const GURL& base_url, |
| 75 scoped_ptr<google_apis::DriveServiceInterface> drive_service, | 77 scoped_ptr<google_apis::DriveServiceInterface> drive_service, |
| 76 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); | 78 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); |
| 77 | 79 |
| 78 // Fetches Resource ID of the directory where we should place all files to | 80 // Fetches Resource ID of the directory where we should place all files to |
| 79 // sync. Upon completion, invokes |callback|. | 81 // sync. Upon completion, invokes |callback|. |
| 80 // If the directory does not exist on the server this also creates | 82 // If the directory does not exist on the server this also creates |
| 81 // the directory. | 83 // the directory. |
| 82 void GetDriveDirectoryForSyncRoot(const ResourceIdCallback& callback); | 84 void GetDriveDirectoryForSyncRoot(const ResourceIdCallback& callback); |
| 83 | 85 |
| 84 // Fetches Resource ID of the directory for the |origin|. | 86 // Fetches Resource ID of the directory for the |origin|. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // deleted from Drive. If |remote_file_md5| is different from the actual | 163 // deleted from Drive. If |remote_file_md5| is different from the actual |
| 162 // value, cancels the deletion and invokes |callback| with | 164 // value, cancels the deletion and invokes |callback| with |
| 163 // GDataErrorCode::HTTP_CONFLICT immediately. | 165 // GDataErrorCode::HTTP_CONFLICT immediately. |
| 164 void DeleteFile(const std::string& resource_id, | 166 void DeleteFile(const std::string& resource_id, |
| 165 const std::string& remote_file_md5, | 167 const std::string& remote_file_md5, |
| 166 const GDataErrorCallback& callback); | 168 const GDataErrorCallback& callback); |
| 167 | 169 |
| 168 static std::string OriginToDirectoryTitle(const GURL& origin); | 170 static std::string OriginToDirectoryTitle(const GURL& origin); |
| 169 static GURL DirectoryTitleToOrigin(const std::string& title); | 171 static GURL DirectoryTitleToOrigin(const std::string& title); |
| 170 | 172 |
| 173 // Converts |resource_id| to corresponing resource link. |
| 174 GURL ResourceIdToResourceLink(const std::string& resource_id) const; |
| 175 |
| 171 // DriveServiceObserver overrides. | 176 // DriveServiceObserver overrides. |
| 172 virtual void OnReadyToPerformOperations() OVERRIDE; | 177 virtual void OnReadyToPerformOperations() OVERRIDE; |
| 173 | 178 |
| 174 private: | 179 private: |
| 175 friend class DriveFileSyncClientTest; | 180 friend class DriveFileSyncClientTest; |
| 176 friend class DriveFileSyncServiceTest; | 181 friend class DriveFileSyncServiceTest; |
| 177 | 182 |
| 178 // Constructor for test use. | 183 // Constructor for test use. |
| 179 DriveFileSyncClient( | 184 DriveFileSyncClient( |
| 180 Profile* profile, | 185 Profile* profile, |
| 186 const GURL& base_url, |
| 181 scoped_ptr<google_apis::DriveServiceInterface> drive_service, | 187 scoped_ptr<google_apis::DriveServiceInterface> drive_service, |
| 182 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); | 188 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); |
| 183 | 189 |
| 184 void DidGetDirectory(const std::string& parent_resource_id, | 190 void DidGetDirectory(const std::string& parent_resource_id, |
| 185 const std::string& directory_name, | 191 const std::string& directory_name, |
| 186 const ResourceIdCallback& callback, | 192 const ResourceIdCallback& callback, |
| 187 google_apis::GDataErrorCode error, | 193 google_apis::GDataErrorCode error, |
| 188 scoped_ptr<google_apis::DocumentFeed> feed); | 194 scoped_ptr<google_apis::DocumentFeed> feed); |
| 189 | 195 |
| 190 void DidGetParentDirectoryForCreateDirectory( | 196 void DidGetParentDirectoryForCreateDirectory( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 google_apis::GDataErrorCode error, | 257 google_apis::GDataErrorCode error, |
| 252 scoped_ptr<google_apis::DocumentEntry> entry); | 258 scoped_ptr<google_apis::DocumentEntry> entry); |
| 253 | 259 |
| 254 void DidDeleteFile(const GDataErrorCallback& callback, | 260 void DidDeleteFile(const GDataErrorCallback& callback, |
| 255 google_apis::GDataErrorCode error); | 261 google_apis::GDataErrorCode error); |
| 256 | 262 |
| 257 static std::string FormatTitleQuery(const std::string& title); | 263 static std::string FormatTitleQuery(const std::string& title); |
| 258 | 264 |
| 259 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; | 265 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; |
| 260 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_; | 266 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_; |
| 267 google_apis::GDataWapiUrlGenerator url_generator_; |
| 261 | 268 |
| 262 ObserverList<DriveFileSyncClientObserver> observers_; | 269 ObserverList<DriveFileSyncClientObserver> observers_; |
| 263 | 270 |
| 264 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); | 271 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); |
| 265 }; | 272 }; |
| 266 | 273 |
| 267 } // namespace sync_file_system | 274 } // namespace sync_file_system |
| 268 | 275 |
| 269 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ | 276 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ |
| OLD | NEW |