Chromium Code Reviews| 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_SYNC_FILE_SYSTEM_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/memory/weak_ptr.h" | |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 17 #include "chrome/browser/sync_file_system/remote_file_provider.h" | |
| 16 #include "webkit/fileapi/syncable/sync_status_code.h" | 18 #include "webkit/fileapi/syncable/sync_status_code.h" |
| 17 | 19 |
| 18 class GURL; | 20 class GURL; |
| 19 | 21 |
| 20 namespace fileapi { | 22 namespace fileapi { |
| 21 class FileSystemContext; | 23 class FileSystemContext; |
| 24 class FileSystemURL; | |
| 22 } | 25 } |
| 23 | 26 |
| 24 namespace sync_file_system { | 27 namespace sync_file_system { |
| 25 | 28 |
| 26 class LocalFileSyncService; | 29 class LocalFileSyncService; |
| 27 | 30 |
| 28 class SyncFileSystemService : public ProfileKeyedService { | 31 class SyncFileSystemService |
| 32 : public ProfileKeyedService, | |
| 33 public RemoteChangeProcessor, | |
| 34 public base::SupportsWeakPtr<SyncFileSystemService> { | |
| 29 public: | 35 public: |
| 30 typedef base::Callback<void(fileapi::SyncStatusCode status)> StatusCallback; | 36 typedef base::Callback<void(fileapi::SyncStatusCode status)> StatusCallback; |
| 31 | 37 |
| 32 // ProfileKeyedService overrides. | 38 // ProfileKeyedService overrides. |
| 33 virtual void Shutdown() OVERRIDE; | 39 virtual void Shutdown() OVERRIDE; |
| 34 | 40 |
| 41 // RemoteChangeProcessor override. | |
| 42 virtual void OnRemoteChangeAvailable() OVERRIDE; | |
| 43 | |
| 35 void InitializeForApp( | 44 void InitializeForApp( |
| 36 fileapi::FileSystemContext* file_system_context, | 45 fileapi::FileSystemContext* file_system_context, |
| 37 const std::string& service_name, | 46 const std::string& service_name, |
| 38 const GURL& app_url, | 47 const GURL& app_url, |
| 39 const StatusCallback& callback); | 48 const StatusCallback& callback); |
| 40 | 49 |
| 41 private: | 50 private: |
| 42 friend class SyncFileSystemServiceFactory; | 51 friend class SyncFileSystemServiceFactory; |
| 52 typedef std::map<std::string, RemoteFileProvider*> RemoteFileProviderMap; | |
|
kinuko
2012/10/18 13:54:32
Not necessary for now?
tzik
2012/10/23 04:19:32
Done.
| |
| 43 | 53 |
| 44 explicit SyncFileSystemService(Profile* profile); | 54 explicit SyncFileSystemService(Profile* profile); |
| 45 virtual ~SyncFileSystemService(); | 55 virtual ~SyncFileSystemService(); |
| 46 | 56 |
| 47 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service); | 57 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service, |
| 58 scoped_ptr<RemoteFileProvider> remote_file_provider); | |
| 59 | |
| 60 void MaybeStartRemoteSync(); | |
| 61 void DidDownloadFile(fileapi::SyncStatusCode status, | |
| 62 const FilePath& file_path); | |
| 48 | 63 |
| 49 Profile* profile_; | 64 Profile* profile_; |
| 50 | 65 |
| 51 scoped_ptr<LocalFileSyncService> local_file_service_; | 66 scoped_ptr<LocalFileSyncService> local_file_service_; |
| 67 scoped_ptr<RemoteFileProvider> remote_file_provider_; | |
| 68 bool sync_is_running_; | |
|
kinuko
2012/10/18 13:54:32
remote_sync_is_running_ at least for now?
| |
| 52 | 69 |
| 53 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); | 70 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); |
| 54 }; | 71 }; |
| 55 | 72 |
| 56 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { | 73 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { |
| 57 public: | 74 public: |
| 58 static SyncFileSystemService* GetForProfile(Profile* profile); | 75 static SyncFileSystemService* GetForProfile(Profile* profile); |
| 59 static SyncFileSystemService* FindForProfile(Profile* profile); | 76 static SyncFileSystemService* FindForProfile(Profile* profile); |
| 60 static SyncFileSystemServiceFactory* GetInstance(); | 77 static SyncFileSystemServiceFactory* GetInstance(); |
| 61 | 78 |
| 62 private: | 79 private: |
| 63 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; | 80 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; |
| 64 SyncFileSystemServiceFactory(); | 81 SyncFileSystemServiceFactory(); |
| 65 virtual ~SyncFileSystemServiceFactory(); | 82 virtual ~SyncFileSystemServiceFactory(); |
| 66 | 83 |
| 67 // ProfileKeyedServiceFactory overrides. | 84 // ProfileKeyedServiceFactory overrides. |
| 68 virtual ProfileKeyedService* BuildServiceInstanceFor( | 85 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 69 Profile* profile) const OVERRIDE; | 86 Profile* profile) const OVERRIDE; |
| 70 }; | 87 }; |
| 71 | 88 |
| 72 } // namespace sync_file_system | 89 } // namespace sync_file_system |
| 73 | 90 |
| 74 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 91 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| OLD | NEW |