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

Unified Diff: chrome/browser/chromeos/gdata/gdata_files.cc

Issue 10204013: Move FindEntryDelegate and friends to separate file. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: change tense of comments Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_files.cc
===================================================================
--- chrome/browser/chromeos/gdata/gdata_files.cc (revision 133833)
+++ chrome/browser/chromeos/gdata/gdata_files.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/platform_file.h"
#include "base/stringprintf.h"
#include "base/string_util.h"
+#include "chrome/browser/chromeos/gdata/find_entry_delegate.h"
#include "chrome/browser/chromeos/gdata/gdata.pb.h"
#include "chrome/browser/chromeos/gdata/gdata_parser.h"
#include "net/base/escape.h"
@@ -446,6 +447,57 @@
}
}
+void GDataRootDirectory::FindEntryByPath(
+ const FilePath& file_path,
+ FindEntryDelegate* delegate) {
+ // GDataFileSystem has already locked.
+ DCHECK(delegate);
+
+ std::vector<FilePath::StringType> components;
+ file_path.GetComponents(&components);
+
+ GDataDirectory* current_dir = this;
+ FilePath directory_path;
+ for (size_t i = 0; i < components.size() && current_dir; i++) {
+ directory_path = directory_path.Append(current_dir->file_name());
+
+ // Last element must match, if not last then it must be a directory.
+ if (i == components.size() - 1) {
+ if (current_dir->file_name() == components[i])
+ delegate->OnDone(base::PLATFORM_FILE_OK, directory_path, current_dir);
+ else
+ delegate->OnDone(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
+
+ return;
+ }
+
+ // Not the last part of the path, search for the next segment.
+ GDataFileCollection::const_iterator file_iter =
+ current_dir->children().find(components[i + 1]);
+ if (file_iter == current_dir->children().end()) {
+ delegate->OnDone(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
+ return;
+ }
+
+ // Found file, must be the last segment.
+ if (file_iter->second->file_info().is_directory) {
+ // Found directory, continue traversal.
+ current_dir = file_iter->second->AsGDataDirectory();
+ } else {
+ if ((i + 1) == (components.size() - 1)) {
+ delegate->OnDone(base::PLATFORM_FILE_OK,
+ directory_path,
+ file_iter->second);
+ } else {
+ delegate->OnDone(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
+ }
+
+ return;
+ }
+ }
+ delegate->OnDone(base::PLATFORM_FILE_ERROR_NOT_FOUND, FilePath(), NULL);
+}
+
GDataEntry* GDataRootDirectory::GetEntryByResourceId(
const std::string& resource) {
// GDataFileSystem has already locked.
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698