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

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: address comments 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 d49b5f41af3e3c00001e0731dc018dbf78549cc1..c710fd9ee17f544f403e65137943521b99a20055 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files.cc
@@ -677,6 +677,54 @@ 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()) {
+ GDataDirectory* directory = entry->AsGDataDirectory();
achuithb 2012/08/07 21:39:20 nit: Is this temporary necessary?
satorux1 2012/08/07 22:57:05 Good catch. no longer needed.
+ entries = directory->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());
@@ -1024,6 +1072,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