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 f598d1dd9c8214d239e9a4f460f997ae13958aca..73c2df836423ce949e5e25f8b11d7f2cad86755f 100644 |
| --- a/chrome/browser/chromeos/gdata/gdata_files.cc |
| +++ b/chrome/browser/chromeos/gdata/gdata_files.cc |
| @@ -66,6 +66,18 @@ bool IsValidRootDirectoryProto(const GDataDirectoryProto& proto) { |
| } // namespace |
| +EntryInfoResult::EntryInfoResult() : error(GDATA_FILE_ERROR_FAILED) { |
| +} |
| + |
| +EntryInfoResult::~EntryInfoResult() { |
| +} |
| + |
| +EntryInfoPairResult::EntryInfoPairResult() { |
| +} |
| + |
| +EntryInfoPairResult::~EntryInfoPairResult() { |
| +} |
| + |
| // GDataEntry class. |
| GDataEntry::GDataEntry(GDataDirectory* parent, |
| @@ -698,6 +710,23 @@ void GDataDirectoryService::ReadDirectoryByPath( |
| base::Bind(callback, error, base::Passed(&entries))); |
| } |
| +void GDataDirectoryService::GetEntryInfoPairByPaths( |
| + const FilePath& first_path, |
| + const FilePath& second_path, |
| + const GetEntryInfoPairCallback& callback) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK(!callback.is_null()); |
| + |
| + // Get the first entry. |
| + GetEntryInfoByPath( |
| + first_path, |
| + base::Bind(&GDataDirectoryService::GetEntryInfoPairByPathsAfterGetFirst, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + first_path, |
| + second_path, |
| + callback)); |
| +} |
| + |
| void GDataDirectoryService::RefreshFile(scoped_ptr<GDataFile> fresh_file) { |
| DCHECK(fresh_file.get()); |
| @@ -1144,4 +1173,50 @@ scoped_ptr<GDataEntry> GDataDirectoryService::FromProtoString( |
| return entry.Pass(); |
| } |
| +void GDataDirectoryService::GetEntryInfoPairByPathsAfterGetFirst( |
| + const FilePath& first_path, |
| + const FilePath& second_path, |
| + const GetEntryInfoPairCallback& callback, |
| + GDataFileError error, |
| + scoped_ptr<GDataEntryProto> entry_proto) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK(!callback.is_null()); |
| + |
| + scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult); |
| + result->first.path = first_path; |
|
achuithb
2012/08/08 22:02:47
You could optionally add a member like
void EntryI
satorux1
2012/08/08 22:13:34
Thank you for the suggestion, but I'd keep this as
|
| + result->first.error = error; |
| + result->first.proto = entry_proto.Pass(); |
| + |
| + if (error != GDATA_FILE_OK) { |
| + callback.Run(result.Pass()); |
|
achuithb
2012/08/08 22:02:47
Let's also add a comment here saying that if the f
satorux1
2012/08/08 22:13:34
Done.
|
| + return; |
| + } |
| + |
| + // Get the second entry. |
| + GetEntryInfoByPath( |
| + second_path, |
| + base::Bind(&GDataDirectoryService::GetEntryInfoPairByPathsAfterGetSecond, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + second_path, |
| + callback, |
| + base::Passed(&result))); |
| +} |
| + |
| +void GDataDirectoryService::GetEntryInfoPairByPathsAfterGetSecond( |
| + const FilePath& second_path, |
| + const GetEntryInfoPairCallback& callback, |
| + scoped_ptr<EntryInfoPairResult> result, |
| + GDataFileError error, |
| + scoped_ptr<GDataEntryProto> entry_proto) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK(!callback.is_null()); |
| + DCHECK(result.get()); |
| + |
| + result->second.path = second_path; |
| + result->second.error = error; |
| + result->second.proto = entry_proto.Pass(); |
| + |
| + callback.Run(result.Pass()); |
| +} |
| + |
| } // namespace gdata |