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 RemoteFileObserver, | |
| 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 // RemoteFileObserver override. | |
| 42 virtual void OnRemoteChangeAvailable(RemoteFileProvider* remote_file_provider) | |
| 43 OVERRIDE; | |
| 44 | |
| 45 void RegisterRemoteFileProvider( | |
| 46 const std::string& service_name, | |
| 47 scoped_ptr<RemoteFileProvider> remote_file_provider); | |
| 48 | |
| 35 void InitializeForApp( | 49 void InitializeForApp( |
| 36 fileapi::FileSystemContext* file_system_context, | 50 fileapi::FileSystemContext* file_system_context, |
| 37 const std::string& service_name, | 51 const std::string& service_name, |
| 38 const GURL& app_url, | 52 const GURL& app_url, |
| 39 const StatusCallback& callback); | 53 const StatusCallback& callback); |
| 40 | 54 |
| 41 private: | 55 private: |
| 42 friend class SyncFileSystemServiceFactory; | 56 friend class SyncFileSystemServiceFactory; |
| 57 typedef std::map<std::string, RemoteFileProvider*> RemoteFileProviderMap; | |
| 43 | 58 |
| 44 explicit SyncFileSystemService(Profile* profile); | 59 explicit SyncFileSystemService(Profile* profile); |
| 45 virtual ~SyncFileSystemService(); | 60 virtual ~SyncFileSystemService(); |
| 46 | 61 |
| 47 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service); | 62 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service); |
| 48 | 63 |
| 64 void MayStartRemoteSync(); | |
| 65 void DidDownloadFile(scoped_ptr<RemoteChange> change, | |
| 66 fileapi::SyncStatusCode status, | |
| 67 const FilePath& file_path); | |
| 68 void DidDeleteFile(const fileapi::FileSystemURL& url, | |
| 69 fileapi::SyncStatusCode status); | |
| 70 | |
| 49 Profile* profile_; | 71 Profile* profile_; |
| 50 | 72 |
| 51 scoped_ptr<LocalFileSyncService> local_file_service_; | 73 scoped_ptr<LocalFileSyncService> local_file_service_; |
| 74 RemoteFileProviderMap remote_file_providers_; | |
| 75 std::set<RemoteFileProvider*> pending_providers_; | |
|
kinuko
2012/10/17 09:22:57
I haven't looked closely at the .cc file but what
tzik
2012/10/18 07:18:08
Removed.
In this version of patchset, I considere
| |
| 76 bool sync_is_running_; | |
| 52 | 77 |
| 53 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); | 78 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); |
| 54 }; | 79 }; |
| 55 | 80 |
| 56 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { | 81 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { |
| 57 public: | 82 public: |
| 58 static SyncFileSystemService* GetForProfile(Profile* profile); | 83 static SyncFileSystemService* GetForProfile(Profile* profile); |
| 59 static SyncFileSystemService* FindForProfile(Profile* profile); | 84 static SyncFileSystemService* FindForProfile(Profile* profile); |
| 60 static SyncFileSystemServiceFactory* GetInstance(); | 85 static SyncFileSystemServiceFactory* GetInstance(); |
| 61 | 86 |
| 62 private: | 87 private: |
| 63 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; | 88 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; |
| 64 SyncFileSystemServiceFactory(); | 89 SyncFileSystemServiceFactory(); |
| 65 virtual ~SyncFileSystemServiceFactory(); | 90 virtual ~SyncFileSystemServiceFactory(); |
| 66 | 91 |
| 67 // ProfileKeyedServiceFactory overrides. | 92 // ProfileKeyedServiceFactory overrides. |
| 68 virtual ProfileKeyedService* BuildServiceInstanceFor( | 93 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 69 Profile* profile) const OVERRIDE; | 94 Profile* profile) const OVERRIDE; |
| 70 }; | 95 }; |
| 71 | 96 |
| 72 } // namespace sync_file_system | 97 } // namespace sync_file_system |
| 73 | 98 |
| 74 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 99 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| OLD | NEW |