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/resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 FileError ResourceMetadata::ReadDirectoryByPath( | 277 FileError ResourceMetadata::ReadDirectoryByPath( |
278 const base::FilePath& path, | 278 const base::FilePath& path, |
279 ResourceEntryVector* out_entries) { | 279 ResourceEntryVector* out_entries) { |
280 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); | 280 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
281 DCHECK(out_entries); | 281 DCHECK(out_entries); |
282 | 282 |
283 std::string id; | 283 std::string id; |
284 FileError error = GetIdByPath(path, &id); | 284 FileError error = GetIdByPath(path, &id); |
285 if (error != FILE_ERROR_OK) | 285 if (error != FILE_ERROR_OK) |
286 return error; | 286 return error; |
| 287 return ReadDirectoryById(id, out_entries); |
| 288 } |
| 289 |
| 290 FileError ResourceMetadata::ReadDirectoryById( |
| 291 const std::string& id, |
| 292 ResourceEntryVector* out_entries) { |
| 293 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); |
| 294 DCHECK(out_entries); |
287 | 295 |
288 ResourceEntry entry; | 296 ResourceEntry entry; |
289 error = GetResourceEntryById(id, &entry); | 297 FileError error = GetResourceEntryById(id, &entry); |
290 if (error != FILE_ERROR_OK) | 298 if (error != FILE_ERROR_OK) |
291 return error; | 299 return error; |
292 | 300 |
293 if (!entry.file_info().is_directory()) | 301 if (!entry.file_info().is_directory()) |
294 return FILE_ERROR_NOT_A_DIRECTORY; | 302 return FILE_ERROR_NOT_A_DIRECTORY; |
295 | 303 |
296 std::vector<std::string> children; | 304 std::vector<std::string> children; |
297 storage_->GetChildren(id, &children); | 305 storage_->GetChildren(id, &children); |
298 | 306 |
299 ResourceEntryVector entries(children.size()); | 307 ResourceEntryVector entries(children.size()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 for (size_t i = 0; i < children.size(); ++i) { | 465 for (size_t i = 0; i < children.size(); ++i) { |
458 if (!RemoveEntryRecursively(children[i])) | 466 if (!RemoveEntryRecursively(children[i])) |
459 return false; | 467 return false; |
460 } | 468 } |
461 } | 469 } |
462 return storage_->RemoveEntry(id); | 470 return storage_->RemoveEntry(id); |
463 } | 471 } |
464 | 472 |
465 } // namespace internal | 473 } // namespace internal |
466 } // namespace drive | 474 } // namespace drive |
OLD | NEW |