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

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

Issue 10832254: gdata: Remove use of FindEntryByPathSync() from RemoveEntryFromNonRootDirectory() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: just rebase 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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 } 1285 }
1286 1286
1287 void GDataFileSystem::RemoveEntryFromNonRootDirectory( 1287 void GDataFileSystem::RemoveEntryFromNonRootDirectory(
1288 const FileMoveCallback& callback, 1288 const FileMoveCallback& callback,
1289 GDataFileError error, 1289 GDataFileError error,
1290 const FilePath& file_path) { 1290 const FilePath& file_path) {
1291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1292 DCHECK(!callback.is_null()); 1292 DCHECK(!callback.is_null());
1293 1293
1294 const FilePath dir_path = file_path.DirName(); 1294 const FilePath dir_path = file_path.DirName();
1295 GDataEntry* entry = directory_service_->FindEntryByPathSync(file_path); 1295 // Return if there is an error or |dir_path| is the root directory.
1296 GDataEntry* dir = directory_service_->FindEntryByPathSync(dir_path); 1296 if (error != GDATA_FILE_OK || dir_path == FilePath(kGDataRootDirectory)) {
1297 if (error == GDATA_FILE_OK) {
1298 if (!entry || !dir) {
1299 error = GDATA_FILE_ERROR_NOT_FOUND;
1300 } else {
1301 if (!dir->AsGDataDirectory())
1302 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
1303 }
1304 }
1305
1306 // Returns if there is an error or |dir_path| is the root directory.
1307 if (error != GDATA_FILE_OK ||
1308 dir->resource_id() == kGDataRootDirectoryResourceId) {
1309 callback.Run(error, file_path); 1297 callback.Run(error, file_path);
1310 return; 1298 return;
1311 } 1299 }
1312 1300
1301 directory_service_->GetEntryInfoPairByPaths(
1302 file_path,
1303 dir_path,
1304 base::Bind(
1305 &GDataFileSystem::RemoveEntryFromNonRootDirectoryAfterEntryInfoPair,
1306 ui_weak_ptr_,
1307 callback));
1308 }
1309
1310 void GDataFileSystem::RemoveEntryFromNonRootDirectoryAfterEntryInfoPair(
1311 const FileMoveCallback& callback,
1312 scoped_ptr<EntryInfoPairResult> result) {
1313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1314 DCHECK(!callback.is_null());
1315 DCHECK(result.get());
1316
1317 const FilePath& file_path = result->first.path;
1318 const FilePath& dir_path = result->second.path;
1319 if (result->first.error != GDATA_FILE_OK) {
1320 callback.Run(result->first.error, file_path);
1321 return;
1322 } else if (result->second.error != GDATA_FILE_OK) {
1323 callback.Run(result->second.error, file_path);
1324 return;
1325 }
1326
1327 scoped_ptr<GDataEntryProto> entry_proto = result->first.proto.Pass();
1328 scoped_ptr<GDataEntryProto> dir_proto = result->second.proto.Pass();
1329
1330 if (!dir_proto->file_info().is_directory()) {
1331 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY, file_path);
1332 return;
1333 }
1334
1313 documents_service_->RemoveResourceFromDirectory( 1335 documents_service_->RemoveResourceFromDirectory(
1314 dir->content_url(), 1336 GURL(dir_proto->content_url()),
1315 entry->edit_url(), 1337 GURL(entry_proto->edit_url()),
1316 entry->resource_id(), 1338 entry_proto->resource_id(),
1317 base::Bind(&GDataFileSystem::MoveEntryToRootDirectoryLocally, 1339 base::Bind(&GDataFileSystem::MoveEntryToRootDirectoryLocally,
1318 ui_weak_ptr_, 1340 ui_weak_ptr_,
1319 callback, 1341 callback,
1320 file_path, 1342 file_path,
1321 dir_path)); 1343 dir_path));
1322 } 1344 }
1323 1345
1324 void GDataFileSystem::Remove(const FilePath& file_path, 1346 void GDataFileSystem::Remove(const FilePath& file_path,
1325 bool is_recursive, 1347 bool is_recursive,
1326 const FileOperationCallback& callback) { 1348 const FileOperationCallback& callback) {
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3465 } 3487 }
3466 3488
3467 PlatformFileInfoProto entry_file_info; 3489 PlatformFileInfoProto entry_file_info;
3468 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3490 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3469 *entry_proto->mutable_file_info() = entry_file_info; 3491 *entry_proto->mutable_file_info() = entry_file_info;
3470 if (!callback.is_null()) 3492 if (!callback.is_null())
3471 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3493 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3472 } 3494 }
3473 3495
3474 } // namespace gdata 3496 } // 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