Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_system / remove_operation.h
blob215e6a3f949b5dc742e9f0669c2d990b4e96c456
1 // Copyright (c) 2012 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_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "google_apis/drive/drive_api_error_codes.h"
15 namespace base {
16 class FilePath;
17 class SequencedTaskRunner;
18 } // namespace base
20 namespace drive {
22 class ResourceEntry;
24 namespace internal {
25 class FileCache;
26 class ResourceMetadata;
27 } // namespace internal
29 namespace file_system {
31 class OperationDelegate;
33 // This class encapsulates the drive Remove function. It is responsible for
34 // moving the removed entry to the trash.
35 class RemoveOperation {
36 public:
37 RemoveOperation(base::SequencedTaskRunner* blocking_task_runner,
38 OperationDelegate* delegate,
39 internal::ResourceMetadata* metadata,
40 internal::FileCache* cache);
41 ~RemoveOperation();
43 // Removes the resource at |path|. If |path| is a directory and |is_recursive|
44 // is set, it recursively removes all the descendants. If |is_recursive| is
45 // not set, it succeeds only when the directory is empty.
47 // |callback| must not be null.
48 void Remove(const base::FilePath& path,
49 bool is_recursive,
50 const FileOperationCallback& callback);
52 private:
53 // Part of Remove(). Called after UpdateLocalState() completion.
54 void RemoveAfterUpdateLocalState(const FileOperationCallback& callback,
55 const std::string* local_id,
56 const ResourceEntry* entry,
57 const base::FilePath* changed_directory_path,
58 FileError error);
60 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
61 OperationDelegate* delegate_;
62 internal::ResourceMetadata* metadata_;
63 internal::FileCache* cache_;
65 // Note: This should remain the last member so it'll be destroyed and
66 // invalidate the weak pointers before any other members are destroyed.
67 base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_;
68 DISALLOW_COPY_AND_ASSIGN(RemoveOperation);
71 } // namespace file_system
72 } // namespace drive
74 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_