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

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

Issue 15974004: drive: Rewrite UpdateOpreation to access cache/metadata on the blocking pool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ClearDirtyOnUIThread Created 7 years, 6 months 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_UPDATE_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_UPDATE_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_UPDATE_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_UPDATE_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/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h"
11 #include "chrome/browser/chromeos/drive/file_system_interface.h" 13 #include "chrome/browser/chromeos/drive/file_system_interface.h"
12 #include "chrome/browser/google_apis/gdata_errorcode.h" 14 #include "chrome/browser/google_apis/gdata_errorcode.h"
13 15
14 namespace base { 16 namespace base {
15 class FilePath; 17 class FilePath;
18 class SequencedTaskRunner;
16 } // namespace base 19 } // namespace base
17 20
18 namespace drive { 21 namespace drive {
19 22
20 class JobScheduler; 23 class JobScheduler;
21 class ResourceEntry; 24 class ResourceEntry;
22 25
23 namespace internal { 26 namespace internal {
24 class FileCache; 27 class FileCache;
25 class ResourceMetadata; 28 class ResourceMetadata;
26 } // namespace internal 29 } // namespace internal
27 30
28 namespace file_system { 31 namespace file_system {
29 32
30 class OperationObserver; 33 class OperationObserver;
31 34
32 // This class encapsulates the drive Update function. It is responsible for 35 // This class encapsulates the drive Update function. It is responsible for
33 // sending the request to the drive API, then updating the local state and 36 // sending the request to the drive API, then updating the local state and
34 // metadata to reflect the new state. 37 // metadata to reflect the new state.
35 class UpdateOperation { 38 class UpdateOperation {
36 public: 39 public:
37 UpdateOperation(OperationObserver* observer, 40 UpdateOperation(base::SequencedTaskRunner* blocking_task_runner,
41 OperationObserver* observer,
38 JobScheduler* scheduler, 42 JobScheduler* scheduler,
39 internal::ResourceMetadata* metadata, 43 internal::ResourceMetadata* metadata,
40 internal::FileCache* cache); 44 internal::FileCache* cache);
41 ~UpdateOperation(); 45 ~UpdateOperation();
42 46
43 // Updates a file by the given |resource_id| on the Drive server by 47 // Updates a file by the given |resource_id| on the Drive server by
44 // uploading an updated version. Used for uploading dirty files. The file 48 // uploading an updated version. Used for uploading dirty files. The file
45 // should already be present in the cache. 49 // should already be present in the cache.
46 // 50 //
47 // |callback| must not be null. 51 // |callback| must not be null.
48 void UpdateFileByResourceId(const std::string& resource_id, 52 void UpdateFileByResourceId(const std::string& resource_id,
49 DriveClientContext context, 53 DriveClientContext context,
50 const FileOperationCallback& callback); 54 const FileOperationCallback& callback);
51 55
52 private: 56 private:
53 void UpdateFileAfterGetEntryInfo(DriveClientContext context, 57 void UpdateFileAfterGetLocalState(DriveClientContext context,
54 const FileOperationCallback& callback, 58 const FileOperationCallback& callback,
55 FileError error, 59 const ResourceEntry* entry,
56 const base::FilePath& drive_file_path, 60 const base::FilePath* drive_file_path,
57 scoped_ptr<ResourceEntry> entry); 61 const base::FilePath* cache_file_path,
58 62 FileError error);
59 void UpdateFileAfterGetFile(DriveClientContext context,
60 const FileOperationCallback& callback,
61 const base::FilePath& drive_file_path,
62 scoped_ptr<ResourceEntry> entry,
63 FileError error,
64 const base::FilePath& cache_file_path);
65 63
66 void UpdateFileAfterUpload( 64 void UpdateFileAfterUpload(
67 const FileOperationCallback& callback, 65 const FileOperationCallback& callback,
68 google_apis::GDataErrorCode error, 66 google_apis::GDataErrorCode error,
69 scoped_ptr<google_apis::ResourceEntry> resource_entry); 67 scoped_ptr<google_apis::ResourceEntry> resource_entry);
70 68
71 void UpdateFileAfterRefresh(const FileOperationCallback& callback, 69 void UpdateFileAfterUpdateLocalState(const FileOperationCallback& callback,
72 FileError error, 70 const base::FilePath* drive_file_path,
73 const base::FilePath& drive_file_path, 71 FileError error);
74 scoped_ptr<ResourceEntry> entry);
75 72
73 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
76 OperationObserver* observer_; 74 OperationObserver* observer_;
77 JobScheduler* scheduler_; 75 JobScheduler* scheduler_;
78 internal::ResourceMetadata* metadata_; 76 internal::ResourceMetadata* metadata_;
79 internal::FileCache* cache_; 77 internal::FileCache* cache_;
80 78
81 // Note: This should remain the last member so it'll be destroyed and 79 // Note: This should remain the last member so it'll be destroyed and
82 // invalidate the weak pointers before any other members are destroyed. 80 // invalidate the weak pointers before any other members are destroyed.
83 base::WeakPtrFactory<UpdateOperation> weak_ptr_factory_; 81 base::WeakPtrFactory<UpdateOperation> weak_ptr_factory_;
84 DISALLOW_COPY_AND_ASSIGN(UpdateOperation); 82 DISALLOW_COPY_AND_ASSIGN(UpdateOperation);
85 }; 83 };
86 84
87 } // namespace file_system 85 } // namespace file_system
88 } // namespace drive 86 } // namespace drive
89 87
90 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_UPDATE_OPERATION_H_ 88 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_UPDATE_OPERATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/operations.cc ('k') | chrome/browser/chromeos/drive/file_system/update_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698