OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ |
7 | 7 |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 9 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
10 #include "chrome/browser/sync_file_system/sync_status_code.h" | 10 #include "chrome/browser/sync_file_system/sync_status_code.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "webkit/browser/fileapi/file_system_backend.h" | 13 #include "storage/browser/fileapi/file_system_backend.h" |
14 #include "webkit/browser/fileapi/file_system_quota_util.h" | 14 #include "storage/browser/fileapi/file_system_quota_util.h" |
15 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" | 15 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h" |
16 | 16 |
17 namespace sync_file_system { | 17 namespace sync_file_system { |
18 | 18 |
19 class LocalFileChangeTracker; | 19 class LocalFileChangeTracker; |
20 class LocalFileSyncContext; | 20 class LocalFileSyncContext; |
21 | 21 |
22 class SyncFileSystemBackend | 22 class SyncFileSystemBackend : public storage::FileSystemBackend { |
23 : public fileapi::FileSystemBackend { | |
24 public: | 23 public: |
25 explicit SyncFileSystemBackend(Profile* profile); | 24 explicit SyncFileSystemBackend(Profile* profile); |
26 virtual ~SyncFileSystemBackend(); | 25 virtual ~SyncFileSystemBackend(); |
27 | 26 |
28 static SyncFileSystemBackend* CreateForTesting(); | 27 static SyncFileSystemBackend* CreateForTesting(); |
29 | 28 |
30 // FileSystemBackend overrides. | 29 // FileSystemBackend overrides. |
31 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; | 30 virtual bool CanHandleType(storage::FileSystemType type) const OVERRIDE; |
32 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; | 31 virtual void Initialize(storage::FileSystemContext* context) OVERRIDE; |
33 virtual void ResolveURL(const fileapi::FileSystemURL& url, | 32 virtual void ResolveURL(const storage::FileSystemURL& url, |
34 fileapi::OpenFileSystemMode mode, | 33 storage::OpenFileSystemMode mode, |
35 const OpenFileSystemCallback& callback) OVERRIDE; | 34 const OpenFileSystemCallback& callback) OVERRIDE; |
36 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil( | 35 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
37 fileapi::FileSystemType type) OVERRIDE; | 36 storage::FileSystemType type) OVERRIDE; |
38 virtual fileapi::CopyOrMoveFileValidatorFactory* | 37 virtual storage::CopyOrMoveFileValidatorFactory* |
39 GetCopyOrMoveFileValidatorFactory( | 38 GetCopyOrMoveFileValidatorFactory(storage::FileSystemType type, |
40 fileapi::FileSystemType type, | 39 base::File::Error* error_code) OVERRIDE; |
41 base::File::Error* error_code) OVERRIDE; | 40 virtual storage::FileSystemOperation* CreateFileSystemOperation( |
42 virtual fileapi::FileSystemOperation* CreateFileSystemOperation( | 41 const storage::FileSystemURL& url, |
43 const fileapi::FileSystemURL& url, | 42 storage::FileSystemContext* context, |
44 fileapi::FileSystemContext* context, | |
45 base::File::Error* error_code) const OVERRIDE; | 43 base::File::Error* error_code) const OVERRIDE; |
46 virtual bool SupportsStreaming( | 44 virtual bool SupportsStreaming( |
47 const fileapi::FileSystemURL& url) const OVERRIDE; | 45 const storage::FileSystemURL& url) const OVERRIDE; |
48 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 46 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( |
49 const fileapi::FileSystemURL& url, | 47 const storage::FileSystemURL& url, |
50 int64 offset, | 48 int64 offset, |
51 const base::Time& expected_modification_time, | 49 const base::Time& expected_modification_time, |
52 fileapi::FileSystemContext* context) const OVERRIDE; | 50 storage::FileSystemContext* context) const OVERRIDE; |
53 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( | 51 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter( |
54 const fileapi::FileSystemURL& url, | 52 const storage::FileSystemURL& url, |
55 int64 offset, | 53 int64 offset, |
56 fileapi::FileSystemContext* context) const OVERRIDE; | 54 storage::FileSystemContext* context) const OVERRIDE; |
57 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 55 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
58 | 56 |
59 static SyncFileSystemBackend* GetBackend( | 57 static SyncFileSystemBackend* GetBackend( |
60 const fileapi::FileSystemContext* context); | 58 const storage::FileSystemContext* context); |
61 | 59 |
62 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); } | 60 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); } |
63 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker); | 61 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker); |
64 | 62 |
65 LocalFileSyncContext* sync_context() { return sync_context_.get(); } | 63 LocalFileSyncContext* sync_context() { return sync_context_.get(); } |
66 void set_sync_context(LocalFileSyncContext* sync_context); | 64 void set_sync_context(LocalFileSyncContext* sync_context); |
67 | 65 |
68 private: | 66 private: |
69 class ProfileHolder : public content::NotificationObserver { | 67 class ProfileHolder : public content::NotificationObserver { |
70 public: | 68 public: |
71 explicit ProfileHolder(Profile* profile); | 69 explicit ProfileHolder(Profile* profile); |
72 | 70 |
73 // NotificationObserver override. | 71 // NotificationObserver override. |
74 virtual void Observe(int type, | 72 virtual void Observe(int type, |
75 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
76 const content::NotificationDetails& details) OVERRIDE; | 74 const content::NotificationDetails& details) OVERRIDE; |
77 | 75 |
78 Profile* GetProfile(); | 76 Profile* GetProfile(); |
79 | 77 |
80 private: | 78 private: |
81 content::NotificationRegistrar registrar_; | 79 content::NotificationRegistrar registrar_; |
82 Profile* profile_; | 80 Profile* profile_; |
83 }; | 81 }; |
84 | 82 |
85 // Not owned. | 83 // Not owned. |
86 fileapi::FileSystemContext* context_; | 84 storage::FileSystemContext* context_; |
87 | 85 |
88 scoped_ptr<LocalFileChangeTracker> change_tracker_; | 86 scoped_ptr<LocalFileChangeTracker> change_tracker_; |
89 scoped_refptr<LocalFileSyncContext> sync_context_; | 87 scoped_refptr<LocalFileSyncContext> sync_context_; |
90 | 88 |
91 // Should be accessed on the UI thread. | 89 // Should be accessed on the UI thread. |
92 scoped_ptr<ProfileHolder> profile_holder_; | 90 scoped_ptr<ProfileHolder> profile_holder_; |
93 | 91 |
94 // A flag to skip the initialization sequence of SyncFileSystemService for | 92 // A flag to skip the initialization sequence of SyncFileSystemService for |
95 // testing. | 93 // testing. |
96 bool skip_initialize_syncfs_service_for_testing_; | 94 bool skip_initialize_syncfs_service_for_testing_; |
97 | 95 |
98 fileapi::SandboxFileSystemBackendDelegate* GetDelegate() const; | 96 storage::SandboxFileSystemBackendDelegate* GetDelegate() const; |
99 | 97 |
100 void InitializeSyncFileSystemService( | 98 void InitializeSyncFileSystemService( |
101 const GURL& origin_url, | 99 const GURL& origin_url, |
102 const SyncStatusCallback& callback); | 100 const SyncStatusCallback& callback); |
103 void DidInitializeSyncFileSystemService( | 101 void DidInitializeSyncFileSystemService( |
104 fileapi::FileSystemContext* context, | 102 storage::FileSystemContext* context, |
105 const GURL& origin_url, | 103 const GURL& origin_url, |
106 fileapi::FileSystemType type, | 104 storage::FileSystemType type, |
107 fileapi::OpenFileSystemMode mode, | 105 storage::OpenFileSystemMode mode, |
108 const OpenFileSystemCallback& callback, | 106 const OpenFileSystemCallback& callback, |
109 SyncStatusCode status); | 107 SyncStatusCode status); |
110 | 108 |
111 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemBackend); | 109 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemBackend); |
112 }; | 110 }; |
113 | 111 |
114 } // namespace sync_file_system | 112 } // namespace sync_file_system |
115 | 113 |
116 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ | 114 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |