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