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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/gdata/gdata_files.h" 5 #include "chrome/browser/chromeos/gdata/gdata_files.h"
6 6
7 #include <leveldb/db.h> 7 #include <leveldb/db.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 LOG(ERROR) << "Incompatible proto detected (bad resource ID): " 59 LOG(ERROR) << "Incompatible proto detected (bad resource ID): "
60 << entry_proto.resource_id(); 60 << entry_proto.resource_id();
61 return false; 61 return false;
62 } 62 }
63 63
64 return true; 64 return true;
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 EntryInfoPairResult::EntryInfoPairResult()
70 : first_error(GDATA_FILE_ERROR_FAILED),
71 second_error(GDATA_FILE_ERROR_FAILED) {
72 }
73
74 EntryInfoPairResult::~EntryInfoPairResult() {
75 }
76
69 // GDataEntry class. 77 // GDataEntry class.
70 78
71 GDataEntry::GDataEntry(GDataDirectory* parent, 79 GDataEntry::GDataEntry(GDataDirectory* parent,
72 GDataDirectoryService* directory_service) 80 GDataDirectoryService* directory_service)
73 : directory_service_(directory_service), 81 : directory_service_(directory_service),
74 deleted_(false) { 82 deleted_(false) {
75 SetParent(parent); 83 SetParent(parent);
76 } 84 }
77 85
78 GDataEntry::~GDataEntry() { 86 GDataEntry::~GDataEntry() {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY; 699 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
692 } else { 700 } else {
693 error = GDATA_FILE_ERROR_NOT_FOUND; 701 error = GDATA_FILE_ERROR_NOT_FOUND;
694 } 702 }
695 703
696 base::MessageLoopProxy::current()->PostTask( 704 base::MessageLoopProxy::current()->PostTask(
697 FROM_HERE, 705 FROM_HERE,
698 base::Bind(callback, error, base::Passed(&entries))); 706 base::Bind(callback, error, base::Passed(&entries)));
699 } 707 }
700 708
709 void GDataDirectoryService::GetEntryInfoPairByPaths(
710 const FilePath& first_path,
711 const FilePath& second_path,
712 const GetEntryInfoPairCallback& callback) {
713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
714 DCHECK(!callback.is_null());
715
716 // Get the first entry.
717 GetEntryInfoByPath(
718 first_path,
719 base::Bind(&GDataDirectoryService::GetEntryInfoPairByPathsAfterGetFirst,
720 weak_ptr_factory_.GetWeakPtr(),
721 first_path,
722 second_path,
723 callback));
724 }
725
701 void GDataDirectoryService::RefreshFile(scoped_ptr<GDataFile> fresh_file) { 726 void GDataDirectoryService::RefreshFile(scoped_ptr<GDataFile> fresh_file) {
702 DCHECK(fresh_file.get()); 727 DCHECK(fresh_file.get());
703 728
704 // Need to get a reference here because Passed() could get evaluated first. 729 // Need to get a reference here because Passed() could get evaluated first.
705 const std::string& resource_id = fresh_file->resource_id(); 730 const std::string& resource_id = fresh_file->resource_id();
706 GetEntryByResourceIdAsync( 731 GetEntryByResourceIdAsync(
707 resource_id, 732 resource_id,
708 base::Bind(&GDataDirectoryService::RefreshFileInternal, 733 base::Bind(&GDataDirectoryService::RefreshFileInternal,
709 base::Passed(&fresh_file))); 734 base::Passed(&fresh_file)));
710 } 735 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 // Call GDataFile::FromProto. 1162 // Call GDataFile::FromProto.
1138 if (file->FromProto(entry_proto)) { 1163 if (file->FromProto(entry_proto)) {
1139 entry.reset(file.release()); 1164 entry.reset(file.release());
1140 } else { 1165 } else {
1141 NOTREACHED() << "FromProto (file) failed"; 1166 NOTREACHED() << "FromProto (file) failed";
1142 } 1167 }
1143 } 1168 }
1144 return entry.Pass(); 1169 return entry.Pass();
1145 } 1170 }
1146 1171
1172 void GDataDirectoryService::GetEntryInfoPairByPathsAfterGetFirst(
1173 const FilePath& first_path,
1174 const FilePath& second_path,
1175 const GetEntryInfoPairCallback& callback,
1176 GDataFileError error,
1177 scoped_ptr<GDataEntryProto> entry_proto) {
1178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1179 DCHECK(!callback.is_null());
1180
1181 scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult);
1182 result->first_path = first_path;
1183 result->first_error = error;
1184 result->first_proto = entry_proto.Pass();
1185
1186 if (error != GDATA_FILE_OK) {
1187 callback.Run(result.Pass());
1188 return;
achuithb 2012/08/08 20:50:32 Why is this necessary? Why not look for the second
satorux1 2012/08/08 21:21:21 Looking at the code in gdata_file_system.cc, we do
1189 }
1190
1191 // Get the second entry.
1192 GetEntryInfoByPath(
1193 second_path,
1194 base::Bind(&GDataDirectoryService::GetEntryInfoPairByPathsAfterGetSecond,
1195 weak_ptr_factory_.GetWeakPtr(),
1196 second_path,
1197 callback,
1198 base::Passed(&result)));
1199 }
1200
1201 void GDataDirectoryService::GetEntryInfoPairByPathsAfterGetSecond(
1202 const FilePath& second_path,
1203 const GetEntryInfoPairCallback& callback,
1204 scoped_ptr<EntryInfoPairResult> result,
1205 GDataFileError error,
1206 scoped_ptr<GDataEntryProto> entry_proto) {
1207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1208 DCHECK(!callback.is_null());
1209 DCHECK(result.get());
1210
1211 result->second_path = second_path;
1212 result->second_error = error;
1213 result->second_proto = entry_proto.Pass();
1214
1215 callback.Run(result.Pass());
1216 }
1217
1147 } // namespace gdata 1218 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698