OLD | NEW |
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // GDataFileSystem::GetFileFromCacheParams struct implementation. | 446 // GDataFileSystem::GetFileFromCacheParams struct implementation. |
447 struct GDataFileSystem::GetFileFromCacheParams { | 447 struct GDataFileSystem::GetFileFromCacheParams { |
448 GetFileFromCacheParams( | 448 GetFileFromCacheParams( |
449 const FilePath& virtual_file_path, | 449 const FilePath& virtual_file_path, |
450 const FilePath& local_tmp_path, | 450 const FilePath& local_tmp_path, |
451 const GURL& content_url, | 451 const GURL& content_url, |
452 const std::string& resource_id, | 452 const std::string& resource_id, |
453 const std::string& md5, | 453 const std::string& md5, |
454 const std::string& mime_type, | 454 const std::string& mime_type, |
455 const GetFileCallback& get_file_callback, | 455 const GetFileCallback& get_file_callback, |
456 const GetDownloadDataCallback& get_download_data_callback); | 456 const GetContentCallback& get_content_callback); |
457 ~GetFileFromCacheParams(); | 457 ~GetFileFromCacheParams(); |
458 | 458 |
459 FilePath virtual_file_path; | 459 FilePath virtual_file_path; |
460 FilePath local_tmp_path; | 460 FilePath local_tmp_path; |
461 GURL content_url; | 461 GURL content_url; |
462 std::string resource_id; | 462 std::string resource_id; |
463 std::string md5; | 463 std::string md5; |
464 std::string mime_type; | 464 std::string mime_type; |
465 const GetFileCallback get_file_callback; | 465 const GetFileCallback get_file_callback; |
466 const GetDownloadDataCallback get_download_data_callback; | 466 const GetContentCallback get_content_callback; |
467 }; | 467 }; |
468 | 468 |
469 GDataFileSystem::GetFileFromCacheParams::GetFileFromCacheParams( | 469 GDataFileSystem::GetFileFromCacheParams::GetFileFromCacheParams( |
470 const FilePath& virtual_file_path, | 470 const FilePath& virtual_file_path, |
471 const FilePath& local_tmp_path, | 471 const FilePath& local_tmp_path, |
472 const GURL& content_url, | 472 const GURL& content_url, |
473 const std::string& resource_id, | 473 const std::string& resource_id, |
474 const std::string& md5, | 474 const std::string& md5, |
475 const std::string& mime_type, | 475 const std::string& mime_type, |
476 const GetFileCallback& get_file_callback, | 476 const GetFileCallback& get_file_callback, |
477 const GetDownloadDataCallback& get_download_data_callback) | 477 const GetContentCallback& get_content_callback) |
478 : virtual_file_path(virtual_file_path), | 478 : virtual_file_path(virtual_file_path), |
479 local_tmp_path(local_tmp_path), | 479 local_tmp_path(local_tmp_path), |
480 content_url(content_url), | 480 content_url(content_url), |
481 resource_id(resource_id), | 481 resource_id(resource_id), |
482 md5(md5), | 482 md5(md5), |
483 mime_type(mime_type), | 483 mime_type(mime_type), |
484 get_file_callback(get_file_callback), | 484 get_file_callback(get_file_callback), |
485 get_download_data_callback(get_download_data_callback) { | 485 get_content_callback(get_content_callback) { |
486 } | 486 } |
487 | 487 |
488 GDataFileSystem::GetFileFromCacheParams::~GetFileFromCacheParams() { | 488 GDataFileSystem::GetFileFromCacheParams::~GetFileFromCacheParams() { |
489 } | 489 } |
490 | 490 |
491 // GDataFileSystem::StartFileUploadParams implementation. | 491 // GDataFileSystem::StartFileUploadParams implementation. |
492 struct GDataFileSystem::StartFileUploadParams { | 492 struct GDataFileSystem::StartFileUploadParams { |
493 StartFileUploadParams(const FilePath& in_local_file_path, | 493 StartFileUploadParams(const FilePath& in_local_file_path, |
494 const FilePath& in_remote_file_path, | 494 const FilePath& in_remote_file_path, |
495 const FileOperationCallback& in_callback) | 495 const FileOperationCallback& in_callback) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 const FilePath& remote_src_file_path, | 709 const FilePath& remote_src_file_path, |
710 const FilePath& local_dest_file_path, | 710 const FilePath& local_dest_file_path, |
711 const FileOperationCallback& callback) { | 711 const FileOperationCallback& callback) { |
712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
713 | 713 |
714 GetFileByPath(remote_src_file_path, | 714 GetFileByPath(remote_src_file_path, |
715 base::Bind(&GDataFileSystem::OnGetFileCompleteForTransferFile, | 715 base::Bind(&GDataFileSystem::OnGetFileCompleteForTransferFile, |
716 ui_weak_ptr_, | 716 ui_weak_ptr_, |
717 local_dest_file_path, | 717 local_dest_file_path, |
718 callback), | 718 callback), |
719 GetDownloadDataCallback()); | 719 GetContentCallback()); |
720 } | 720 } |
721 | 721 |
722 void GDataFileSystem::TransferFileFromLocalToRemote( | 722 void GDataFileSystem::TransferFileFromLocalToRemote( |
723 const FilePath& local_src_file_path, | 723 const FilePath& local_src_file_path, |
724 const FilePath& remote_dest_file_path, | 724 const FilePath& remote_dest_file_path, |
725 const FileOperationCallback& callback) { | 725 const FileOperationCallback& callback) { |
726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
727 | 727 |
728 // Make sure the destination directory exists. | 728 // Make sure the destination directory exists. |
729 directory_service_->GetEntryInfoByPath( | 729 directory_service_->GetEntryInfoByPath( |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 return; | 975 return; |
976 } | 976 } |
977 | 977 |
978 // TODO(benchan): Reimplement this once the server API supports | 978 // TODO(benchan): Reimplement this once the server API supports |
979 // copying of regular files directly on the server side. | 979 // copying of regular files directly on the server side. |
980 GetFileByPath(src_file_path, | 980 GetFileByPath(src_file_path, |
981 base::Bind(&GDataFileSystem::OnGetFileCompleteForCopy, | 981 base::Bind(&GDataFileSystem::OnGetFileCompleteForCopy, |
982 ui_weak_ptr_, | 982 ui_weak_ptr_, |
983 dest_file_path, | 983 dest_file_path, |
984 callback), | 984 callback), |
985 GetDownloadDataCallback()); | 985 GetContentCallback()); |
986 } | 986 } |
987 | 987 |
988 void GDataFileSystem::OnGetFileCompleteForCopy( | 988 void GDataFileSystem::OnGetFileCompleteForCopy( |
989 const FilePath& remote_dest_file_path, | 989 const FilePath& remote_dest_file_path, |
990 const FileOperationCallback& callback, | 990 const FileOperationCallback& callback, |
991 GDataFileError error, | 991 GDataFileError error, |
992 const FilePath& local_file_path, | 992 const FilePath& local_file_path, |
993 const std::string& unused_mime_type, | 993 const std::string& unused_mime_type, |
994 GDataFileType file_type) { | 994 GDataFileType file_type) { |
995 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 995 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 | 1480 |
1481 // No entry found at |file_path|. Let's create a brand new file. | 1481 // No entry found at |file_path|. Let's create a brand new file. |
1482 // For now, it is implemented by uploading an empty file (/dev/null). | 1482 // For now, it is implemented by uploading an empty file (/dev/null). |
1483 // TODO(kinaba): http://crbug.com/135143. Implement in a nicer way. | 1483 // TODO(kinaba): http://crbug.com/135143. Implement in a nicer way. |
1484 TransferRegularFile(FilePath(kEmptyFilePath), file_path, callback); | 1484 TransferRegularFile(FilePath(kEmptyFilePath), file_path, callback); |
1485 } | 1485 } |
1486 | 1486 |
1487 void GDataFileSystem::GetFileByPath( | 1487 void GDataFileSystem::GetFileByPath( |
1488 const FilePath& file_path, | 1488 const FilePath& file_path, |
1489 const GetFileCallback& get_file_callback, | 1489 const GetFileCallback& get_file_callback, |
1490 const GetDownloadDataCallback& get_download_data_callback) { | 1490 const GetContentCallback& get_content_callback) { |
1491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1492 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1492 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1493 RunTaskOnUIThread( | 1493 RunTaskOnUIThread( |
1494 base::Bind(&GDataFileSystem::GetFileByPathOnUIThread, | 1494 base::Bind(&GDataFileSystem::GetFileByPathOnUIThread, |
1495 ui_weak_ptr_, | 1495 ui_weak_ptr_, |
1496 file_path, | 1496 file_path, |
1497 CreateRelayCallback(get_file_callback), | 1497 CreateRelayCallback(get_file_callback), |
1498 CreateRelayCallback(get_download_data_callback))); | 1498 CreateRelayCallback(get_content_callback))); |
1499 } | 1499 } |
1500 | 1500 |
1501 void GDataFileSystem::GetFileByPathOnUIThread( | 1501 void GDataFileSystem::GetFileByPathOnUIThread( |
1502 const FilePath& file_path, | 1502 const FilePath& file_path, |
1503 const GetFileCallback& get_file_callback, | 1503 const GetFileCallback& get_file_callback, |
1504 const GetDownloadDataCallback& get_download_data_callback) { | 1504 const GetContentCallback& get_content_callback) { |
1505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1506 | 1506 |
1507 directory_service_->GetEntryInfoByPath( | 1507 directory_service_->GetEntryInfoByPath( |
1508 file_path, | 1508 file_path, |
1509 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath, | 1509 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath, |
1510 ui_weak_ptr_, | 1510 ui_weak_ptr_, |
1511 file_path, | 1511 file_path, |
1512 CreateRelayCallback(get_file_callback), | 1512 CreateRelayCallback(get_file_callback), |
1513 CreateRelayCallback(get_download_data_callback))); | 1513 CreateRelayCallback(get_content_callback))); |
1514 } | 1514 } |
1515 | 1515 |
1516 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath( | 1516 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath( |
1517 const FilePath& file_path, | 1517 const FilePath& file_path, |
1518 const GetFileCallback& get_file_callback, | 1518 const GetFileCallback& get_file_callback, |
1519 const GetDownloadDataCallback& get_download_data_callback, | 1519 const GetContentCallback& get_content_callback, |
1520 GDataFileError error, | 1520 GDataFileError error, |
1521 scoped_ptr<GDataEntryProto> entry_proto) { | 1521 scoped_ptr<GDataEntryProto> entry_proto) { |
1522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1523 | 1523 |
1524 // If |error| == PLATFORM_FILE_OK then |entry_proto| must be valid. | 1524 // If |error| == PLATFORM_FILE_OK then |entry_proto| must be valid. |
1525 DCHECK(error != GDATA_FILE_OK || | 1525 DCHECK(error != GDATA_FILE_OK || |
1526 (entry_proto.get() && !entry_proto->resource_id().empty())); | 1526 (entry_proto.get() && !entry_proto->resource_id().empty())); |
1527 GetResolvedFileByPath(file_path, | 1527 GetResolvedFileByPath(file_path, |
1528 get_file_callback, | 1528 get_file_callback, |
1529 get_download_data_callback, | 1529 get_content_callback, |
1530 error, | 1530 error, |
1531 entry_proto.get()); | 1531 entry_proto.get()); |
1532 } | 1532 } |
1533 | 1533 |
1534 void GDataFileSystem::GetResolvedFileByPath( | 1534 void GDataFileSystem::GetResolvedFileByPath( |
1535 const FilePath& file_path, | 1535 const FilePath& file_path, |
1536 const GetFileCallback& get_file_callback, | 1536 const GetFileCallback& get_file_callback, |
1537 const GetDownloadDataCallback& get_download_data_callback, | 1537 const GetContentCallback& get_content_callback, |
1538 GDataFileError error, | 1538 GDataFileError error, |
1539 const GDataEntryProto* entry_proto) { | 1539 const GDataEntryProto* entry_proto) { |
1540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1541 | 1541 |
1542 if (entry_proto && !entry_proto->has_file_specific_info()) | 1542 if (entry_proto && !entry_proto->has_file_specific_info()) |
1543 error = GDATA_FILE_ERROR_NOT_FOUND; | 1543 error = GDATA_FILE_ERROR_NOT_FOUND; |
1544 | 1544 |
1545 if (error != GDATA_FILE_OK) { | 1545 if (error != GDATA_FILE_OK) { |
1546 if (!get_file_callback.is_null()) { | 1546 if (!get_file_callback.is_null()) { |
1547 MessageLoop::current()->PostTask( | 1547 MessageLoop::current()->PostTask( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 &GDataFileSystem::OnGetFileFromCache, | 1599 &GDataFileSystem::OnGetFileFromCache, |
1600 ui_weak_ptr_, | 1600 ui_weak_ptr_, |
1601 GetFileFromCacheParams( | 1601 GetFileFromCacheParams( |
1602 file_path, | 1602 file_path, |
1603 local_tmp_path, | 1603 local_tmp_path, |
1604 GURL(entry_proto->content_url()), | 1604 GURL(entry_proto->content_url()), |
1605 entry_proto->resource_id(), | 1605 entry_proto->resource_id(), |
1606 entry_proto->file_specific_info().file_md5(), | 1606 entry_proto->file_specific_info().file_md5(), |
1607 entry_proto->file_specific_info().content_mime_type(), | 1607 entry_proto->file_specific_info().content_mime_type(), |
1608 get_file_callback, | 1608 get_file_callback, |
1609 get_download_data_callback))); | 1609 get_content_callback))); |
1610 } | 1610 } |
1611 | 1611 |
1612 void GDataFileSystem::GetFileByResourceId( | 1612 void GDataFileSystem::GetFileByResourceId( |
1613 const std::string& resource_id, | 1613 const std::string& resource_id, |
1614 const GetFileCallback& get_file_callback, | 1614 const GetFileCallback& get_file_callback, |
1615 const GetDownloadDataCallback& get_download_data_callback) { | 1615 const GetContentCallback& get_content_callback) { |
1616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1617 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1617 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1618 RunTaskOnUIThread( | 1618 RunTaskOnUIThread( |
1619 base::Bind(&GDataFileSystem::GetFileByResourceIdOnUIThread, | 1619 base::Bind(&GDataFileSystem::GetFileByResourceIdOnUIThread, |
1620 ui_weak_ptr_, | 1620 ui_weak_ptr_, |
1621 resource_id, | 1621 resource_id, |
1622 CreateRelayCallback(get_file_callback), | 1622 CreateRelayCallback(get_file_callback), |
1623 CreateRelayCallback(get_download_data_callback))); | 1623 CreateRelayCallback(get_content_callback))); |
1624 } | 1624 } |
1625 | 1625 |
1626 void GDataFileSystem::GetFileByResourceIdOnUIThread( | 1626 void GDataFileSystem::GetFileByResourceIdOnUIThread( |
1627 const std::string& resource_id, | 1627 const std::string& resource_id, |
1628 const GetFileCallback& get_file_callback, | 1628 const GetFileCallback& get_file_callback, |
1629 const GetDownloadDataCallback& get_download_data_callback) { | 1629 const GetContentCallback& get_content_callback) { |
1630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1631 | 1631 |
1632 directory_service_->GetEntryByResourceIdAsync(resource_id, | 1632 directory_service_->GetEntryByResourceIdAsync(resource_id, |
1633 base::Bind(&GDataFileSystem::GetFileByEntryOnUIThread, | 1633 base::Bind(&GDataFileSystem::GetFileByEntryOnUIThread, |
1634 ui_weak_ptr_, | 1634 ui_weak_ptr_, |
1635 get_file_callback, | 1635 get_file_callback, |
1636 get_download_data_callback)); | 1636 get_content_callback)); |
1637 } | 1637 } |
1638 | 1638 |
1639 void GDataFileSystem::GetFileByEntryOnUIThread( | 1639 void GDataFileSystem::GetFileByEntryOnUIThread( |
1640 const GetFileCallback& get_file_callback, | 1640 const GetFileCallback& get_file_callback, |
1641 const GetDownloadDataCallback& get_download_data_callback, | 1641 const GetContentCallback& get_content_callback, |
1642 GDataEntry* entry) { | 1642 GDataEntry* entry) { |
1643 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1643 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1644 | 1644 |
1645 FilePath file_path; | 1645 FilePath file_path; |
1646 if (entry) { | 1646 if (entry) { |
1647 GDataFile* file = entry->AsGDataFile(); | 1647 GDataFile* file = entry->AsGDataFile(); |
1648 if (file) | 1648 if (file) |
1649 file_path = file->GetFilePath(); | 1649 file_path = file->GetFilePath(); |
1650 } | 1650 } |
1651 | 1651 |
1652 // Report an error immediately if the file for the resource ID is not | 1652 // Report an error immediately if the file for the resource ID is not |
1653 // found. | 1653 // found. |
1654 if (file_path.empty()) { | 1654 if (file_path.empty()) { |
1655 if (!get_file_callback.is_null()) { | 1655 if (!get_file_callback.is_null()) { |
1656 base::MessageLoopProxy::current()->PostTask( | 1656 base::MessageLoopProxy::current()->PostTask( |
1657 FROM_HERE, | 1657 FROM_HERE, |
1658 base::Bind(get_file_callback, | 1658 base::Bind(get_file_callback, |
1659 GDATA_FILE_ERROR_NOT_FOUND, | 1659 GDATA_FILE_ERROR_NOT_FOUND, |
1660 FilePath(), | 1660 FilePath(), |
1661 std::string(), | 1661 std::string(), |
1662 REGULAR_FILE)); | 1662 REGULAR_FILE)); |
1663 } | 1663 } |
1664 return; | 1664 return; |
1665 } | 1665 } |
1666 | 1666 |
1667 GetFileByPath(file_path, get_file_callback, get_download_data_callback); | 1667 GetFileByPath(file_path, get_file_callback, get_content_callback); |
1668 } | 1668 } |
1669 | 1669 |
1670 void GDataFileSystem::OnGetFileFromCache(const GetFileFromCacheParams& params, | 1670 void GDataFileSystem::OnGetFileFromCache(const GetFileFromCacheParams& params, |
1671 GDataFileError error, | 1671 GDataFileError error, |
1672 const std::string& resource_id, | 1672 const std::string& resource_id, |
1673 const std::string& md5, | 1673 const std::string& md5, |
1674 const FilePath& cache_file_path) { | 1674 const FilePath& cache_file_path) { |
1675 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1675 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1676 | 1676 |
1677 // Have we found the file in cache? If so, return it back to the caller. | 1677 // Have we found the file in cache? If so, return it back to the caller. |
(...skipping 23 matching lines...) Expand all Loading... |
1701 base::Bind(&GDataFileSystem::OnGetDocumentEntry, | 1701 base::Bind(&GDataFileSystem::OnGetDocumentEntry, |
1702 ui_weak_ptr_, | 1702 ui_weak_ptr_, |
1703 cache_file_path, | 1703 cache_file_path, |
1704 GetFileFromCacheParams(params.virtual_file_path, | 1704 GetFileFromCacheParams(params.virtual_file_path, |
1705 params.local_tmp_path, | 1705 params.local_tmp_path, |
1706 params.content_url, | 1706 params.content_url, |
1707 params.resource_id, | 1707 params.resource_id, |
1708 params.md5, | 1708 params.md5, |
1709 params.mime_type, | 1709 params.mime_type, |
1710 params.get_file_callback, | 1710 params.get_file_callback, |
1711 params.get_download_data_callback))); | 1711 params.get_content_callback))); |
1712 } | 1712 } |
1713 | 1713 |
1714 void GDataFileSystem::OnGetDocumentEntry(const FilePath& cache_file_path, | 1714 void GDataFileSystem::OnGetDocumentEntry(const FilePath& cache_file_path, |
1715 const GetFileFromCacheParams& params, | 1715 const GetFileFromCacheParams& params, |
1716 GDataErrorCode status, | 1716 GDataErrorCode status, |
1717 scoped_ptr<base::Value> data) { | 1717 scoped_ptr<base::Value> data) { |
1718 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1718 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1719 | 1719 |
1720 GDataFileError error = util::GDataToGDataFileError(status); | 1720 GDataFileError error = util::GDataToGDataFileError(status); |
1721 | 1721 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 } | 1786 } |
1787 | 1787 |
1788 // We have enough disk space. Start downloading the file. | 1788 // We have enough disk space. Start downloading the file. |
1789 documents_service_->DownloadFile( | 1789 documents_service_->DownloadFile( |
1790 params.virtual_file_path, | 1790 params.virtual_file_path, |
1791 params.local_tmp_path, | 1791 params.local_tmp_path, |
1792 content_url, | 1792 content_url, |
1793 base::Bind(&GDataFileSystem::OnFileDownloaded, | 1793 base::Bind(&GDataFileSystem::OnFileDownloaded, |
1794 ui_weak_ptr_, | 1794 ui_weak_ptr_, |
1795 params), | 1795 params), |
1796 params.get_download_data_callback); | 1796 params.get_content_callback); |
1797 } | 1797 } |
1798 | 1798 |
1799 void GDataFileSystem::GetEntryInfoByPath(const FilePath& file_path, | 1799 void GDataFileSystem::GetEntryInfoByPath(const FilePath& file_path, |
1800 const GetEntryInfoCallback& callback) { | 1800 const GetEntryInfoCallback& callback) { |
1801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1802 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1802 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1803 RunTaskOnUIThread( | 1803 RunTaskOnUIThread( |
1804 base::Bind(&GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread, | 1804 base::Bind(&GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread, |
1805 ui_weak_ptr_, | 1805 ui_weak_ptr_, |
1806 file_path, | 1806 file_path, |
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 | 3073 |
3074 DCHECK(!entry_proto->resource_id().empty()); | 3074 DCHECK(!entry_proto->resource_id().empty()); |
3075 GetResolvedFileByPath( | 3075 GetResolvedFileByPath( |
3076 file_path, | 3076 file_path, |
3077 base::Bind(&GDataFileSystem::OnGetFileCompleteForOpenFile, | 3077 base::Bind(&GDataFileSystem::OnGetFileCompleteForOpenFile, |
3078 ui_weak_ptr_, | 3078 ui_weak_ptr_, |
3079 callback, | 3079 callback, |
3080 GetFileCompleteForOpenParams( | 3080 GetFileCompleteForOpenParams( |
3081 entry_proto->resource_id(), | 3081 entry_proto->resource_id(), |
3082 entry_proto->file_specific_info().file_md5())), | 3082 entry_proto->file_specific_info().file_md5())), |
3083 GetDownloadDataCallback(), | 3083 GetContentCallback(), |
3084 error, | 3084 error, |
3085 entry_proto.get()); | 3085 entry_proto.get()); |
3086 } | 3086 } |
3087 | 3087 |
3088 void GDataFileSystem::OnGetFileCompleteForOpenFile( | 3088 void GDataFileSystem::OnGetFileCompleteForOpenFile( |
3089 const OpenFileCallback& callback, | 3089 const OpenFileCallback& callback, |
3090 const GetFileCompleteForOpenParams& entry_proto, | 3090 const GetFileCompleteForOpenParams& entry_proto, |
3091 GDataFileError error, | 3091 GDataFileError error, |
3092 const FilePath& file_path, | 3092 const FilePath& file_path, |
3093 const std::string& mime_type, | 3093 const std::string& mime_type, |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3428 } | 3428 } |
3429 | 3429 |
3430 PlatformFileInfoProto entry_file_info; | 3430 PlatformFileInfoProto entry_file_info; |
3431 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3431 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
3432 *entry_proto->mutable_file_info() = entry_file_info; | 3432 *entry_proto->mutable_file_info() = entry_file_info; |
3433 if (!callback.is_null()) | 3433 if (!callback.is_null()) |
3434 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3434 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
3435 } | 3435 } |
3436 | 3436 |
3437 } // namespace gdata | 3437 } // namespace gdata |
OLD | NEW |