| 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/file_manager/snapshot_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "chrome/browser/chromeos/file_manager/app_id.h" | 9 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 callback); | 54 callback); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Part of ComputeSpaceNeedToBeFreed. | 57 // Part of ComputeSpaceNeedToBeFreed. |
| 58 void GetMetadataOnIOThread(const base::FilePath& path, | 58 void GetMetadataOnIOThread(const base::FilePath& path, |
| 59 scoped_refptr<storage::FileSystemContext> context, | 59 scoped_refptr<storage::FileSystemContext> context, |
| 60 const storage::FileSystemURL& url, | 60 const storage::FileSystemURL& url, |
| 61 const GetNecessaryFreeSpaceCallback& callback) { | 61 const GetNecessaryFreeSpaceCallback& callback) { |
| 62 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 62 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 63 context->operation_runner()->GetMetadata( | 63 context->operation_runner()->GetMetadata( |
| 64 url, | 64 url, storage::FileSystemOperation::GET_METADATA_FIELD_SIZE, |
| 65 base::Bind(&ComputeSpaceNeedToBeFreedAfterGetMetadata, path, callback)); | 65 base::Bind(&ComputeSpaceNeedToBeFreedAfterGetMetadata, path, callback)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Computes the size of space that need to be __additionally__ made available | 68 // Computes the size of space that need to be __additionally__ made available |
| 69 // in the |profile|'s data directory for taking the snapshot of |url|. | 69 // in the |profile|'s data directory for taking the snapshot of |url|. |
| 70 // Returns 0 if no additional space is required, or -1 in the case of an error. | 70 // Returns 0 if no additional space is required, or -1 in the case of an error. |
| 71 void ComputeSpaceNeedToBeFreed( | 71 void ComputeSpaceNeedToBeFreed( |
| 72 Profile* profile, | 72 Profile* profile, |
| 73 scoped_refptr<storage::FileSystemContext> context, | 73 scoped_refptr<storage::FileSystemContext> context, |
| 74 const storage::FileSystemURL& url, | 74 const storage::FileSystemURL& url, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (result != base::File::FILE_OK) { | 203 if (result != base::File::FILE_OK) { |
| 204 callback.Run(base::FilePath()); | 204 callback.Run(base::FilePath()); |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 | 207 |
| 208 file_refs_.push_back(FileReferenceWithSizeInfo(file_ref, file_info.size)); | 208 file_refs_.push_back(FileReferenceWithSizeInfo(file_ref, file_info.size)); |
| 209 callback.Run(platform_path); | 209 callback.Run(platform_path); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace file_manager | 212 } // namespace file_manager |
| OLD | NEW |