summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/remove_operation_delegate.h
blob: 2a296c71b4a26f6a0a8b58f2ff5217d074e2a479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_
#define WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_

#include <stack>

#include "webkit/fileapi/recursive_operation_delegate.h"

namespace fileapi {

class RemoveOperationDelegate
    : public RecursiveOperationDelegate,
      public base::SupportsWeakPtr<RemoveOperationDelegate> {
 public:
  RemoveOperationDelegate(LocalFileSystemOperation* original_operation,
                          const FileSystemURL& url,
                          const StatusCallback& callback);
  virtual ~RemoveOperationDelegate();

  // RecursiveOperationDelegate overrides:
  virtual void Run() OVERRIDE;
  virtual void RunRecursively() OVERRIDE;
  virtual void ProcessFile(const FileSystemURL& url,
                           const StatusCallback& callback) OVERRIDE;
  virtual void ProcessDirectory(const FileSystemURL& url,
                                const StatusCallback& callback) OVERRIDE;

  using base::SupportsWeakPtr<RemoveOperationDelegate>::AsWeakPtr;

 private:
  void DidTryRemoveFile(base::PlatformFileError error);
  void DidRemoveFile(const StatusCallback& callback,
                     base::PlatformFileError error);
  void RemoveNextDirectory(base::PlatformFileError error);

  FileSystemURL url_;
  StatusCallback callback_;

  std::stack<FileSystemURL> to_remove_directories_;

  DISALLOW_COPY_AND_ASSIGN(RemoveOperationDelegate);
};

}  // namespace fileapi

#endif  // WEBKIT_FILEAPI_REMOVE_OPERATION_DELEGATE_H_