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 "base/threading/thread_checker.h"
13 #include "components/drive/file_errors.h"
14 #include "google_apis/drive/drive_api_error_codes.h"
18 class SequencedTaskRunner
;
27 class ResourceMetadata
;
28 } // namespace internal
30 namespace file_system
{
32 class OperationDelegate
;
34 // This class encapsulates the drive Remove function. It is responsible for
35 // moving the removed entry to the trash.
36 class RemoveOperation
{
38 RemoveOperation(base::SequencedTaskRunner
* blocking_task_runner
,
39 OperationDelegate
* delegate
,
40 internal::ResourceMetadata
* metadata
,
41 internal::FileCache
* cache
);
44 // Removes the resource at |path|. If |path| is a directory and |is_recursive|
45 // is set, it recursively removes all the descendants. If |is_recursive| is
46 // not set, it succeeds only when the directory is empty.
48 // |callback| must not be null.
49 void Remove(const base::FilePath
& path
,
51 const FileOperationCallback
& callback
);
54 // Part of Remove(). Called after UpdateLocalState() completion.
55 void RemoveAfterUpdateLocalState(const FileOperationCallback
& callback
,
56 const std::string
* local_id
,
57 const ResourceEntry
* entry
,
58 const base::FilePath
* changed_directory_path
,
61 scoped_refptr
<base::SequencedTaskRunner
> blocking_task_runner_
;
62 OperationDelegate
* delegate_
;
63 internal::ResourceMetadata
* metadata_
;
64 internal::FileCache
* cache_
;
66 base::ThreadChecker thread_checker_
;
68 // Note: This should remain the last member so it'll be destroyed and
69 // invalidate the weak pointers before any other members are destroyed.
70 base::WeakPtrFactory
<RemoveOperation
> weak_ptr_factory_
;
71 DISALLOW_COPY_AND_ASSIGN(RemoveOperation
);
74 } // namespace file_system
77 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_