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 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 base::Bind(&GDataFileSystem::OnFileDownloaded, | 1863 base::Bind(&GDataFileSystem::OnFileDownloaded, |
1864 ui_weak_ptr_, | 1864 ui_weak_ptr_, |
1865 params), | 1865 params), |
1866 params.get_content_callback); | 1866 params.get_content_callback); |
1867 } | 1867 } |
1868 | 1868 |
1869 void GDataFileSystem::GetEntryInfoByPath(const FilePath& file_path, | 1869 void GDataFileSystem::GetEntryInfoByPath(const FilePath& file_path, |
1870 const GetEntryInfoCallback& callback) { | 1870 const GetEntryInfoCallback& callback) { |
1871 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1871 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
1872 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1872 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1873 DCHECK(!callback.is_null()); |
| 1874 |
1873 RunTaskOnUIThread( | 1875 RunTaskOnUIThread( |
1874 base::Bind(&GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread, | 1876 base::Bind(&GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread, |
1875 ui_weak_ptr_, | 1877 ui_weak_ptr_, |
1876 file_path, | 1878 file_path, |
1877 CreateRelayCallback(callback))); | 1879 CreateRelayCallback(callback))); |
1878 } | 1880 } |
1879 | 1881 |
1880 void GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread( | 1882 void GDataFileSystem::GetEntryInfoByPathAsyncOnUIThread( |
1881 const FilePath& file_path, | 1883 const FilePath& file_path, |
1882 const GetEntryInfoCallback& callback) { | 1884 const GetEntryInfoCallback& callback) { |
1883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1886 DCHECK(!callback.is_null()); |
1884 | 1887 |
1885 FindEntryByPathAsyncOnUIThread( | 1888 FindEntryByPathAsyncOnUIThread( |
1886 file_path, | 1889 file_path, |
1887 base::Bind(&GDataFileSystem::OnGetEntryInfo, | 1890 base::Bind(&GDataFileSystem::OnGetEntryInfo, |
1888 ui_weak_ptr_, | 1891 ui_weak_ptr_, |
1889 callback)); | 1892 callback)); |
1890 } | 1893 } |
1891 | 1894 |
1892 void GDataFileSystem::OnGetEntryInfo(const GetEntryInfoCallback& callback, | 1895 void GDataFileSystem::OnGetEntryInfo(const GetEntryInfoCallback& callback, |
1893 GDataFileError error, | 1896 GDataFileError error, |
1894 GDataEntry* entry) { | 1897 GDataEntry* entry) { |
1895 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1898 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1899 DCHECK(!callback.is_null()); |
1896 | 1900 |
1897 if (error != GDATA_FILE_OK) { | 1901 if (error != GDATA_FILE_OK) { |
1898 if (!callback.is_null()) | 1902 callback.Run(error, scoped_ptr<GDataEntryProto>()); |
1899 callback.Run(error, scoped_ptr<GDataEntryProto>()); | |
1900 return; | 1903 return; |
1901 } | 1904 } |
1902 DCHECK(entry); | 1905 DCHECK(entry); |
1903 | 1906 |
1904 scoped_ptr<GDataEntryProto> entry_proto(new GDataEntryProto); | 1907 scoped_ptr<GDataEntryProto> entry_proto(new GDataEntryProto); |
1905 entry->ToProtoFull(entry_proto.get()); | 1908 entry->ToProtoFull(entry_proto.get()); |
1906 | 1909 |
1907 CheckLocalModificationAndRun(entry_proto.Pass(), callback); | 1910 CheckLocalModificationAndRun(entry_proto.Pass(), callback); |
1908 } | 1911 } |
1909 | 1912 |
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3403 return; | 3406 return; |
3404 } | 3407 } |
3405 | 3408 |
3406 PlatformFileInfoProto entry_file_info; | 3409 PlatformFileInfoProto entry_file_info; |
3407 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3410 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
3408 *entry_proto->mutable_file_info() = entry_file_info; | 3411 *entry_proto->mutable_file_info() = entry_file_info; |
3409 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3412 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
3410 } | 3413 } |
3411 | 3414 |
3412 } // namespace gdata | 3415 } // namespace gdata |
OLD | NEW |