OLD | NEW |
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 #include "chrome/browser/chromeos/drive/file_system/drive_operations.h" | 5 #include "chrome/browser/chromeos/drive/file_system/operations.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" | 8 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" |
9 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" | 9 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" |
10 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" | 10 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" |
11 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" | 11 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" |
12 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" | 12 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
13 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" | 13 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" |
14 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" | 14 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" |
15 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" | 15 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 | 17 |
18 using content::BrowserThread; | 18 using content::BrowserThread; |
19 | 19 |
20 namespace drive { | 20 namespace drive { |
21 namespace file_system { | 21 namespace file_system { |
22 | 22 |
23 DriveOperations::DriveOperations() { | 23 Operations::Operations() { |
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
25 } | 25 } |
26 | 26 |
27 DriveOperations::~DriveOperations() { | 27 Operations::~Operations() { |
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
29 } | 29 } |
30 | 30 |
31 void DriveOperations::Init(OperationObserver* observer, | 31 void Operations::Init(OperationObserver* observer, |
32 JobScheduler* scheduler, | 32 JobScheduler* scheduler, |
33 internal::ResourceMetadata* metadata, | 33 internal::ResourceMetadata* metadata, |
34 internal::FileCache* cache, | 34 internal::FileCache* cache, |
35 FileSystemInterface* file_system, | 35 FileSystemInterface* file_system, |
36 google_apis::DriveServiceInterface* drive_service, | 36 google_apis::DriveServiceInterface* drive_service, |
37 base::SequencedTaskRunner* blocking_task_runner) { | 37 base::SequencedTaskRunner* blocking_task_runner) { |
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
39 | 39 |
40 copy_operation_.reset(new file_system::CopyOperation(blocking_task_runner, | 40 copy_operation_.reset(new file_system::CopyOperation(blocking_task_runner, |
41 observer, | 41 observer, |
42 scheduler, | 42 scheduler, |
43 metadata, | 43 metadata, |
44 cache, | 44 cache, |
45 file_system, | 45 file_system, |
46 drive_service)); | 46 drive_service)); |
47 create_directory_operation_.reset(new CreateDirectoryOperation( | 47 create_directory_operation_.reset(new CreateDirectoryOperation( |
(...skipping 11 matching lines...) Expand all Loading... |
59 remove_operation_.reset( | 59 remove_operation_.reset( |
60 new RemoveOperation(observer, scheduler, metadata, cache)); | 60 new RemoveOperation(observer, scheduler, metadata, cache)); |
61 touch_operation_.reset( | 61 touch_operation_.reset( |
62 new TouchOperation(blocking_task_runner, observer, scheduler, metadata)); | 62 new TouchOperation(blocking_task_runner, observer, scheduler, metadata)); |
63 update_operation_.reset( | 63 update_operation_.reset( |
64 new UpdateOperation(observer, scheduler, metadata, cache)); | 64 new UpdateOperation(observer, scheduler, metadata, cache)); |
65 search_operation_.reset( | 65 search_operation_.reset( |
66 new SearchOperation(blocking_task_runner, scheduler, metadata)); | 66 new SearchOperation(blocking_task_runner, scheduler, metadata)); |
67 } | 67 } |
68 | 68 |
69 void DriveOperations::Copy(const base::FilePath& src_file_path, | 69 void Operations::Copy(const base::FilePath& src_file_path, |
70 const base::FilePath& dest_file_path, | 70 const base::FilePath& dest_file_path, |
71 const FileOperationCallback& callback) { | 71 const FileOperationCallback& callback) { |
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
73 DCHECK(!callback.is_null()); | 73 DCHECK(!callback.is_null()); |
74 | 74 |
75 copy_operation_->Copy(src_file_path, dest_file_path, callback); | 75 copy_operation_->Copy(src_file_path, dest_file_path, callback); |
76 } | 76 } |
77 | 77 |
78 void DriveOperations::TransferFileFromRemoteToLocal( | 78 void Operations::TransferFileFromRemoteToLocal( |
79 const base::FilePath& remote_src_file_path, | 79 const base::FilePath& remote_src_file_path, |
80 const base::FilePath& local_dest_file_path, | 80 const base::FilePath& local_dest_file_path, |
81 const FileOperationCallback& callback) { | 81 const FileOperationCallback& callback) { |
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
83 DCHECK(!callback.is_null()); | 83 DCHECK(!callback.is_null()); |
84 | 84 |
85 copy_operation_->TransferFileFromRemoteToLocal(remote_src_file_path, | 85 copy_operation_->TransferFileFromRemoteToLocal(remote_src_file_path, |
86 local_dest_file_path, | 86 local_dest_file_path, |
87 callback); | 87 callback); |
88 } | 88 } |
89 | 89 |
90 void DriveOperations::TransferFileFromLocalToRemote( | 90 void Operations::TransferFileFromLocalToRemote( |
91 const base::FilePath& local_src_file_path, | 91 const base::FilePath& local_src_file_path, |
92 const base::FilePath& remote_dest_file_path, | 92 const base::FilePath& remote_dest_file_path, |
93 const FileOperationCallback& callback) { | 93 const FileOperationCallback& callback) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
95 DCHECK(!callback.is_null()); | 95 DCHECK(!callback.is_null()); |
96 | 96 |
97 copy_operation_->TransferFileFromLocalToRemote(local_src_file_path, | 97 copy_operation_->TransferFileFromLocalToRemote(local_src_file_path, |
98 remote_dest_file_path, | 98 remote_dest_file_path, |
99 callback); | 99 callback); |
100 } | 100 } |
101 | 101 |
102 void DriveOperations::CreateDirectory(const base::FilePath& directory_path, | 102 void Operations::CreateDirectory(const base::FilePath& directory_path, |
103 bool is_exclusive, | 103 bool is_exclusive, |
104 bool is_recursive, | 104 bool is_recursive, |
105 const FileOperationCallback& callback) { | 105 const FileOperationCallback& callback) { |
106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
107 DCHECK(!callback.is_null()); | 107 DCHECK(!callback.is_null()); |
108 | 108 |
109 create_directory_operation_->CreateDirectory( | 109 create_directory_operation_->CreateDirectory( |
110 directory_path, is_exclusive, is_recursive, callback); | 110 directory_path, is_exclusive, is_recursive, callback); |
111 } | 111 } |
112 | 112 |
113 void DriveOperations::CreateFile(const base::FilePath& remote_file_path, | 113 void Operations::CreateFile(const base::FilePath& remote_file_path, |
114 bool is_exclusive, | 114 bool is_exclusive, |
115 const FileOperationCallback& callback) { | 115 const FileOperationCallback& callback) { |
116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
117 DCHECK(!callback.is_null()); | 117 DCHECK(!callback.is_null()); |
118 | 118 |
119 create_file_operation_->CreateFile(remote_file_path, is_exclusive, callback); | 119 create_file_operation_->CreateFile(remote_file_path, is_exclusive, callback); |
120 } | 120 } |
121 | 121 |
122 void DriveOperations::Move(const base::FilePath& src_file_path, | 122 void Operations::Move(const base::FilePath& src_file_path, |
123 const base::FilePath& dest_file_path, | 123 const base::FilePath& dest_file_path, |
124 const FileOperationCallback& callback) { | 124 const FileOperationCallback& callback) { |
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
126 DCHECK(!callback.is_null()); | 126 DCHECK(!callback.is_null()); |
127 | 127 |
128 move_operation_->Move(src_file_path, dest_file_path, callback); | 128 move_operation_->Move(src_file_path, dest_file_path, callback); |
129 } | 129 } |
130 | 130 |
131 void DriveOperations::Remove(const base::FilePath& file_path, | 131 void Operations::Remove(const base::FilePath& file_path, |
132 bool is_recursive, | 132 bool is_recursive, |
133 const FileOperationCallback& callback) { | 133 const FileOperationCallback& callback) { |
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
135 DCHECK(!callback.is_null()); | 135 DCHECK(!callback.is_null()); |
136 | 136 |
137 remove_operation_->Remove(file_path, is_recursive, callback); | 137 remove_operation_->Remove(file_path, is_recursive, callback); |
138 } | 138 } |
139 | 139 |
140 void DriveOperations::TouchFile(const base::FilePath& file_path, | 140 void Operations::TouchFile(const base::FilePath& file_path, |
141 const base::Time& last_access_time, | 141 const base::Time& last_access_time, |
142 const base::Time& last_modified_time, | 142 const base::Time& last_modified_time, |
143 const FileOperationCallback& callback) { | 143 const FileOperationCallback& callback) { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 DCHECK(!last_access_time.is_null()); | 145 DCHECK(!last_access_time.is_null()); |
146 DCHECK(!last_modified_time.is_null()); | 146 DCHECK(!last_modified_time.is_null()); |
147 DCHECK(!callback.is_null()); | 147 DCHECK(!callback.is_null()); |
148 | 148 |
149 touch_operation_->TouchFile( | 149 touch_operation_->TouchFile( |
150 file_path, last_access_time, last_modified_time, callback); | 150 file_path, last_access_time, last_modified_time, callback); |
151 } | 151 } |
152 | 152 |
153 void DriveOperations::UpdateFileByResourceId( | 153 void Operations::UpdateFileByResourceId( |
154 const std::string& resource_id, | 154 const std::string& resource_id, |
155 DriveClientContext context, | 155 DriveClientContext context, |
156 const FileOperationCallback& callback) { | 156 const FileOperationCallback& callback) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
158 DCHECK(!callback.is_null()); | 158 DCHECK(!callback.is_null()); |
159 | 159 |
160 update_operation_->UpdateFileByResourceId(resource_id, context, callback); | 160 update_operation_->UpdateFileByResourceId(resource_id, context, callback); |
161 } | 161 } |
162 | 162 |
163 void DriveOperations::Search(const std::string& search_query, | 163 void Operations::Search(const std::string& search_query, |
164 const GURL& next_feed, | 164 const GURL& next_feed, |
165 const SearchOperationCallback& callback) { | 165 const SearchOperationCallback& callback) { |
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
167 DCHECK(!callback.is_null()); | 167 DCHECK(!callback.is_null()); |
168 | 168 |
169 search_operation_->Search(search_query, next_feed, callback); | 169 search_operation_->Search(search_query, next_feed, callback); |
170 } | 170 } |
171 | 171 |
172 } // namespace file_system | 172 } // namespace file_system |
173 } // namespace drive | 173 } // namespace drive |
OLD | NEW |