| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_ENTRY_UPDATE_PERFORMER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_ENTRY_UPDATE_PERFORMER_H_ | |
| 7 | |
| 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" | |
| 15 | |
| 16 namespace base { | |
| 17 class ScopedClosureRunner; | |
| 18 class SequencedTaskRunner; | |
| 19 } // namespace base | |
| 20 | |
| 21 namespace google_apis { | |
| 22 class FileResource; | |
| 23 } // namespace google_apis | |
| 24 | |
| 25 namespace drive { | |
| 26 | |
| 27 class FileChange; | |
| 28 class JobScheduler; | |
| 29 class ResourceEntry; | |
| 30 struct ClientContext; | |
| 31 | |
| 32 namespace file_system { | |
| 33 class OperationDelegate; | |
| 34 } // namespace file_system | |
| 35 | |
| 36 namespace internal { | |
| 37 | |
| 38 class EntryRevertPerformer; | |
| 39 class FileCache; | |
| 40 class LoaderController; | |
| 41 class RemovePerformer; | |
| 42 class ResourceMetadata; | |
| 43 | |
| 44 // This class is responsible to perform server side update of an entry. | |
| 45 class EntryUpdatePerformer { | |
| 46 public: | |
| 47 EntryUpdatePerformer(base::SequencedTaskRunner* blocking_task_runner, | |
| 48 file_system::OperationDelegate* delegate, | |
| 49 JobScheduler* scheduler, | |
| 50 ResourceMetadata* metadata, | |
| 51 FileCache* cache, | |
| 52 LoaderController* loader_controller); | |
| 53 ~EntryUpdatePerformer(); | |
| 54 | |
| 55 // Requests the server to update the metadata of the entry specified by | |
| 56 // |local_id| with the locally stored one. | |
| 57 // Invokes |callback| when finished with the result of the operation. | |
| 58 // |callback| must not be null. | |
| 59 void UpdateEntry(const std::string& local_id, | |
| 60 const ClientContext& context, | |
| 61 const FileOperationCallback& callback); | |
| 62 | |
| 63 struct LocalState; | |
| 64 | |
| 65 private: | |
| 66 // Part of UpdateEntry(). Called after local metadata look up. | |
| 67 void UpdateEntryAfterPrepare(const ClientContext& context, | |
| 68 const FileOperationCallback& callback, | |
| 69 scoped_ptr<LocalState> local_state, | |
| 70 FileError error); | |
| 71 | |
| 72 // Part of UpdateEntry(). Called after UpdateResource is completed. | |
| 73 void UpdateEntryAfterUpdateResource( | |
| 74 const ClientContext& context, | |
| 75 const FileOperationCallback& callback, | |
| 76 scoped_ptr<LocalState> local_state, | |
| 77 scoped_ptr<base::ScopedClosureRunner> loader_lock, | |
| 78 google_apis::DriveApiErrorCode status, | |
| 79 scoped_ptr<google_apis::FileResource> entry); | |
| 80 | |
| 81 // Part of UpdateEntry(). Called after FinishUpdate is completed. | |
| 82 void UpdateEntryAfterFinish(const FileOperationCallback& callback, | |
| 83 const FileChange* changed_files, | |
| 84 FileError error); | |
| 85 | |
| 86 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | |
| 87 file_system::OperationDelegate* delegate_; | |
| 88 JobScheduler* scheduler_; | |
| 89 ResourceMetadata* metadata_; | |
| 90 FileCache* cache_; | |
| 91 LoaderController* loader_controller_; | |
| 92 scoped_ptr<RemovePerformer> remove_performer_; | |
| 93 scoped_ptr<EntryRevertPerformer> entry_revert_performer_; | |
| 94 | |
| 95 base::ThreadChecker thread_checker_; | |
| 96 | |
| 97 // Note: This should remain the last member so it'll be destroyed and | |
| 98 // invalidate the weak pointers before any other members are destroyed. | |
| 99 base::WeakPtrFactory<EntryUpdatePerformer> weak_ptr_factory_; | |
| 100 DISALLOW_COPY_AND_ASSIGN(EntryUpdatePerformer); | |
| 101 }; | |
| 102 | |
| 103 } // namespace internal | |
| 104 } // namespace drive | |
| 105 | |
| 106 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_SYNC_ENTRY_UPDATE_PERFORMER_H_ | |
| OLD | NEW |