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