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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_files.cc

Issue 10383156: Remove directory_path argument from chromeos::FindEntryCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 7 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
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gdata/gdata_files.h" 5 #include "chrome/browser/chromeos/gdata/gdata_files.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 file_path.GetComponents(&components); 512 file_path.GetComponents(&components);
513 513
514 GDataDirectory* current_dir = this; 514 GDataDirectory* current_dir = this;
515 FilePath directory_path; 515 FilePath directory_path;
516 516
517 util::GDataSearchPathType path_type = 517 util::GDataSearchPathType path_type =
518 util::GetSearchPathStatusForPathComponents(components); 518 util::GetSearchPathStatusForPathComponents(components);
519 519
520 if (path_type == util::GDATA_SEARCH_PATH_ROOT || 520 if (path_type == util::GDATA_SEARCH_PATH_ROOT ||
521 path_type == util::GDATA_SEARCH_PATH_QUERY) { 521 path_type == util::GDATA_SEARCH_PATH_QUERY) {
522 callback.Run(base::PLATFORM_FILE_OK, file_path.DirName(), 522 callback.Run(base::PLATFORM_FILE_OK, fake_search_directory_.get());
523 fake_search_directory_.get());
524 return; 523 return;
525 } 524 }
526 525
527 // If the path is under search path, we have to modify paremeters for finding 526 // If the path is under search path, we have to modify paremeters for finding
528 // the entry. 527 // the entry.
529 if (path_type != util::GDATA_SEARCH_PATH_INVALID) { 528 if (path_type != util::GDATA_SEARCH_PATH_INVALID) {
530 if (!ModifyFindEntryParamsForSearchPath(file_path, 529 if (!ModifyFindEntryParamsForSearchPath(file_path,
531 &components, &current_dir, &directory_path)) { 530 &components, &current_dir, &directory_path)) {
532 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL); 531 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
533 return; 532 return;
534 } 533 }
535 } 534 }
536 535
537 for (size_t i = 0; i < components.size() && current_dir; i++) { 536 for (size_t i = 0; i < components.size() && current_dir; i++) {
538 directory_path = directory_path.Append(current_dir->file_name()); 537 directory_path = directory_path.Append(current_dir->file_name());
539 538
540 // Last element must match, if not last then it must be a directory. 539 // Last element must match, if not last then it must be a directory.
541 if (i == components.size() - 1) { 540 if (i == components.size() - 1) {
542 if (current_dir->file_name() == components[i]) 541 if (current_dir->file_name() == components[i])
543 callback.Run(base::PLATFORM_FILE_OK, directory_path, current_dir); 542 callback.Run(base::PLATFORM_FILE_OK, current_dir);
544 else 543 else
545 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL); 544 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
546 return; 545 return;
547 } 546 }
548 547
549 // Not the last part of the path, search for the next segment. 548 // Not the last part of the path, search for the next segment.
550 GDataEntry* entry = current_dir->FindChild(components[i + 1]); 549 GDataEntry* entry = current_dir->FindChild(components[i + 1]);
551 if (!entry) { 550 if (!entry) {
552 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL); 551 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
553 return; 552 return;
554 } 553 }
555 554
556 // Found file, must be the last segment. 555 // Found file, must be the last segment.
557 if (entry->file_info().is_directory) { 556 if (entry->file_info().is_directory) {
558 // Found directory, continue traversal. 557 // Found directory, continue traversal.
559 current_dir = entry->AsGDataDirectory(); 558 current_dir = entry->AsGDataDirectory();
560 } else { 559 } else {
561 if ((i + 1) == (components.size() - 1)) 560 if ((i + 1) == (components.size() - 1))
562 callback.Run(base::PLATFORM_FILE_OK, directory_path, entry); 561 callback.Run(base::PLATFORM_FILE_OK, entry);
563 else 562 else
564 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL); 563 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
565 564
566 return; 565 return;
567 } 566 }
568 } 567 }
569 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL); 568 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
570 } 569 }
571 570
572 GDataEntry* GDataRootDirectory::GetEntryByResourceId( 571 GDataEntry* GDataRootDirectory::GetEntryByResourceId(
573 const std::string& resource) { 572 const std::string& resource) {
574 // GDataFileSystem has already locked. 573 // GDataFileSystem has already locked.
575 ResourceMap::const_iterator iter = resource_map_.find(resource); 574 ResourceMap::const_iterator iter = resource_map_.find(resource);
576 if (iter == resource_map_.end()) 575 if (iter == resource_map_.end())
577 return NULL; 576 return NULL;
578 return iter->second; 577 return iter->second;
579 } 578 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 875 }
877 876
878 FromProto(*proto.get()); 877 FromProto(*proto.get());
879 set_origin(FROM_CACHE); 878 set_origin(FROM_CACHE);
880 set_refresh_time(base::Time::Now()); 879 set_refresh_time(base::Time::Now());
881 } 880 }
882 return ok; 881 return ok;
883 } 882 }
884 883
885 } // namespace gdata 884 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698