| 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/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.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/drive_upload_error.h" | 15 #include "chrome/browser/google_apis/drive_upload_error.h" |
| 16 #include "chrome/browser/google_apis/gdata_errorcode.h" | 16 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 18 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 18 | 19 |
| 19 class GURL; | 20 class GURL; |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| 22 namespace google_apis { | 23 namespace google_apis { |
| 23 class DriveUploaderInterface; | 24 class DriveUploaderInterface; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace sync_file_system { | 27 namespace sync_file_system { |
| 27 | 28 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 DocumentFeedCallback; | 51 DocumentFeedCallback; |
| 51 typedef base::Callback<void(google_apis::GDataErrorCode error, | 52 typedef base::Callback<void(google_apis::GDataErrorCode error, |
| 52 scoped_ptr<google_apis::DocumentEntry> entry)> | 53 scoped_ptr<google_apis::DocumentEntry> entry)> |
| 53 DocumentEntryCallback; | 54 DocumentEntryCallback; |
| 54 | 55 |
| 55 explicit DriveFileSyncClient(Profile* profile); | 56 explicit DriveFileSyncClient(Profile* profile); |
| 56 virtual ~DriveFileSyncClient(); | 57 virtual ~DriveFileSyncClient(); |
| 57 | 58 |
| 58 static scoped_ptr<DriveFileSyncClient> CreateForTesting( | 59 static scoped_ptr<DriveFileSyncClient> CreateForTesting( |
| 59 Profile* profile, | 60 Profile* profile, |
| 61 const GURL& base_url, |
| 60 scoped_ptr<google_apis::DriveServiceInterface> drive_service, | 62 scoped_ptr<google_apis::DriveServiceInterface> drive_service, |
| 61 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); | 63 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); |
| 62 | 64 |
| 63 // Fetches Resource ID of the directory where we should place all files to | 65 // Fetches Resource ID of the directory where we should place all files to |
| 64 // sync. Upon completion, invokes |callback|. | 66 // sync. Upon completion, invokes |callback|. |
| 65 // If the directory does not exist on the server this also creates | 67 // If the directory does not exist on the server this also creates |
| 66 // the directory. | 68 // the directory. |
| 67 void GetDriveDirectoryForSyncRoot(const ResourceIdCallback& callback); | 69 void GetDriveDirectoryForSyncRoot(const ResourceIdCallback& callback); |
| 68 | 70 |
| 69 // Fetches Resource ID of the directory for the |origin|. | 71 // Fetches Resource ID of the directory for the |origin|. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 145 |
| 144 // Deletes the file identified by |resource_id|. | 146 // Deletes the file identified by |resource_id|. |
| 145 // |remote_file_md5| represents the expected hash value of the file to be | 147 // |remote_file_md5| represents the expected hash value of the file to be |
| 146 // deleted from Drive. If |remote_file_md5| is different from the actual | 148 // deleted from Drive. If |remote_file_md5| is different from the actual |
| 147 // value, cancels the deletion and invokes |callback| with | 149 // value, cancels the deletion and invokes |callback| with |
| 148 // GDataErrorCode::HTTP_CONFLICT immediately. | 150 // GDataErrorCode::HTTP_CONFLICT immediately. |
| 149 void DeleteFile(const std::string& resource_id, | 151 void DeleteFile(const std::string& resource_id, |
| 150 const std::string& remote_file_md5, | 152 const std::string& remote_file_md5, |
| 151 const GDataErrorCallback& callback); | 153 const GDataErrorCallback& callback); |
| 152 | 154 |
| 155 static std::string OriginToDirectoryTitle(const GURL& origin); |
| 156 static GURL DirectoryTitleToOrigin(const std::string& title); |
| 157 |
| 158 // Convers |resource_id| to corresponing resource link. |
| 159 GURL ResourceIdToResourceLink(const std::string& resource_id) const; |
| 160 |
| 153 private: | 161 private: |
| 154 friend class DriveFileSyncClientTest; | 162 friend class DriveFileSyncClientTest; |
| 155 friend class DriveFileSyncServiceTest; | 163 friend class DriveFileSyncServiceTest; |
| 156 | 164 |
| 157 // Constructor for test use. | 165 // Constructor for test use. |
| 158 DriveFileSyncClient( | 166 DriveFileSyncClient( |
| 159 Profile* profile, | 167 Profile* profile, |
| 168 const GURL& base_url, |
| 160 scoped_ptr<google_apis::DriveServiceInterface> drive_service, | 169 scoped_ptr<google_apis::DriveServiceInterface> drive_service, |
| 161 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); | 170 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); |
| 162 | 171 |
| 163 void DidGetDirectory(const std::string& parent_resource_id, | 172 void DidGetDirectory(const std::string& parent_resource_id, |
| 164 const std::string& directory_name, | 173 const std::string& directory_name, |
| 165 const ResourceIdCallback& callback, | 174 const ResourceIdCallback& callback, |
| 166 google_apis::GDataErrorCode error, | 175 google_apis::GDataErrorCode error, |
| 167 scoped_ptr<google_apis::DocumentFeed> feed); | 176 scoped_ptr<google_apis::DocumentFeed> feed); |
| 168 | 177 |
| 169 void DidGetParentDirectoryForCreateDirectory( | 178 void DidGetParentDirectoryForCreateDirectory( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 google_apis::GDataErrorCode error, | 239 google_apis::GDataErrorCode error, |
| 231 scoped_ptr<google_apis::DocumentEntry> entry); | 240 scoped_ptr<google_apis::DocumentEntry> entry); |
| 232 | 241 |
| 233 void DidDeleteFile(const GDataErrorCallback& callback, | 242 void DidDeleteFile(const GDataErrorCallback& callback, |
| 234 google_apis::GDataErrorCode error); | 243 google_apis::GDataErrorCode error); |
| 235 | 244 |
| 236 static std::string FormatTitleQuery(const std::string& title); | 245 static std::string FormatTitleQuery(const std::string& title); |
| 237 | 246 |
| 238 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; | 247 scoped_ptr<google_apis::DriveServiceInterface> drive_service_; |
| 239 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_; | 248 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader_; |
| 249 google_apis::GDataWapiUrlGenerator url_generator_; |
| 240 | 250 |
| 241 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); | 251 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); |
| 242 }; | 252 }; |
| 243 | 253 |
| 244 } // namespace sync_file_system | 254 } // namespace sync_file_system |
| 245 | 255 |
| 246 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ | 256 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ |
| OLD | NEW |