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_ROOT_DELETE_HELPER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_ROOT_DELETE_HELPER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/files/file.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "storage/browser/fileapi/file_system_url.h"
18 class FileSystemContext
;
21 namespace sync_file_system
{
23 class LocalFileSyncStatus
;
25 // A helper class to delete the root directory of a given Sync FileSystem.
26 // This could happen when AppRoot (or SyncRoot) is deleted by remote operation,
27 // and we want to delete all local files + all pending local changes in this
30 // Expected to be called on and will callback on IO thread.
31 class RootDeleteHelper
{
33 typedef base::Callback
<void(base::File::Error
)> FileStatusCallback
;
35 RootDeleteHelper(storage::FileSystemContext
* file_system_context
,
36 LocalFileSyncStatus
* sync_status
,
37 const storage::FileSystemURL
& url
,
38 const FileStatusCallback
& callback
);
44 void DidDeleteFileSystem(base::File::Error error
);
45 void DidResetFileChangeTracker();
46 void DidOpenFileSystem(const GURL
& root
,
47 const std::string
& name
,
48 base::File::Error error
);
50 scoped_refptr
<storage::FileSystemContext
> file_system_context_
;
51 const storage::FileSystemURL url_
;
52 FileStatusCallback callback_
;
54 // Not owned; owner of this instance owns it.
55 LocalFileSyncStatus
* sync_status_
;
57 base::WeakPtrFactory
<RootDeleteHelper
> weak_factory_
;
59 DISALLOW_COPY_AND_ASSIGN(RootDeleteHelper
);
62 } // namespace sync_file_system
64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_ROOT_DELETE_HELPER_H_