| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/fileapi/fileapi_worker.h" | 5 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "chrome/browser/chromeos/drive/drive.pb.h" | 11 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 12 #include "chrome/browser/chromeos/drive/file_errors.h" | 12 #include "chrome/browser/chromeos/drive/file_errors.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 13 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system_util.h" | 14 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 15 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 15 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "webkit/browser/fileapi/file_system_url.h" |
| 17 #include "webkit/common/fileapi/directory_entry.h" | 18 #include "webkit/common/fileapi/directory_entry.h" |
| 18 | 19 |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 20 | 21 |
| 21 namespace drive { | 22 namespace drive { |
| 22 namespace fileapi_internal { | 23 namespace fileapi_internal { |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // The summary of opening mode is: | 26 // The summary of opening mode is: |
| 26 // - PLATFORM_FILE_OPEN: Open the existing file. Fail if not exists. | 27 // - PLATFORM_FILE_OPEN: Open the existing file. Fail if not exists. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 base::Bind(&base::CreatePlatformFile, | 191 base::Bind(&base::CreatePlatformFile, |
| 191 local_path, file_flags, static_cast<bool*>(NULL), | 192 local_path, file_flags, static_cast<bool*>(NULL), |
| 192 reinterpret_cast<base::PlatformFileError*>(result)), | 193 reinterpret_cast<base::PlatformFileError*>(result)), |
| 193 base::Bind(&RunOpenFileCallback, | 194 base::Bind(&RunOpenFileCallback, |
| 194 callback, close_callback, base::Owned(result))); | 195 callback, close_callback, base::Owned(result))); |
| 195 DCHECK(posted); | 196 DCHECK(posted); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace | 199 } // namespace |
| 199 | 200 |
| 201 FileSystemInterface* GetFileSystemFromUrl(const fileapi::FileSystemURL& url) { |
| 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 203 |
| 204 Profile* profile = util::ExtractProfileFromPath(url.path()); |
| 205 return profile ? util::GetFileSystemByProfile(profile) : NULL; |
| 206 } |
| 207 |
| 200 void RunFileSystemCallback( | 208 void RunFileSystemCallback( |
| 201 const FileSystemGetter& file_system_getter, | 209 const FileSystemGetter& file_system_getter, |
| 202 const base::Callback<void(FileSystemInterface*)>& callback, | 210 const base::Callback<void(FileSystemInterface*)>& callback, |
| 203 const base::Closure& on_error_callback) { | 211 const base::Closure& on_error_callback) { |
| 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 205 FileSystemInterface* file_system = file_system_getter.Run(); | 213 FileSystemInterface* file_system = file_system_getter.Run(); |
| 206 | 214 |
| 207 if (!file_system) { | 215 if (!file_system) { |
| 208 if (!on_error_callback.is_null()) | 216 if (!on_error_callback.is_null()) |
| 209 on_error_callback.Run(); | 217 on_error_callback.Run(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 const StatusCallback& callback, | 365 const StatusCallback& callback, |
| 358 FileSystemInterface* file_system) { | 366 FileSystemInterface* file_system) { |
| 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 360 file_system->TouchFile(file_path, last_access_time, last_modified_time, | 368 file_system->TouchFile(file_path, last_access_time, last_modified_time, |
| 361 base::Bind(&RunStatusCallbackByFileError, callback)); | 369 base::Bind(&RunStatusCallbackByFileError, callback)); |
| 362 | 370 |
| 363 } | 371 } |
| 364 | 372 |
| 365 } // namespace fileapi_internal | 373 } // namespace fileapi_internal |
| 366 } // namespace drive | 374 } // namespace drive |
| OLD | NEW |