Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: chrome/browser/chromeos/drive/resource_metadata.cc

Issue 16107004: drive: Stop returning FilePath from GetResourceEntryById (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!RemoveEntryRecursively(entry->resource_id())) 383 if (!RemoveEntryRecursively(entry->resource_id()))
384 return FILE_ERROR_FAILED; 384 return FILE_ERROR_FAILED;
385 385
386 if (out_file_path) 386 if (out_file_path)
387 *out_file_path = GetFilePath(entry->parent_resource_id()); 387 *out_file_path = GetFilePath(entry->parent_resource_id());
388 return FILE_ERROR_OK; 388 return FILE_ERROR_OK;
389 } 389 }
390 390
391 void ResourceMetadata::GetResourceEntryByIdOnUIThread( 391 void ResourceMetadata::GetResourceEntryByIdOnUIThread(
392 const std::string& resource_id, 392 const std::string& resource_id,
393 const GetResourceEntryWithFilePathCallback& callback) { 393 const GetResourceEntryCallback& callback) {
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
395 DCHECK(!callback.is_null()); 395 DCHECK(!callback.is_null());
396 396
397 base::FilePath* file_path = new base::FilePath;
398 scoped_ptr<ResourceEntry> entry(new ResourceEntry); 397 scoped_ptr<ResourceEntry> entry(new ResourceEntry);
399 ResourceEntry* entry_ptr = entry.get(); 398 ResourceEntry* entry_ptr = entry.get();
400 base::PostTaskAndReplyWithResult( 399 base::PostTaskAndReplyWithResult(
401 blocking_task_runner_, 400 blocking_task_runner_,
402 FROM_HERE, 401 FROM_HERE,
403 base::Bind(&ResourceMetadata::GetResourceEntryById, 402 base::Bind(&ResourceMetadata::GetResourceEntryById,
404 base::Unretained(this), 403 base::Unretained(this),
405 resource_id, 404 resource_id,
406 file_path,
407 entry_ptr), 405 entry_ptr),
408 base::Bind(&RunGetResourceEntryWithFilePathCallback, 406 base::Bind(&RunGetResourceEntryCallback,
409 callback, 407 callback,
410 base::Owned(file_path),
411 base::Passed(&entry))); 408 base::Passed(&entry)));
412 } 409 }
413 410
414 FileError ResourceMetadata::GetResourceEntryById( 411 FileError ResourceMetadata::GetResourceEntryById(
415 const std::string& resource_id, 412 const std::string& resource_id,
416 base::FilePath* out_file_path,
417 ResourceEntry* out_entry) { 413 ResourceEntry* out_entry) {
418 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); 414 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
419 DCHECK(!resource_id.empty()); 415 DCHECK(!resource_id.empty());
416 DCHECK(out_entry);
420 417
421 scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id); 418 scoped_ptr<ResourceEntry> entry = storage_->GetEntry(resource_id);
422 if (!entry) 419 if (!entry)
423 return FILE_ERROR_NOT_FOUND; 420 return FILE_ERROR_NOT_FOUND;
424 421
425 if (out_file_path) 422 out_entry->Swap(entry.get());
426 *out_file_path = GetFilePath(resource_id);
427 if (out_entry)
428 *out_entry = *entry;
429
430 return FILE_ERROR_OK; 423 return FILE_ERROR_OK;
431 } 424 }
432 425
433 void ResourceMetadata::GetResourceEntryByPathOnUIThread( 426 void ResourceMetadata::GetResourceEntryByPathOnUIThread(
434 const base::FilePath& file_path, 427 const base::FilePath& file_path,
435 const GetResourceEntryCallback& callback) { 428 const GetResourceEntryCallback& callback) {
436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
437 DCHECK(!callback.is_null()); 430 DCHECK(!callback.is_null());
438 431
439 scoped_ptr<ResourceEntry> entry(new ResourceEntry); 432 scoped_ptr<ResourceEntry> entry(new ResourceEntry);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 for (size_t i = 0; i < children.size(); ++i) { 925 for (size_t i = 0; i < children.size(); ++i) {
933 if (!RemoveEntryRecursively(children[i])) 926 if (!RemoveEntryRecursively(children[i]))
934 return false; 927 return false;
935 } 928 }
936 } 929 }
937 return storage_->RemoveEntry(resource_id); 930 return storage_->RemoveEntry(resource_id);
938 } 931 }
939 932
940 } // namespace internal 933 } // namespace internal
941 } // namespace drive 934 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/resource_metadata.h ('k') | chrome/browser/chromeos/drive/resource_metadata_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698