Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / sync / remove_performer.h
blob87ff0be576e9cc1f938689dc3da340fbab5134b6
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_CHROMEOS_DRIVE_SYNC_REMOVE_PERFORMER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_REMOVE_PERFORMER_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"
16 namespace base {
17 class SequencedTaskRunner;
20 namespace google_apis {
21 class FileResource;
24 namespace drive {
26 class JobScheduler;
27 class ResourceEntry;
28 struct ClientContext;
30 namespace file_system {
31 class OperationDelegate;
32 } // namespace file_system
34 namespace internal {
36 class EntryRevertPerformer;
37 class ResourceMetadata;
39 // This class encapsulates the drive Remove function. It is responsible for
40 // sending the request to the drive API, then updating the local state and
41 // metadata to reflect the new state.
42 class RemovePerformer {
43 public:
44 RemovePerformer(base::SequencedTaskRunner* blocking_task_runner,
45 file_system::OperationDelegate* delegate,
46 JobScheduler* scheduler,
47 ResourceMetadata* metadata);
48 ~RemovePerformer();
50 // Removes the resource.
52 // |callback| must not be null.
53 void Remove(const std::string& local_id,
54 const ClientContext& context,
55 const FileOperationCallback& callback);
57 private:
58 // Part of Remove(). Called after GetResourceEntry() completion.
59 void RemoveAfterGetResourceEntry(const ClientContext& context,
60 const FileOperationCallback& callback,
61 const ResourceEntry* entry,
62 FileError error);
64 // Requests the server to move the specified resource to the trash.
65 void TrashResource(const ClientContext& context,
66 const FileOperationCallback& callback,
67 const std::string& resource_id,
68 const std::string& local_id);
70 // Part of TrashResource(). Called after server-side removal is done.
71 void TrashResourceAfterUpdateRemoteState(
72 const ClientContext& context,
73 const FileOperationCallback& callback,
74 const std::string& local_id,
75 google_apis::DriveApiErrorCode status);
77 // Requests the server to detach the specified resource from its parent.
78 void UnparentResource(const ClientContext& context,
79 const FileOperationCallback& callback,
80 const std::string& resource_id,
81 const std::string& local_id);
83 // Part of UnparentResource().
84 void UnparentResourceAfterGetFileResource(
85 const ClientContext& context,
86 const FileOperationCallback& callback,
87 const std::string& local_id,
88 google_apis::DriveApiErrorCode status,
89 scoped_ptr<google_apis::FileResource> file_resource);
91 // Part of UnparentResource().
92 void UnparentResourceAfterUpdateRemoteState(
93 const FileOperationCallback& callback,
94 const std::string& local_id,
95 google_apis::DriveApiErrorCode status);
97 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
98 file_system::OperationDelegate* delegate_;
99 JobScheduler* scheduler_;
100 ResourceMetadata* metadata_;
101 scoped_ptr<EntryRevertPerformer> entry_revert_performer_;
103 base::ThreadChecker thread_checker_;
105 // Note: This should remain the last member so it'll be destroyed and
106 // invalidate the weak pointers before any other members are destroyed.
107 base::WeakPtrFactory<RemovePerformer> weak_ptr_factory_;
108 DISALLOW_COPY_AND_ASSIGN(RemovePerformer);
111 } // namespace internal
112 } // namespace drive
114 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_REMOVE_PERFORMER_H_