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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 DCHECK(entry); | 1829 DCHECK(entry); |
1830 | 1830 |
1831 scoped_ptr<GDataEntryProto> entry_proto(new GDataEntryProto); | 1831 scoped_ptr<GDataEntryProto> entry_proto(new GDataEntryProto); |
1832 entry->ToProtoFull(entry_proto.get()); | 1832 entry->ToProtoFull(entry_proto.get()); |
1833 | 1833 |
1834 CheckLocalModificationAndRun(entry_proto.Pass(), callback); | 1834 CheckLocalModificationAndRun(entry_proto.Pass(), callback); |
1835 } | 1835 } |
1836 | 1836 |
1837 void GDataFileSystem::ReadDirectoryByPath( | 1837 void GDataFileSystem::ReadDirectoryByPath( |
1838 const FilePath& file_path, | 1838 const FilePath& file_path, |
1839 const ReadDirectoryCallback& callback) { | 1839 const ReadDirectoryWithSettingCallback& callback) { |
1840 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1840 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1841 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1841 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1842 RunTaskOnUIThread( | 1842 RunTaskOnUIThread( |
1843 base::Bind(&GDataFileSystem::ReadDirectoryByPathAsyncOnUIThread, | 1843 base::Bind(&GDataFileSystem::ReadDirectoryByPathAsyncOnUIThread, |
1844 ui_weak_ptr_, | 1844 ui_weak_ptr_, |
1845 file_path, | 1845 file_path, |
1846 CreateRelayCallback(callback))); | 1846 CreateRelayCallback(callback))); |
1847 } | 1847 } |
1848 | 1848 |
1849 void GDataFileSystem::ReadDirectoryByPathAsyncOnUIThread( | 1849 void GDataFileSystem::ReadDirectoryByPathAsyncOnUIThread( |
1850 const FilePath& file_path, | 1850 const FilePath& file_path, |
1851 const ReadDirectoryCallback& callback) { | 1851 const ReadDirectoryWithSettingCallback& callback) { |
1852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1853 | 1853 |
1854 FindEntryByPathAsyncOnUIThread( | 1854 FindEntryByPathAsyncOnUIThread( |
1855 file_path, | 1855 file_path, |
1856 base::Bind(&GDataFileSystem::OnReadDirectory, | 1856 base::Bind(&GDataFileSystem::OnReadDirectory, |
1857 ui_weak_ptr_, | 1857 ui_weak_ptr_, |
1858 callback)); | 1858 callback)); |
1859 } | 1859 } |
1860 | 1860 |
1861 void GDataFileSystem::OnReadDirectory(const ReadDirectoryCallback& callback, | 1861 void GDataFileSystem::OnReadDirectory( |
1862 GDataFileError error, | 1862 const ReadDirectoryWithSettingCallback& callback, |
1863 GDataEntry* entry) { | 1863 GDataFileError error, |
| 1864 GDataEntry* entry) { |
1864 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1865 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1865 | 1866 |
1866 if (error != GDATA_FILE_OK) { | 1867 if (error != GDATA_FILE_OK) { |
1867 if (!callback.is_null()) | 1868 if (!callback.is_null()) |
1868 callback.Run(error, | 1869 callback.Run(error, |
1869 hide_hosted_docs_, | 1870 hide_hosted_docs_, |
1870 scoped_ptr<GDataEntryProtoVector>()); | 1871 scoped_ptr<GDataEntryProtoVector>()); |
1871 return; | 1872 return; |
1872 } | 1873 } |
1873 DCHECK(entry); | 1874 DCHECK(entry); |
1874 | 1875 |
1875 GDataDirectory* directory = entry->AsGDataDirectory(); | 1876 GDataDirectory* directory = entry->AsGDataDirectory(); |
1876 if (!directory) { | 1877 if (!directory) { |
1877 if (!callback.is_null()) | 1878 if (!callback.is_null()) |
1878 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, | 1879 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, |
1879 hide_hosted_docs_, | 1880 hide_hosted_docs_, |
1880 scoped_ptr<GDataEntryProtoVector>()); | 1881 scoped_ptr<GDataEntryProtoVector>()); |
1881 return; | 1882 return; |
1882 } | 1883 } |
1883 | 1884 |
1884 scoped_ptr<GDataEntryProtoVector> entries(new GDataEntryProtoVector); | 1885 scoped_ptr<GDataEntryProtoVector> entries(directory->ToProtoVector()); |
1885 for (GDataFileCollection::const_iterator iter = | |
1886 directory->child_files().begin(); | |
1887 iter != directory->child_files().end(); ++iter) { | |
1888 GDataEntryProto proto; | |
1889 static_cast<const GDataEntry*>(iter->second)->ToProtoFull(&proto); | |
1890 entries->push_back(proto); | |
1891 } | |
1892 for (GDataDirectoryCollection::const_iterator iter = | |
1893 directory->child_directories().begin(); | |
1894 iter != directory->child_directories().end(); ++iter) { | |
1895 GDataEntryProto proto; | |
1896 static_cast<const GDataEntry*>(iter->second)->ToProtoFull(&proto); | |
1897 entries->push_back(proto); | |
1898 } | |
1899 | 1886 |
1900 if (!callback.is_null()) | 1887 if (!callback.is_null()) |
1901 callback.Run(GDATA_FILE_OK, hide_hosted_docs_, entries.Pass()); | 1888 callback.Run(GDATA_FILE_OK, hide_hosted_docs_, entries.Pass()); |
1902 } | 1889 } |
1903 | 1890 |
1904 void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) { | 1891 void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) { |
1905 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1906 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1893 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1907 RunTaskOnUIThread( | 1894 RunTaskOnUIThread( |
1908 base::Bind(&GDataFileSystem::RequestDirectoryRefreshOnUIThread, | 1895 base::Bind(&GDataFileSystem::RequestDirectoryRefreshOnUIThread, |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3424 } | 3411 } |
3425 | 3412 |
3426 PlatformFileInfoProto entry_file_info; | 3413 PlatformFileInfoProto entry_file_info; |
3427 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3414 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
3428 *entry_proto->mutable_file_info() = entry_file_info; | 3415 *entry_proto->mutable_file_info() = entry_file_info; |
3429 if (!callback.is_null()) | 3416 if (!callback.is_null()) |
3430 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3417 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
3431 } | 3418 } |
3432 | 3419 |
3433 } // namespace gdata | 3420 } // namespace gdata |
OLD | NEW |