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_FILE_SYSTEM_TOUCH_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_TOUCH_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/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 FilePath; | 16 class FilePath; |
17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
18 class Time; | 18 class Time; |
19 } // namespace base | 19 } // namespace base |
20 | 20 |
21 namespace google_apis { | 21 namespace google_apis { |
22 class ResourceEntry; | 22 class ResourceEntry; |
23 } // namespace google_apis | 23 } // namespace google_apis |
24 | 24 |
25 namespace drive { | 25 namespace drive { |
26 namespace internal { | 26 namespace internal { |
27 class ResourceMetadata; | 27 class ResourceMetadata; |
28 } // namespace internal | 28 } // namespace internal |
29 | 29 |
30 class JobScheduler; | |
31 class ResourceEntry; | 30 class ResourceEntry; |
32 | 31 |
33 namespace file_system { | 32 namespace file_system { |
34 | 33 |
35 class OperationObserver; | 34 class OperationObserver; |
36 | 35 |
37 class TouchOperation { | 36 class TouchOperation { |
38 public: | 37 public: |
39 TouchOperation(base::SequencedTaskRunner* blocking_task_runner, | 38 TouchOperation(base::SequencedTaskRunner* blocking_task_runner, |
40 OperationObserver* observer, | 39 OperationObserver* observer, |
41 JobScheduler* scheduler, | |
42 internal::ResourceMetadata* metadata); | 40 internal::ResourceMetadata* metadata); |
43 ~TouchOperation(); | 41 ~TouchOperation(); |
44 | 42 |
45 // Touches the file by updating last access time and last modified time. | 43 // Touches the file by updating last access time and last modified time. |
46 // Upon completion, invokes |callback|. | 44 // Upon completion, invokes |callback|. |
47 // |last_access_time|, |last_modified_time| and |callback| must not be null. | 45 // |last_access_time|, |last_modified_time| and |callback| must not be null. |
48 void TouchFile(const base::FilePath& file_path, | 46 void TouchFile(const base::FilePath& file_path, |
49 const base::Time& last_access_time, | 47 const base::Time& last_access_time, |
50 const base::Time& last_modified_time, | 48 const base::Time& last_modified_time, |
51 const FileOperationCallback& callback); | 49 const FileOperationCallback& callback); |
52 | 50 |
53 private: | 51 private: |
54 // Part of TouchFile(). Runs after GetResourceEntry is completed. | 52 // Part of TouchFile(). Runs after updating the local state. |
55 void TouchFileAfterGetResourceEntry(const base::Time& last_access_time, | 53 void TouchFileAfterUpdateLocalState(const base::FilePath& file_path, |
56 const base::Time& last_modified_time, | |
57 const FileOperationCallback& callback, | 54 const FileOperationCallback& callback, |
58 ResourceEntry* entry, | 55 const std::string* local_id, |
59 FileError error); | 56 FileError error); |
60 | 57 |
61 // Part of TouchFile(). Runs after the server side update for last access time | |
62 // and last modified time is completed. | |
63 void TouchFileAfterServerTimeStampUpdated( | |
64 const std::string& local_id, | |
65 const FileOperationCallback& callback, | |
66 google_apis::GDataErrorCode gdata_error, | |
67 scoped_ptr<google_apis::ResourceEntry> resource_entry); | |
68 | |
69 // Part of TouchFile(). Runs after refreshing the local metadata is completed. | |
70 void TouchFileAfterRefreshMetadata(const base::FilePath* file_path, | |
71 const FileOperationCallback& callback, | |
72 FileError error); | |
73 | |
74 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 58 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
75 OperationObserver* observer_; | 59 OperationObserver* observer_; |
76 JobScheduler* scheduler_; | |
77 internal::ResourceMetadata* metadata_; | 60 internal::ResourceMetadata* metadata_; |
78 | 61 |
79 // Note: This should remain the last member so it'll be destroyed and | 62 // Note: This should remain the last member so it'll be destroyed and |
80 // invalidate the weak pointers before any other members are destroyed. | 63 // invalidate the weak pointers before any other members are destroyed. |
81 base::WeakPtrFactory<TouchOperation> weak_ptr_factory_; | 64 base::WeakPtrFactory<TouchOperation> weak_ptr_factory_; |
82 DISALLOW_COPY_AND_ASSIGN(TouchOperation); | 65 DISALLOW_COPY_AND_ASSIGN(TouchOperation); |
83 }; | 66 }; |
84 | 67 |
85 } // namespace file_system | 68 } // namespace file_system |
86 } // namespace drive | 69 } // namespace drive |
87 | 70 |
88 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_ | 71 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_TOUCH_OPERATION_H_ |
OLD | NEW |