Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / sync_file_system / local / sync_file_system_backend.h
blob4b47e2873b423e69cb858f8d7f8503bddaf034d6
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
3 // found in the LICENSE file.
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_
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sync_file_system/sync_callbacks.h"
10 #include "chrome/browser/sync_file_system/sync_status_code.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "storage/browser/fileapi/file_system_backend.h"
14 #include "storage/browser/fileapi/file_system_quota_util.h"
15 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h"
16 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
18 namespace sync_file_system {
20 class LocalFileChangeTracker;
21 class LocalFileSyncContext;
23 class SyncFileSystemBackend : public storage::FileSystemBackend {
24 public:
25 explicit SyncFileSystemBackend(Profile* profile);
26 ~SyncFileSystemBackend() override;
28 static SyncFileSystemBackend* CreateForTesting();
30 // FileSystemBackend overrides.
31 bool CanHandleType(storage::FileSystemType type) const override;
32 void Initialize(storage::FileSystemContext* context) override;
33 void ResolveURL(const storage::FileSystemURL& url,
34 storage::OpenFileSystemMode mode,
35 const OpenFileSystemCallback& callback) override;
36 storage::AsyncFileUtil* GetAsyncFileUtil(
37 storage::FileSystemType type) override;
38 storage::WatcherManager* GetWatcherManager(
39 storage::FileSystemType type) override;
40 storage::CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
41 storage::FileSystemType type,
42 base::File::Error* error_code) override;
43 storage::FileSystemOperation* CreateFileSystemOperation(
44 const storage::FileSystemURL& url,
45 storage::FileSystemContext* context,
46 base::File::Error* error_code) const override;
47 bool SupportsStreaming(const storage::FileSystemURL& url) const override;
48 bool HasInplaceCopyImplementation(
49 storage::FileSystemType type) const override;
50 scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
51 const storage::FileSystemURL& url,
52 int64 offset,
53 int64 max_bytes_to_read,
54 const base::Time& expected_modification_time,
55 storage::FileSystemContext* context) const override;
56 scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter(
57 const storage::FileSystemURL& url,
58 int64 offset,
59 storage::FileSystemContext* context) const override;
60 storage::FileSystemQuotaUtil* GetQuotaUtil() override;
61 const storage::UpdateObserverList* GetUpdateObservers(
62 storage::FileSystemType type) const override;
63 const storage::ChangeObserverList* GetChangeObservers(
64 storage::FileSystemType type) const override;
65 const storage::AccessObserverList* GetAccessObservers(
66 storage::FileSystemType type) const override;
68 static SyncFileSystemBackend* GetBackend(
69 const storage::FileSystemContext* context);
71 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); }
72 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker);
74 LocalFileSyncContext* sync_context() { return sync_context_.get(); }
75 void set_sync_context(LocalFileSyncContext* sync_context);
77 private:
78 class ProfileHolder : public content::NotificationObserver {
79 public:
80 explicit ProfileHolder(Profile* profile);
82 // NotificationObserver override.
83 void Observe(int type,
84 const content::NotificationSource& source,
85 const content::NotificationDetails& details) override;
87 Profile* GetProfile();
89 private:
90 content::NotificationRegistrar registrar_;
91 Profile* profile_;
94 // Not owned.
95 storage::FileSystemContext* context_;
97 scoped_ptr<LocalFileChangeTracker> change_tracker_;
98 scoped_refptr<LocalFileSyncContext> sync_context_;
100 // Should be accessed on the UI thread.
101 scoped_ptr<ProfileHolder> profile_holder_;
103 // A flag to skip the initialization sequence of SyncFileSystemService for
104 // testing.
105 bool skip_initialize_syncfs_service_for_testing_;
107 storage::SandboxFileSystemBackendDelegate* GetDelegate() const;
109 void InitializeSyncFileSystemService(
110 const GURL& origin_url,
111 const SyncStatusCallback& callback);
112 void DidInitializeSyncFileSystemService(
113 storage::FileSystemContext* context,
114 const GURL& origin_url,
115 storage::FileSystemType type,
116 storage::OpenFileSystemMode mode,
117 const OpenFileSystemCallback& callback,
118 SyncStatusCode status);
120 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemBackend);
123 } // namespace sync_file_system
125 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_