Chromium Code Reviews| 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(); |