| 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 "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 15 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| 16 #include "chrome/browser/sync_file_system/change_observer_interface.h" |
| 16 #include "webkit/fileapi/syncable/sync_status_code.h" | 17 #include "webkit/fileapi/syncable/sync_status_code.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace fileapi { | 21 namespace fileapi { |
| 21 class FileSystemContext; | 22 class FileSystemContext; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace sync_file_system { | 25 namespace sync_file_system { |
| 25 | 26 |
| 26 class LocalFileSyncService; | 27 class LocalFileSyncService; |
| 28 class LocalChangeObserver; |
| 29 class RemoteChangeObserver; |
| 27 | 30 |
| 28 class SyncFileSystemService : public ProfileKeyedService { | 31 class SyncFileSystemService |
| 32 : public ProfileKeyedService, |
| 33 public LocalChangeObserver, |
| 34 public RemoteChangeObserver { |
| 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 |
| 35 void InitializeForApp( | 41 void InitializeForApp( |
| 36 fileapi::FileSystemContext* file_system_context, | 42 fileapi::FileSystemContext* file_system_context, |
| 37 const std::string& service_name, | 43 const std::string& service_name, |
| 38 const GURL& app_url, | 44 const GURL& app_url, |
| 39 const StatusCallback& callback); | 45 const StatusCallback& callback); |
| 40 | 46 |
| 41 private: | 47 private: |
| 42 friend class SyncFileSystemServiceFactory; | 48 friend class SyncFileSystemServiceFactory; |
| 43 | 49 |
| 44 explicit SyncFileSystemService(Profile* profile); | 50 explicit SyncFileSystemService(Profile* profile); |
| 45 virtual ~SyncFileSystemService(); | 51 virtual ~SyncFileSystemService(); |
| 46 | 52 |
| 47 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service); | 53 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service); |
| 48 | 54 |
| 55 // RemoteChangeObserver overrides. |
| 56 virtual void OnLocalChangeAvailable(int64 pending_changes) OVERRIDE; |
| 57 |
| 58 // LocalChangeObserver overrides. |
| 59 virtual void OnRemoteChangeAvailable(int64 pending_changes) OVERRIDE; |
| 60 |
| 49 Profile* profile_; | 61 Profile* profile_; |
| 50 | 62 |
| 63 int64 pending_local_changes_; |
| 64 int64 pending_remote_changes_; |
| 65 |
| 51 scoped_ptr<LocalFileSyncService> local_file_service_; | 66 scoped_ptr<LocalFileSyncService> local_file_service_; |
| 52 | 67 |
| 53 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); | 68 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); |
| 54 }; | 69 }; |
| 55 | 70 |
| 56 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { | 71 class SyncFileSystemServiceFactory : public ProfileKeyedServiceFactory { |
| 57 public: | 72 public: |
| 58 static SyncFileSystemService* GetForProfile(Profile* profile); | 73 static SyncFileSystemService* GetForProfile(Profile* profile); |
| 59 static SyncFileSystemService* FindForProfile(Profile* profile); | 74 static SyncFileSystemService* FindForProfile(Profile* profile); |
| 60 static SyncFileSystemServiceFactory* GetInstance(); | 75 static SyncFileSystemServiceFactory* GetInstance(); |
| 61 | 76 |
| 62 private: | 77 private: |
| 63 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; | 78 friend struct DefaultSingletonTraits<SyncFileSystemServiceFactory>; |
| 64 SyncFileSystemServiceFactory(); | 79 SyncFileSystemServiceFactory(); |
| 65 virtual ~SyncFileSystemServiceFactory(); | 80 virtual ~SyncFileSystemServiceFactory(); |
| 66 | 81 |
| 67 // ProfileKeyedServiceFactory overrides. | 82 // ProfileKeyedServiceFactory overrides. |
| 68 virtual ProfileKeyedService* BuildServiceInstanceFor( | 83 virtual ProfileKeyedService* BuildServiceInstanceFor( |
| 69 Profile* profile) const OVERRIDE; | 84 Profile* profile) const OVERRIDE; |
| 70 }; | 85 }; |
| 71 | 86 |
| 72 } // namespace sync_file_system | 87 } // namespace sync_file_system |
| 73 | 88 |
| 74 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 89 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| OLD | NEW |