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

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

Issue 10831212: gdata: Add GDataDirectoryService::GetEntryInfoPairByPaths() (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 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
« 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