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

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

Issue 10837148: gdata: Add GetEntryInfoByPath() and ReadDirectoryByPath() to GDataDirectoryService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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/browser/chromeos/gdata/gdata_files_unittest.cc » ('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
diff --git a/chrome/browser/chromeos/gdata/gdata_files.cc b/chrome/browser/chromeos/gdata/gdata_files.cc
index 23d565d704145f678aed1fb0c2f789ee6b871fc4..f598d1dd9c8214d239e9a4f460f997ae13958aca 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files.cc
@@ -651,6 +651,53 @@ void GDataDirectoryService::GetEntryByResourceIdAsync(
callback.Run(entry);
}
+void GDataDirectoryService::GetEntryInfoByPath(
+ const FilePath& path,
+ const GetEntryInfoCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ scoped_ptr<GDataEntryProto> entry_proto;
+ GDataFileError error = GDATA_FILE_ERROR_FAILED;
+
+ GDataEntry* entry = FindEntryByPathSync(path);
+ if (entry) {
+ entry_proto.reset(new GDataEntryProto);
+ entry->ToProtoFull(entry_proto.get());
+ error = GDATA_FILE_OK;
+ } else {
+ error = GDATA_FILE_ERROR_NOT_FOUND;
+ }
+
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, error, base::Passed(&entry_proto)));
+}
+
+void GDataDirectoryService::ReadDirectoryByPath(
+ const FilePath& path,
+ const ReadDirectoryCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+
+ scoped_ptr<GDataEntryProtoVector> entries;
+ GDataFileError error = GDATA_FILE_ERROR_FAILED;
+
+ GDataEntry* entry = FindEntryByPathSync(path);
+ if (entry && entry->AsGDataDirectory()) {
+ entries = entry->AsGDataDirectory()->ToProtoVector();
+ error = GDATA_FILE_OK;
+ } else if (entry && !entry->AsGDataDirectory()) {
+ error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
+ } else {
+ error = GDATA_FILE_ERROR_NOT_FOUND;
+ }
+
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, error, base::Passed(&entries)));
+}
+
void GDataDirectoryService::RefreshFile(scoped_ptr<GDataFile> fresh_file) {
DCHECK(fresh_file.get());
@@ -998,6 +1045,26 @@ void GDataDirectory::ToProto(GDataDirectoryProto* proto) const {
}
}
+scoped_ptr<GDataEntryProtoVector> GDataDirectory::ToProtoVector() const {
+ scoped_ptr<GDataEntryProtoVector> entries(new GDataEntryProtoVector);
+ for (GDataFileCollection::const_iterator iter = child_files().begin();
+ iter != child_files().end(); ++iter) {
+ GDataEntryProto proto;
+ iter->second->ToProto(&proto);
+ entries->push_back(proto);
+ }
+ for (GDataDirectoryCollection::const_iterator iter =
+ child_directories().begin();
+ iter != child_directories().end(); ++iter) {
+ GDataEntryProto proto;
+ // Convert to GDataEntry, as we don't want to include children in |proto|.
+ static_cast<const GDataEntry*>(iter->second)->ToProtoFull(&proto);
+ entries->push_back(proto);
+ }
+
+ return entries.Pass();
+}
+
void GDataEntry::SerializeToString(std::string* serialized_proto) const {
const GDataFile* file = AsGDataFileConst();
const GDataDirectory* dir = AsGDataDirectoryConst();
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/browser/chromeos/gdata/gdata_files_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698