Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/sync_file_system/local/sync_file_system_backend.h

Issue 22810002: SyncFS: Reorder initialization sequence of SyncFileSystemService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Profile handling Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
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"
8 #include "webkit/browser/fileapi/file_system_backend.h" 13 #include "webkit/browser/fileapi/file_system_backend.h"
9 #include "webkit/browser/fileapi/file_system_quota_util.h" 14 #include "webkit/browser/fileapi/file_system_quota_util.h"
10 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" 15 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
11 16
12 namespace sync_file_system { 17 namespace sync_file_system {
13 18
14 class LocalFileChangeTracker; 19 class LocalFileChangeTracker;
15 class LocalFileSyncContext; 20 class LocalFileSyncContext;
16 21
17 class SyncFileSystemBackend 22 class SyncFileSystemBackend
18 : public fileapi::FileSystemBackend { 23 : public fileapi::FileSystemBackend {
19 public: 24 public:
20 SyncFileSystemBackend(); 25 explicit SyncFileSystemBackend(Profile* profile);
21 virtual ~SyncFileSystemBackend(); 26 virtual ~SyncFileSystemBackend();
22 27
28 static SyncFileSystemBackend* CreateForTesting();
29
23 // FileSystemBackend overrides. 30 // FileSystemBackend overrides.
24 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; 31 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
25 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; 32 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE;
26 virtual void OpenFileSystem( 33 virtual void OpenFileSystem(
27 const GURL& origin_url, 34 const GURL& origin_url,
28 fileapi::FileSystemType type, 35 fileapi::FileSystemType type,
29 fileapi::OpenFileSystemMode mode, 36 fileapi::OpenFileSystemMode mode,
30 const OpenFileSystemCallback& callback) OVERRIDE; 37 const OpenFileSystemCallback& callback) OVERRIDE;
31 virtual fileapi::FileSystemFileUtil* GetFileUtil( 38 virtual fileapi::FileSystemFileUtil* GetFileUtil(
32 fileapi::FileSystemType type) OVERRIDE; 39 fileapi::FileSystemType type) OVERRIDE;
(...skipping 14 matching lines...) Expand all
47 fileapi::FileSystemContext* context) const OVERRIDE; 54 fileapi::FileSystemContext* context) const OVERRIDE;
48 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( 55 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
49 const fileapi::FileSystemURL& url, 56 const fileapi::FileSystemURL& url,
50 int64 offset, 57 int64 offset,
51 fileapi::FileSystemContext* context) const OVERRIDE; 58 fileapi::FileSystemContext* context) const OVERRIDE;
52 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; 59 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
53 60
54 static SyncFileSystemBackend* GetBackend( 61 static SyncFileSystemBackend* GetBackend(
55 const fileapi::FileSystemContext* context); 62 const fileapi::FileSystemContext* context);
56 63
57 sync_file_system::LocalFileChangeTracker* change_tracker() { 64 LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); }
58 return change_tracker_.get(); 65 void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker);
59 }
60 void SetLocalFileChangeTracker(
61 scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker);
62 66
63 sync_file_system::LocalFileSyncContext* sync_context() { 67 LocalFileSyncContext* sync_context() { return sync_context_.get(); }
64 return sync_context_.get(); 68 void set_sync_context(LocalFileSyncContext* sync_context);
65 }
66 void set_sync_context(sync_file_system::LocalFileSyncContext* sync_context);
67 69
68 private: 70 private:
69 // Owned by FileSystemContext. 71 class ProfileHolder : public content::NotificationObserver {
kinuko 2013/08/28 06:51:28 Is it possible to just make SyncFSBackend implemen
70 fileapi::SandboxFileSystemBackendDelegate* delegate_; 72 public:
73 explicit ProfileHolder(Profile* profile);
71 74
72 scoped_ptr<sync_file_system::LocalFileChangeTracker> change_tracker_; 75 // NotificationObserver override.
73 scoped_refptr<sync_file_system::LocalFileSyncContext> sync_context_; 76 virtual void Observe(int type,
77 const content::NotificationSource& source,
78 const content::NotificationDetails& details) OVERRIDE;
79
80 Profile* GetProfile();
81
82 private:
83 content::NotificationRegistrar registrar_;
84 Profile* profile_;
85 };
86
87 // Not owned.
88 fileapi::FileSystemContext* context_;
89
90 scoped_ptr<LocalFileChangeTracker> change_tracker_;
91 scoped_refptr<LocalFileSyncContext> sync_context_;
92
93 // Should be accessed on the UI thread.
94 scoped_ptr<ProfileHolder> profile_holder_;
95
96 // A flag to skip the initialization sequence of SyncFileSystemService for
97 // testing.
98 bool skip_initialize_syncfs_service_for_testing_;
99
100 // Constructor for CreateForTesting.
101 SyncFileSystemBackend();
102
103 fileapi::SandboxFileSystemBackendDelegate* GetDelegate() const;
104
105 void InitializeSyncFileSystemService(
106 const GURL& origin_url,
107 const SyncStatusCallback& callback);
108 void DidInitializeSyncFileSystemService(
109 const GURL& origin_url,
110 fileapi::FileSystemType type,
111 fileapi::OpenFileSystemMode mode,
112 const OpenFileSystemCallback& callback,
113 SyncStatusCode status);
74 114
75 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemBackend); 115 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemBackend);
76 }; 116 };
77 117
78 } // namespace sync_file_system 118 } // namespace sync_file_system
79 119
80 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_ 120 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNC_FILE_SYSTEM_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698