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

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

Issue 10790126: gdata: Remove use of GetGDataEntryByPath() from Rename (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 1461
1462 // It is a no-op if the file is renamed to the same name. 1462 // It is a no-op if the file is renamed to the same name.
1463 if (file_path.BaseName().value() == new_name) { 1463 if (file_path.BaseName().value() == new_name) {
1464 if (!callback.is_null()) { 1464 if (!callback.is_null()) {
1465 MessageLoop::current()->PostTask( 1465 MessageLoop::current()->PostTask(
1466 FROM_HERE, base::Bind(callback, GDATA_FILE_OK, file_path)); 1466 FROM_HERE, base::Bind(callback, GDATA_FILE_OK, file_path));
1467 } 1467 }
1468 return; 1468 return;
1469 } 1469 }
1470 1470
1471 GDataEntry* entry = GetGDataEntryByPath(file_path); 1471 // Get the edit URL of an entry at |file_path|.
1472 if (!entry) { 1472 GetEntryInfoByPath(file_path,
1473 if (!callback.is_null()) { 1473 base::Bind(
1474 MessageLoop::current()->PostTask(FROM_HERE, 1474 &GDataFileSystem::RenameAfterGetEntryInfo,
1475 base::Bind(callback, GDATA_FILE_ERROR_NOT_FOUND, file_path)); 1475 ui_weak_ptr_,
1476 } 1476 file_path,
1477 new_name,
1478 callback));
1479 }
1480
1481 void GDataFileSystem::RenameAfterGetEntryInfo(
1482 const FilePath& file_path,
1483 const FilePath::StringType& new_name,
1484 const FilePathUpdateCallback& callback,
1485 GDataFileError error,
1486 scoped_ptr<GDataEntryProto> entry_proto) {
1487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1488
1489 if (error != GDATA_FILE_OK) {
1490 if (!callback.is_null())
1491 callback.Run(error, file_path);
1477 return; 1492 return;
1478 } 1493 }
1494 DCHECK(entry_proto.get());
1479 1495
1480 // Drop the .g<something> extension from |new_name| if the file being 1496 // Drop the .g<something> extension from |new_name| if the file being
1481 // renamed is a hosted document and |new_name| has the same .g<something> 1497 // renamed is a hosted document and |new_name| has the same .g<something>
1482 // extension as the file. 1498 // extension as the file.
1483 FilePath::StringType file_name = new_name; 1499 FilePath::StringType file_name = new_name;
1484 if (entry->AsGDataFile() && entry->AsGDataFile()->is_hosted_document()) { 1500 if (entry_proto->has_file_specific_info() &&
achuithb 2012/07/23 22:06:00 I know this is not part of this CL, but what happe
satorux1 2012/07/23 22:23:58 Nothing is wrong with entry_proto->has_file_specif
1501 entry_proto->file_specific_info().is_hosted_document()) {
1485 FilePath new_file(file_name); 1502 FilePath new_file(file_name);
1486 if (new_file.Extension() == entry->AsGDataFile()->document_extension()) { 1503 if (new_file.Extension() ==
1504 entry_proto->file_specific_info().document_extension()) {
1487 file_name = new_file.RemoveExtension().value(); 1505 file_name = new_file.RemoveExtension().value();
1488 } 1506 }
1489 } 1507 }
1490 1508
1491 documents_service_->RenameResource( 1509 documents_service_->RenameResource(
1492 entry->edit_url(), 1510 GURL(entry_proto->edit_url()),
1493 file_name, 1511 file_name,
1494 base::Bind(&GDataFileSystem::OnRenameResourceCompleted, 1512 base::Bind(&GDataFileSystem::OnRenameResourceCompleted,
1495 ui_weak_ptr_, 1513 ui_weak_ptr_,
1496 file_path, 1514 file_path,
1497 file_name, 1515 file_name,
1498 callback)); 1516 callback));
1499 } 1517 }
1500 1518
1501 void GDataFileSystem::Move(const FilePath& src_file_path, 1519 void GDataFileSystem::Move(const FilePath& src_file_path,
1502 const FilePath& dest_file_path, 1520 const FilePath& dest_file_path,
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after
4063 // must go through here. Removes the |file_path| from the remembered set so 4081 // must go through here. Removes the |file_path| from the remembered set so
4064 // that subsequent operations can open the file again. 4082 // that subsequent operations can open the file again.
4065 open_files_.erase(file_path); 4083 open_files_.erase(file_path);
4066 4084
4067 // Then invokes the user-supplied callback function. 4085 // Then invokes the user-supplied callback function.
4068 if (!callback.is_null()) 4086 if (!callback.is_null())
4069 callback.Run(result); 4087 callback.Run(result);
4070 } 4088 }
4071 4089
4072 } // namespace gdata 4090 } // 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