OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" | 5 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/drive.pb.h" | 7 #include "chrome/browser/chromeos/drive/drive.pb.h" |
8 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 8 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
10 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 10 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 void CreateDirectoryOperation::CreateDirectory( | 64 void CreateDirectoryOperation::CreateDirectory( |
65 const base::FilePath& directory_path, | 65 const base::FilePath& directory_path, |
66 bool is_exclusive, | 66 bool is_exclusive, |
67 bool is_recursive, | 67 bool is_recursive, |
68 const FileOperationCallback& callback) { | 68 const FileOperationCallback& callback) { |
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
70 DCHECK(!callback.is_null()); | 70 DCHECK(!callback.is_null()); |
71 | 71 |
72 ResourceEntry* entry = new ResourceEntry; | 72 ResourceEntry* entry = new ResourceEntry; |
73 base::PostTaskAndReplyWithResult( | 73 base::PostTaskAndReplyWithResult( |
74 blocking_task_runner_, | 74 blocking_task_runner_.get(), |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&CreateDirectoryOperation::GetExistingDeepestDirectory, | 76 base::Bind(&CreateDirectoryOperation::GetExistingDeepestDirectory, |
77 metadata_, directory_path, entry), | 77 metadata_, |
78 base::Bind(&CreateDirectoryOperation | 78 directory_path, |
79 ::CreateDirectoryAfterGetExistingDeepestDirectory, | 79 entry), |
| 80 base::Bind(&CreateDirectoryOperation:: |
| 81 CreateDirectoryAfterGetExistingDeepestDirectory, |
80 weak_ptr_factory_.GetWeakPtr(), | 82 weak_ptr_factory_.GetWeakPtr(), |
81 directory_path, is_exclusive, is_recursive, | 83 directory_path, |
82 callback, base::Owned(entry))); | 84 is_exclusive, |
| 85 is_recursive, |
| 86 callback, |
| 87 base::Owned(entry))); |
83 } | 88 } |
84 | 89 |
85 // static | 90 // static |
86 base::FilePath CreateDirectoryOperation::GetExistingDeepestDirectory( | 91 base::FilePath CreateDirectoryOperation::GetExistingDeepestDirectory( |
87 internal::ResourceMetadata* metadata, | 92 internal::ResourceMetadata* metadata, |
88 const base::FilePath& directory_path, | 93 const base::FilePath& directory_path, |
89 ResourceEntry* entry) { | 94 ResourceEntry* entry) { |
90 DCHECK(metadata); | 95 DCHECK(metadata); |
91 DCHECK(entry); | 96 DCHECK(entry); |
92 | 97 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return; | 195 return; |
191 } | 196 } |
192 DCHECK(resource_entry); | 197 DCHECK(resource_entry); |
193 | 198 |
194 // Note that the created directory may be renamed inside | 199 // Note that the created directory may be renamed inside |
195 // ResourceMetadata::AddEntry due to name confliction. | 200 // ResourceMetadata::AddEntry due to name confliction. |
196 // What we actually need here is the new created path (not the path we try | 201 // What we actually need here is the new created path (not the path we try |
197 // to create). | 202 // to create). |
198 base::FilePath* file_path = new base::FilePath; | 203 base::FilePath* file_path = new base::FilePath; |
199 base::PostTaskAndReplyWithResult( | 204 base::PostTaskAndReplyWithResult( |
200 blocking_task_runner_, | 205 blocking_task_runner_.get(), |
201 FROM_HERE, | 206 FROM_HERE, |
202 base::Bind(&UpdateLocalStateForCreateDirectoryRecursively, | 207 base::Bind(&UpdateLocalStateForCreateDirectoryRecursively, |
203 metadata_, ConvertToResourceEntry(*resource_entry), file_path), | 208 metadata_, |
204 base::Bind(&CreateDirectoryOperation | 209 ConvertToResourceEntry(*resource_entry), |
205 ::CreateDirectoryRecursivelyAfterUpdateLocalState, | 210 file_path), |
| 211 base::Bind(&CreateDirectoryOperation:: |
| 212 CreateDirectoryRecursivelyAfterUpdateLocalState, |
206 weak_ptr_factory_.GetWeakPtr(), | 213 weak_ptr_factory_.GetWeakPtr(), |
207 resource_entry->resource_id(), | 214 resource_entry->resource_id(), |
208 remaining_path, callback, base::Owned(file_path))); | 215 remaining_path, |
| 216 callback, |
| 217 base::Owned(file_path))); |
209 } | 218 } |
210 | 219 |
211 void CreateDirectoryOperation::CreateDirectoryRecursivelyAfterUpdateLocalState( | 220 void CreateDirectoryOperation::CreateDirectoryRecursivelyAfterUpdateLocalState( |
212 const std::string& resource_id, | 221 const std::string& resource_id, |
213 const base::FilePath& remaining_path, | 222 const base::FilePath& remaining_path, |
214 const FileOperationCallback& callback, | 223 const FileOperationCallback& callback, |
215 base::FilePath* file_path, | 224 base::FilePath* file_path, |
216 FileError error) { | 225 FileError error) { |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
218 DCHECK(!callback.is_null()); | 227 DCHECK(!callback.is_null()); |
(...skipping 10 matching lines...) Expand all Loading... |
229 callback.Run(FILE_ERROR_OK); | 238 callback.Run(FILE_ERROR_OK); |
230 return; | 239 return; |
231 } | 240 } |
232 | 241 |
233 // Create descendent directories. | 242 // Create descendent directories. |
234 CreateDirectoryRecursively(resource_id, remaining_path, callback); | 243 CreateDirectoryRecursively(resource_id, remaining_path, callback); |
235 } | 244 } |
236 | 245 |
237 } // namespace file_system | 246 } // namespace file_system |
238 } // namespace drive | 247 } // namespace drive |
OLD | NEW |