Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / sync / entry_update_performer.h
blob7dd53def92f564a2ff715f7401699ac3a4af4a3f
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_ENTRY_UPDATE_PERFORMER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_ENTRY_UPDATE_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 "chrome/browser/chromeos/drive/file_errors.h"
13 #include "google_apis/drive/gdata_errorcode.h"
15 namespace base {
16 class SequencedTaskRunner;
17 } // namespace base
19 namespace google_apis {
20 class ResourceEntry;
21 } // namespace google_apis
23 namespace drive {
25 class JobScheduler;
26 class ResourceEntry;
28 namespace file_system {
29 class OperationObserver;
30 } // namespace file_system
32 namespace internal {
34 class EntryRevertPerformer;
35 class RemovePerformer;
36 class ResourceMetadata;
38 // This class is responsible to perform server side update of an entry.
39 class EntryUpdatePerformer {
40 public:
41 EntryUpdatePerformer(base::SequencedTaskRunner* blocking_task_runner,
42 file_system::OperationObserver* observer,
43 JobScheduler* scheduler,
44 ResourceMetadata* metadata);
45 ~EntryUpdatePerformer();
47 // Requests the server to update the metadata of the entry specified by
48 // |local_id| with the locally stored one.
49 // Invokes |callback| when finished with the result of the operation.
50 // |callback| must not be null.
51 void UpdateEntry(const std::string& local_id,
52 const FileOperationCallback& callback);
54 private:
55 // Part of UpdateEntry(). Called after local metadata look up.
56 void UpdateEntryAfterPrepare(const FileOperationCallback& callback,
57 scoped_ptr<ResourceEntry> entry,
58 scoped_ptr<ResourceEntry> parent_entry,
59 FileError error);
61 // Part of UpdateEntry(). Called after UpdateResource is completed.
62 void UpdateEntryAfterUpdateResource(
63 const FileOperationCallback& callback,
64 const std::string& local_id,
65 google_apis::GDataErrorCode status,
66 scoped_ptr<google_apis::ResourceEntry> resource_entry);
68 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
69 JobScheduler* scheduler_;
70 ResourceMetadata* metadata_;
71 scoped_ptr<RemovePerformer> remove_performer_;
72 scoped_ptr<EntryRevertPerformer> entry_revert_performer_;
74 // Note: This should remain the last member so it'll be destroyed and
75 // invalidate the weak pointers before any other members are destroyed.
76 base::WeakPtrFactory<EntryUpdatePerformer> weak_ptr_factory_;
77 DISALLOW_COPY_AND_ASSIGN(EntryUpdatePerformer);
80 } // namespace internal
81 } // namespace drive
83 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_ENTRY_UPDATE_PERFORMER_H_