| 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/gdata/gdata_file_system_proxy.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 base::PLATFORM_FILE_ERROR_NOT_FOUND, | 151 base::PLATFORM_FILE_ERROR_NOT_FOUND, |
| 152 std::vector<base::FileUtilProxy::Entry>(), | 152 std::vector<base::FileUtilProxy::Entry>(), |
| 153 false)); | 153 false)); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 | 156 |
| 157 file_system_->FindFileByPathAsync( | 157 file_system_->FindFileByPathAsync( |
| 158 file_path, | 158 file_path, |
| 159 base::Bind(&GDataFileSystemProxy::OnReadDirectory, | 159 base::Bind(&GDataFileSystemProxy::OnReadDirectory, |
| 160 this, | 160 this, |
| 161 file_system_->hide_hosted_documents(), |
| 161 proxy, | 162 proxy, |
| 162 callback)); | 163 callback)); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void GDataFileSystemProxy::Remove(const GURL& file_url, bool recursive, | 166 void GDataFileSystemProxy::Remove(const GURL& file_url, bool recursive, |
| 166 const FileSystemOperationInterface::StatusCallback& callback) { | 167 const FileSystemOperationInterface::StatusCallback& callback) { |
| 167 FilePath file_path; | 168 FilePath file_path; |
| 168 if (!ValidateUrl(file_url, &file_path)) { | 169 if (!ValidateUrl(file_url, &file_path)) { |
| 169 MessageLoopProxy::current()->PostTask(FROM_HERE, | 170 MessageLoopProxy::current()->PostTask(FROM_HERE, |
| 170 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); | 171 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 242 } |
| 242 | 243 |
| 243 proxy->PostTask(FROM_HERE, | 244 proxy->PostTask(FROM_HERE, |
| 244 base::Bind(callback, | 245 base::Bind(callback, |
| 245 base::PLATFORM_FILE_OK, | 246 base::PLATFORM_FILE_OK, |
| 246 file->file_info(), | 247 file->file_info(), |
| 247 file_path)); | 248 file_path)); |
| 248 } | 249 } |
| 249 | 250 |
| 250 void GDataFileSystemProxy::OnReadDirectory( | 251 void GDataFileSystemProxy::OnReadDirectory( |
| 252 bool hide_hosted_documents, |
| 251 scoped_refptr<base::MessageLoopProxy> proxy, | 253 scoped_refptr<base::MessageLoopProxy> proxy, |
| 252 const FileSystemOperationInterface::ReadDirectoryCallback& callback, | 254 const FileSystemOperationInterface::ReadDirectoryCallback& callback, |
| 253 base::PlatformFileError error, | 255 base::PlatformFileError error, |
| 254 const FilePath& directory_path, | 256 const FilePath& directory_path, |
| 255 GDataFileBase* file) { | 257 GDataFileBase* file) { |
| 256 DCHECK(file); | 258 DCHECK(file); |
| 257 GDataDirectory* directory = file->AsGDataDirectory(); | 259 GDataDirectory* directory = file->AsGDataDirectory(); |
| 258 if (!directory) | 260 if (!directory) |
| 259 error = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 261 error = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; |
| 260 | 262 |
| 261 if (error != base::PLATFORM_FILE_OK) { | 263 if (error != base::PLATFORM_FILE_OK) { |
| 262 proxy->PostTask(FROM_HERE, | 264 proxy->PostTask(FROM_HERE, |
| 263 base::Bind(callback, | 265 base::Bind(callback, |
| 264 error, | 266 error, |
| 265 std::vector<base::FileUtilProxy::Entry>(), | 267 std::vector<base::FileUtilProxy::Entry>(), |
| 266 false)); | 268 false)); |
| 267 return; | 269 return; |
| 268 } | 270 } |
| 269 std::vector<base::FileUtilProxy::Entry> entries; | 271 std::vector<base::FileUtilProxy::Entry> entries; |
| 270 // Convert gdata files to something File API stack can understand. | 272 // Convert gdata files to something File API stack can understand. |
| 271 for (GDataFileCollection::const_iterator iter = | 273 for (GDataFileCollection::const_iterator iter = |
| 272 directory->children().begin(); | 274 directory->children().begin(); |
| 273 iter != directory->children().end(); ++iter) { | 275 iter != directory->children().end(); ++iter) { |
| 276 if (hide_hosted_documents) { |
| 277 GDataFile* file = iter->second->AsGDataFile(); |
| 278 if (file && file->is_hosted_document()) |
| 279 continue; |
| 280 } |
| 281 |
| 274 entries.push_back(GDataFileToFileUtilProxyEntry(*(iter->second))); | 282 entries.push_back(GDataFileToFileUtilProxyEntry(*(iter->second))); |
| 275 } | 283 } |
| 276 | 284 |
| 277 proxy->PostTask(FROM_HERE, | 285 proxy->PostTask(FROM_HERE, |
| 278 base::Bind(callback, | 286 base::Bind(callback, |
| 279 base::PLATFORM_FILE_OK, | 287 base::PLATFORM_FILE_OK, |
| 280 entries, | 288 entries, |
| 281 false)); | 289 false)); |
| 282 } | 290 } |
| 283 | 291 |
| 284 } // namespace gdata | 292 } // namespace gdata |
| OLD | NEW |