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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10827262: gdata: Remove use of FindEntryByPathSync() from MoveEntryFromRootDirectory() (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
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_file_system.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1228
1229 void GDataFileSystem::MoveEntryFromRootDirectory( 1229 void GDataFileSystem::MoveEntryFromRootDirectory(
1230 const FilePath& dir_path, 1230 const FilePath& dir_path,
1231 const FileOperationCallback& callback, 1231 const FileOperationCallback& callback,
1232 GDataFileError error, 1232 GDataFileError error,
1233 const FilePath& file_path) { 1233 const FilePath& file_path) {
1234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1235 DCHECK(!callback.is_null()); 1235 DCHECK(!callback.is_null());
1236 DCHECK_EQ(kGDataRootDirectory, file_path.DirName().value()); 1236 DCHECK_EQ(kGDataRootDirectory, file_path.DirName().value());
1237 1237
1238 GDataEntry* entry = directory_service_->FindEntryByPathSync(file_path); 1238 // Return if there is an error or |dir_path| is the root directory.
1239 GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(dir_path); 1239 if (error != GDATA_FILE_OK || dir_path == FilePath(kGDataRootDirectory)) {
1240 if (error == GDATA_FILE_OK) {
1241 if (!entry || !dir_entry) {
1242 error = GDATA_FILE_ERROR_NOT_FOUND;
1243 } else {
1244 if (!dir_entry->AsGDataDirectory())
1245 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
1246 }
1247 }
1248
1249 // Returns if there is an error or |dir_path| is the root directory.
1250 if (error != GDATA_FILE_OK ||
1251 dir_entry->resource_id() == kGDataRootDirectoryResourceId) {
1252 callback.Run(error); 1240 callback.Run(error);
1253 return; 1241 return;
1254 } 1242 }
1255 1243
1244 directory_service_->GetEntryInfoPairByPaths(
1245 file_path,
1246 dir_path,
1247 base::Bind(
1248 &GDataFileSystem::MoveEntryFromRootDirectoryAfterGetEntryInfoPair,
1249 ui_weak_ptr_,
1250 callback));
1251 }
1252
1253 void GDataFileSystem::MoveEntryFromRootDirectoryAfterGetEntryInfoPair(
1254 const FileOperationCallback& callback,
1255 scoped_ptr<EntryInfoPairResult> result) {
1256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1257 DCHECK(!callback.is_null());
1258 DCHECK(result.get());
1259
1260 if (result->first.error != GDATA_FILE_OK) {
1261 callback.Run(result->first.error);
1262 return;
1263 } else if (result->second.error != GDATA_FILE_OK) {
1264 callback.Run(result->second.error);
1265 return;
1266 }
1267
1268 scoped_ptr<GDataEntryProto> src_proto = result->first.proto.Pass();
achuithb 2012/08/10 08:46:42 I would've used GDataEntryProto* instead of scoped
1269 scoped_ptr<GDataEntryProto> dir_proto = result->second.proto.Pass();
1270
1271 if (!dir_proto->file_info().is_directory()) {
1272 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY);
1273 return;
1274 }
1275
1276 const FilePath& file_path = result->first.path;
1277 const FilePath& dir_path = result->second.path;
1256 documents_service_->AddResourceToDirectory( 1278 documents_service_->AddResourceToDirectory(
1257 dir_entry->content_url(), 1279 GURL(dir_proto->content_url()),
1258 entry->edit_url(), 1280 GURL(src_proto->edit_url()),
1259 base::Bind(&GDataFileSystem::OnMoveEntryFromRootDirectoryCompleted, 1281 base::Bind(&GDataFileSystem::OnMoveEntryFromRootDirectoryCompleted,
1260 ui_weak_ptr_, 1282 ui_weak_ptr_,
1261 callback, 1283 callback,
1262 file_path, 1284 file_path,
1263 dir_path)); 1285 dir_path));
1264 } 1286 }
1265 1287
1266 void GDataFileSystem::RemoveEntryFromDirectory( 1288 void GDataFileSystem::RemoveEntryFromDirectory(
1267 const FilePath& dir_path, 1289 const FilePath& dir_path,
1268 const FileMoveCallback& callback, 1290 const FileMoveCallback& callback,
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 } 3471 }
3450 3472
3451 PlatformFileInfoProto entry_file_info; 3473 PlatformFileInfoProto entry_file_info;
3452 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3474 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3453 *entry_proto->mutable_file_info() = entry_file_info; 3475 *entry_proto->mutable_file_info() = entry_file_info;
3454 if (!callback.is_null()) 3476 if (!callback.is_null())
3455 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3477 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3456 } 3478 }
3457 3479
3458 } // namespace gdata 3480 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698