Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/browser/chromeos/drive/file_system/remove_operation.h

Issue 68543002: drive: Support offline delete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to drive/other and mark as deleted Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h" 12 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "chrome/browser/google_apis/gdata_errorcode.h" 13 #include "chrome/browser/google_apis/gdata_errorcode.h"
14 14
15 namespace base { 15 namespace base {
16 class FilePath; 16 class FilePath;
17 class SequencedTaskRunner; 17 class SequencedTaskRunner;
18 } // namespace base 18 } // namespace base
19 19
20 namespace drive { 20 namespace drive {
21 21
22 class JobScheduler;
23 class ResourceEntry; 22 class ResourceEntry;
24 23
25 namespace internal { 24 namespace internal {
26 class FileCache; 25 class FileCache;
27 class ResourceMetadata; 26 class ResourceMetadata;
28 } // namespace internal 27 } // namespace internal
29 28
30 namespace file_system { 29 namespace file_system {
31 30
32 class OperationObserver; 31 class OperationObserver;
33 32
34 // This class encapsulates the drive Remove function. It is responsible for
35 // sending the request to the drive API, then updating the local state and
36 // metadata to reflect the new state.
37 class RemoveOperation { 33 class RemoveOperation {
kinaba 2013/11/12 06:21:29 Please keep some brief class comment.
hashimoto 2013/11/25 10:13:58 Done.
38 public: 34 public:
39 RemoveOperation(base::SequencedTaskRunner* blocking_task_runner, 35 RemoveOperation(base::SequencedTaskRunner* blocking_task_runner,
40 OperationObserver* observer, 36 OperationObserver* observer,
41 JobScheduler* scheduler,
42 internal::ResourceMetadata* metadata, 37 internal::ResourceMetadata* metadata,
43 internal::FileCache* cache); 38 internal::FileCache* cache);
44 ~RemoveOperation(); 39 ~RemoveOperation();
45 40
46 // Removes the resource at |path|. If |path| is a directory and |is_recursive| 41 // Removes the resource at |path|. If |path| is a directory and |is_recursive|
47 // is set, it recursively removes all the descendants. If |is_recursive| is 42 // is set, it recursively removes all the descendants. If |is_recursive| is
48 // not set, it succeeds only when the directory is empty. 43 // not set, it succeeds only when the directory is empty.
49 // 44 //
50 // |callback| must not be null. 45 // |callback| must not be null.
51 void Remove(const base::FilePath& path, 46 void Remove(const base::FilePath& path,
52 bool is_recursive, 47 bool is_recursive,
53 const FileOperationCallback& callback); 48 const FileOperationCallback& callback);
54 49
55 private: 50 private:
56 // Part of Remove(). Called after CheckLocalState() completion.
57 void RemoveAfterCheckLocalState(const FileOperationCallback& callback,
58 const std::string* parent_resource_id,
59 const ResourceEntry* entry,
60 FileError error);
61
62 // Part of Remove(). Called after server-side removal is done.
63 void RemoveAfterUpdateRemoteState(
64 const FileOperationCallback& callback,
65 const base::Callback<FileError(base::FilePath*)>& local_update_task,
66 google_apis::GDataErrorCode status);
67
68 // Part of Remove(). Called after UpdateLocalState() completion. 51 // Part of Remove(). Called after UpdateLocalState() completion.
69 void RemoveAfterUpdateLocalState(const FileOperationCallback& callback, 52 void RemoveAfterUpdateLocalState(const FileOperationCallback& callback,
53 const std::string* local_id,
70 const base::FilePath* changed_directory_path, 54 const base::FilePath* changed_directory_path,
71 FileError error); 55 FileError error);
72 56
73 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 57 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
74 OperationObserver* observer_; 58 OperationObserver* observer_;
75 JobScheduler* scheduler_;
76 internal::ResourceMetadata* metadata_; 59 internal::ResourceMetadata* metadata_;
77 internal::FileCache* cache_; 60 internal::FileCache* cache_;
78 61
79 // Note: This should remain the last member so it'll be destroyed and 62 // Note: This should remain the last member so it'll be destroyed and
80 // invalidate the weak pointers before any other members are destroyed. 63 // invalidate the weak pointers before any other members are destroyed.
81 base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_; 64 base::WeakPtrFactory<RemoveOperation> weak_ptr_factory_;
82 DISALLOW_COPY_AND_ASSIGN(RemoveOperation); 65 DISALLOW_COPY_AND_ASSIGN(RemoveOperation);
83 }; 66 };
84 67
85 } // namespace file_system 68 } // namespace file_system
86 } // namespace drive 69 } // namespace drive
87 70
88 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_ 71 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_REMOVE_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698