| 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 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 20 #include "net/base/network_change_notifier.h" |
| 20 | 21 |
| 21 class GURL; | 22 class GURL; |
| 22 class Profile; | 23 class Profile; |
| 23 | 24 |
| 24 namespace google_apis { | 25 namespace google_apis { |
| 25 class DriveUploaderInterface; | 26 class DriveUploaderInterface; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace sync_file_system { | 29 namespace sync_file_system { |
| 29 | 30 |
| 30 class DriveFileSyncClientObserver { | 31 class DriveFileSyncClientObserver { |
| 31 public: | 32 public: |
| 32 DriveFileSyncClientObserver() {} | 33 DriveFileSyncClientObserver() {} |
| 33 virtual ~DriveFileSyncClientObserver() {} | 34 virtual ~DriveFileSyncClientObserver() {} |
| 34 virtual void OnAuthenticated() = 0; | 35 virtual void OnAuthenticated() = 0; |
| 36 virtual void OnNetworkConnected() = 0; |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClientObserver); | 39 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClientObserver); |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 // This class is responsible for talking to the Drive service to get and put | 42 // This class is responsible for talking to the Drive service to get and put |
| 41 // Drive directories, files and metadata. | 43 // Drive directories, files and metadata. |
| 42 // This class is owned by DriveFileSyncService. | 44 // This class is owned by DriveFileSyncService. |
| 43 class DriveFileSyncClient : public google_apis::DriveServiceObserver, | 45 class DriveFileSyncClient |
| 44 public base::NonThreadSafe, | 46 : public google_apis::DriveServiceObserver, |
| 45 public base::SupportsWeakPtr<DriveFileSyncClient> { | 47 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 48 public base::NonThreadSafe, |
| 49 public base::SupportsWeakPtr<DriveFileSyncClient> { |
| 46 public: | 50 public: |
| 47 typedef base::Callback<void(google_apis::GDataErrorCode error)> | 51 typedef base::Callback<void(google_apis::GDataErrorCode error)> |
| 48 GDataErrorCallback; | 52 GDataErrorCallback; |
| 49 typedef base::Callback<void(google_apis::GDataErrorCode error, | 53 typedef base::Callback<void(google_apis::GDataErrorCode error, |
| 50 const std::string& file_md5)> | 54 const std::string& file_md5)> |
| 51 DownloadFileCallback; | 55 DownloadFileCallback; |
| 52 typedef base::Callback<void(google_apis::GDataErrorCode error, | 56 typedef base::Callback<void(google_apis::GDataErrorCode error, |
| 53 const std::string& resource_id, | 57 const std::string& resource_id, |
| 54 const std::string& file_md5)> | 58 const std::string& file_md5)> |
| 55 UploadFileCallback; | 59 UploadFileCallback; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 173 |
| 170 static std::string OriginToDirectoryTitle(const GURL& origin); | 174 static std::string OriginToDirectoryTitle(const GURL& origin); |
| 171 static GURL DirectoryTitleToOrigin(const std::string& title); | 175 static GURL DirectoryTitleToOrigin(const std::string& title); |
| 172 | 176 |
| 173 // Converts |resource_id| to corresponing resource link. | 177 // Converts |resource_id| to corresponing resource link. |
| 174 GURL ResourceIdToResourceLink(const std::string& resource_id) const; | 178 GURL ResourceIdToResourceLink(const std::string& resource_id) const; |
| 175 | 179 |
| 176 // DriveServiceObserver overrides. | 180 // DriveServiceObserver overrides. |
| 177 virtual void OnReadyToPerformOperations() OVERRIDE; | 181 virtual void OnReadyToPerformOperations() OVERRIDE; |
| 178 | 182 |
| 183 // ConnectionTypeObserver overrides. |
| 184 virtual void OnConnectionTypeChanged( |
| 185 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 186 |
| 179 private: | 187 private: |
| 180 friend class DriveFileSyncClientTest; | 188 friend class DriveFileSyncClientTest; |
| 181 friend class DriveFileSyncServiceTest; | 189 friend class DriveFileSyncServiceTest; |
| 182 | 190 |
| 183 // Constructor for test use. | 191 // Constructor for test use. |
| 184 DriveFileSyncClient( | 192 DriveFileSyncClient( |
| 185 Profile* profile, | 193 Profile* profile, |
| 186 const GURL& base_url, | 194 const GURL& base_url, |
| 187 scoped_ptr<google_apis::DriveServiceInterface> drive_service, | 195 scoped_ptr<google_apis::DriveServiceInterface> drive_service, |
| 188 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); | 196 scoped_ptr<google_apis::DriveUploaderInterface> drive_uploader); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 google_apis::GDataWapiUrlGenerator url_generator_; | 275 google_apis::GDataWapiUrlGenerator url_generator_; |
| 268 | 276 |
| 269 ObserverList<DriveFileSyncClientObserver> observers_; | 277 ObserverList<DriveFileSyncClientObserver> observers_; |
| 270 | 278 |
| 271 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); | 279 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncClient); |
| 272 }; | 280 }; |
| 273 | 281 |
| 274 } // namespace sync_file_system | 282 } // namespace sync_file_system |
| 275 | 283 |
| 276 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ | 284 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_CLIENT_H_ |
| OLD | NEW |