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 <errno.h> | 7 #include <errno.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 update_timer_.Stop(); | 1034 update_timer_.Stop(); |
1035 } | 1035 } |
1036 | 1036 |
1037 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) { | 1037 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) { |
1038 // TokenFetcher, used in DocumentsService, must be run on UI thread. | 1038 // TokenFetcher, used in DocumentsService, must be run on UI thread. |
1039 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1039 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1040 | 1040 |
1041 documents_service_->Authenticate(callback); | 1041 documents_service_->Authenticate(callback); |
1042 } | 1042 } |
1043 | 1043 |
1044 void GDataFileSystem::FindEntryByResourceIdSync( | 1044 void GDataFileSystem::FindEntryByResourceIdAsync( |
1045 const std::string& resource_id, | 1045 const std::string& resource_id, |
1046 const FindEntryCallback& callback) { | 1046 const FindEntryCallback& callback) { |
1047 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | |
achuithb
2012/06/11 20:46:37
Not sure I understand the point of this DCHECK?
hshi1
2012/06/11 20:58:51
This is essentially a copy & paste of the many oth
achuithb
2012/06/11 21:48:41
I've not seen this pattern before (outside of this
| |
1048 BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
1049 RunTaskOnUIThread( | |
1050 base::Bind(&GDataFileSystem::FindEntryByResourceIdAsyncOnUIThread, | |
1051 ui_weak_ptr_, | |
1052 resource_id, | |
1053 CreateRelayCallback(callback))); | |
1054 } | |
1055 | |
1056 void GDataFileSystem::FindEntryByResourceIdAsyncOnUIThread( | |
1057 const std::string& resource_id, | |
1058 const FindEntryCallback& callback) { | |
1059 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
1060 | |
1047 base::AutoLock lock(lock_); // To access root. | 1061 base::AutoLock lock(lock_); // To access root. |
1048 | |
1049 GDataFile* file = NULL; | 1062 GDataFile* file = NULL; |
1050 GDataEntry* entry = root_->GetEntryByResourceId(resource_id); | 1063 GDataEntry* entry = root_->GetEntryByResourceId(resource_id); |
1051 if (entry) | 1064 if (entry) |
1052 file = entry->AsGDataFile(); | 1065 file = entry->AsGDataFile(); |
1053 | 1066 |
1054 if (file) | 1067 if (file) |
1055 callback.Run(base::PLATFORM_FILE_OK, file); | 1068 callback.Run(base::PLATFORM_FILE_OK, file); |
1056 else | 1069 else |
1057 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); | 1070 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); |
1058 } | 1071 } |
(...skipping 4132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5191 base::PlatformFileError error, | 5204 base::PlatformFileError error, |
5192 const std::string& resource_id, | 5205 const std::string& resource_id, |
5193 const std::string& md5) { | 5206 const std::string& md5) { |
5194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 5207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
5195 | 5208 |
5196 if (!callback.is_null()) | 5209 if (!callback.is_null()) |
5197 callback.Run(error); | 5210 callback.Run(error); |
5198 } | 5211 } |
5199 | 5212 |
5200 } // namespace gdata | 5213 } // namespace gdata |
OLD | NEW |