Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / sync_file_system / local / root_delete_helper.h
bloba3bfa9d9be927fd6eb19642f6a7e049fc79b225b
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"
15 class GURL;
17 namespace storage {
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
28 // case.
30 // Expected to be called on and will callback on IO thread.
31 class RootDeleteHelper {
32 public:
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);
39 ~RootDeleteHelper();
41 void Run();
43 private:
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_