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

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

Issue 23571005: drive: Remove unused functions from ResourceMetadata. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void RunReadDirectoryCallback(const ReadDirectoryCallback& callback, 50 void RunReadDirectoryCallback(const ReadDirectoryCallback& callback,
51 scoped_ptr<ResourceEntryVector> entries, 51 scoped_ptr<ResourceEntryVector> entries,
52 FileError error) { 52 FileError error) {
53 DCHECK(!callback.is_null()); 53 DCHECK(!callback.is_null());
54 54
55 if (error != FILE_ERROR_OK) 55 if (error != FILE_ERROR_OK)
56 entries.reset(); 56 entries.reset();
57 callback.Run(error, entries.Pass()); 57 callback.Run(error, entries.Pass());
58 } 58 }
59 59
60 // Runs |callback| with arguments.
61 void RunFileMoveCallback(const FileMoveCallback& callback,
62 base::FilePath* path,
63 FileError error) {
64 DCHECK(!callback.is_null());
65 DCHECK(path);
66
67 callback.Run(error, *path);
68 }
69
70 // Helper function to run tasks with FileMoveCallback.
71 void PostFileMoveTask(
72 base::TaskRunner* task_runner,
73 const base::Callback<FileError(base::FilePath* out_file_path)>& task,
74 const FileMoveCallback& callback) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
76 DCHECK(!task.is_null());
77 DCHECK(!callback.is_null());
78
79 base::FilePath* file_path = new base::FilePath;
80
81 base::PostTaskAndReplyWithResult(
82 task_runner,
83 FROM_HERE,
84 base::Bind(task, file_path),
85 base::Bind(&RunFileMoveCallback, callback, base::Owned(file_path)));
86 }
87
88 } // namespace 60 } // namespace
89 61
90 EntryInfoResult::EntryInfoResult() : error(FILE_ERROR_FAILED) {
91 }
92
93 EntryInfoResult::~EntryInfoResult() {
94 }
95
96 EntryInfoPairResult::EntryInfoPairResult() {
97 }
98
99 EntryInfoPairResult::~EntryInfoPairResult() {
100 }
101
102 namespace internal { 62 namespace internal {
103 63
104 ResourceMetadata::ResourceMetadata( 64 ResourceMetadata::ResourceMetadata(
105 ResourceMetadataStorage* storage, 65 ResourceMetadataStorage* storage,
106 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) 66 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
107 : blocking_task_runner_(blocking_task_runner), 67 : blocking_task_runner_(blocking_task_runner),
108 storage_(storage), 68 storage_(storage),
109 weak_ptr_factory_(this) { 69 weak_ptr_factory_(this) {
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
111 } 71 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 453
494 // TODO(hashimoto): Implement the real resource ID to local ID look up. 454 // TODO(hashimoto): Implement the real resource ID to local ID look up.
495 // crbug.com/260514 455 // crbug.com/260514
496 ResourceEntry entry; 456 ResourceEntry entry;
497 FileError error = GetResourceEntryById(resource_id, &entry); 457 FileError error = GetResourceEntryById(resource_id, &entry);
498 if (error == FILE_ERROR_OK) 458 if (error == FILE_ERROR_OK)
499 *out_local_id = resource_id; 459 *out_local_id = resource_id;
500 return error; 460 return error;
501 } 461 }
502 462
503 void ResourceMetadata::GetResourceEntryPairByPathsOnUIThread(
504 const base::FilePath& first_path,
505 const base::FilePath& second_path,
506 const GetResourceEntryPairCallback& callback) {
507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
508 DCHECK(!callback.is_null());
509
510 // Get the first entry.
511 GetResourceEntryByPathOnUIThread(
512 first_path,
513 base::Bind(
514 &ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetFirst,
515 weak_ptr_factory_.GetWeakPtr(),
516 first_path,
517 second_path,
518 callback));
519 }
520
521 void ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetFirst(
522 const base::FilePath& first_path,
523 const base::FilePath& second_path,
524 const GetResourceEntryPairCallback& callback,
525 FileError error,
526 scoped_ptr<ResourceEntry> entry) {
527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
528 DCHECK(!callback.is_null());
529
530 scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult);
531 result->first.path = first_path;
532 result->first.error = error;
533 result->first.entry = entry.Pass();
534
535 // If the first one is not found, don't continue.
536 if (error != FILE_ERROR_OK) {
537 callback.Run(result.Pass());
538 return;
539 }
540
541 // Get the second entry.
542 GetResourceEntryByPathOnUIThread(
543 second_path,
544 base::Bind(
545 &ResourceMetadata::
546 GetResourceEntryPairByPathsOnUIThreadAfterGetSecond,
547 weak_ptr_factory_.GetWeakPtr(),
548 second_path,
549 callback,
550 base::Passed(&result)));
551 }
552
553 void ResourceMetadata::GetResourceEntryPairByPathsOnUIThreadAfterGetSecond(
554 const base::FilePath& second_path,
555 const GetResourceEntryPairCallback& callback,
556 scoped_ptr<EntryInfoPairResult> result,
557 FileError error,
558 scoped_ptr<ResourceEntry> entry) {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
560 DCHECK(!callback.is_null());
561 DCHECK(result.get());
562
563 result->second.path = second_path;
564 result->second.error = error;
565 result->second.entry = entry.Pass();
566
567 callback.Run(result.Pass());
568 }
569
570 bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id, 463 bool ResourceMetadata::PutEntryUnderDirectory(const std::string& id,
571 const ResourceEntry& entry) { 464 const ResourceEntry& entry) {
572 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); 465 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
573 466
574 ResourceEntry updated_entry(entry); 467 ResourceEntry updated_entry(entry);
575 468
576 // The entry name may have been changed due to prior name de-duplication. 469 // The entry name may have been changed due to prior name de-duplication.
577 // We need to first restore the file name based on the title before going 470 // We need to first restore the file name based on the title before going
578 // through name de-duplication again when it is added to another directory. 471 // through name de-duplication again when it is added to another directory.
579 SetBaseNameFromTitle(&updated_entry); 472 SetBaseNameFromTitle(&updated_entry);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 for (size_t i = 0; i < children.size(); ++i) { 508 for (size_t i = 0; i < children.size(); ++i) {
616 if (!RemoveEntryRecursively(children[i])) 509 if (!RemoveEntryRecursively(children[i]))
617 return false; 510 return false;
618 } 511 }
619 } 512 }
620 return storage_->RemoveEntry(id); 513 return storage_->RemoveEntry(id);
621 } 514 }
622 515
623 } // namespace internal 516 } // namespace internal
624 } // namespace drive 517 } // 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