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

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

Issue 10538071: gdata: Convert FindEntryByResourceIdSync() to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase svn:trunk/src@141679 and resolve conflicts. Created 8 years, 6 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
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 <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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 }; 825 };
826 826
827 // Returns callback which runs the given |callback| on the current thread. 827 // Returns callback which runs the given |callback| on the current thread.
828 template<typename CallbackType> 828 template<typename CallbackType>
829 CallbackType CreateRelayCallback(const CallbackType& callback) { 829 CallbackType CreateRelayCallback(const CallbackType& callback) {
830 return base::Bind(&RelayCallback<CallbackType>::Run, 830 return base::Bind(&RelayCallback<CallbackType>::Run,
831 base::MessageLoopProxy::current(), 831 base::MessageLoopProxy::current(),
832 callback); 832 callback);
833 } 833 }
834 834
835 // Callback used to find a directory element for file system updates.
836 void ReadOnlyFindEntryCallback(GDataEntry** out,
837 base::PlatformFileError error,
838 GDataEntry* entry) {
839 if (error == base::PLATFORM_FILE_OK)
840 *out = entry;
841 }
842
835 } // namespace 843 } // namespace
836 844
837 // GDataFileSystem::GetDocumentsParams struct implementation. 845 // GDataFileSystem::GetDocumentsParams struct implementation.
838 846
839 GDataFileSystem::GetDocumentsParams::GetDocumentsParams( 847 GDataFileSystem::GetDocumentsParams::GetDocumentsParams(
840 int start_changestamp, 848 int start_changestamp,
841 int root_feed_changestamp, 849 int root_feed_changestamp,
842 std::vector<DocumentFeed*>* feed_list, 850 std::vector<DocumentFeed*>* feed_list,
843 bool should_fetch_multiple_feeds, 851 bool should_fetch_multiple_feeds,
844 const FilePath& search_file_path, 852 const FilePath& search_file_path,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 update_timer_.Stop(); 1049 update_timer_.Stop();
1042 } 1050 }
1043 1051
1044 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) { 1052 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) {
1045 // TokenFetcher, used in DocumentsService, must be run on UI thread. 1053 // TokenFetcher, used in DocumentsService, must be run on UI thread.
1046 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1054 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1047 1055
1048 documents_service_->Authenticate(callback); 1056 documents_service_->Authenticate(callback);
1049 } 1057 }
1050 1058
1051 void GDataFileSystem::FindEntryByResourceIdSync( 1059 void GDataFileSystem::FindEntryByResourceId(const std::string& resource_id,
1060 const FindEntryCallback& callback) {
1061 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
1062 BrowserThread::CurrentlyOn(BrowserThread::IO));
1063 RunTaskOnUIThread(
1064 base::Bind(&GDataFileSystem::FindEntryByResourceIdOnUIThread,
1065 ui_weak_ptr_,
1066 resource_id,
1067 CreateRelayCallback(callback)));
1068 }
1069
1070 void GDataFileSystem::FindEntryByResourceIdOnUIThread(
1052 const std::string& resource_id, 1071 const std::string& resource_id,
1053 const FindEntryCallback& callback) { 1072 const FindEntryCallback& callback) {
1073 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1074
1054 base::AutoLock lock(lock_); // To access root. 1075 base::AutoLock lock(lock_); // To access root.
1055
1056 GDataFile* file = NULL; 1076 GDataFile* file = NULL;
1057 GDataEntry* entry = root_->GetEntryByResourceId(resource_id); 1077 GDataEntry* entry = root_->GetEntryByResourceId(resource_id);
1058 if (entry) 1078 if (entry)
1059 file = entry->AsGDataFile(); 1079 file = entry->AsGDataFile();
1060 1080
1061 if (file) 1081 if (file)
1062 callback.Run(base::PLATFORM_FILE_OK, file); 1082 callback.Run(base::PLATFORM_FILE_OK, file);
1063 else 1083 else
1064 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); 1084 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
1065 } 1085 }
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after
5184 base::PlatformFileError error, 5204 base::PlatformFileError error,
5185 const std::string& resource_id, 5205 const std::string& resource_id,
5186 const std::string& md5) { 5206 const std::string& md5) {
5187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 5207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
5188 5208
5189 if (!callback.is_null()) 5209 if (!callback.is_null())
5190 callback.Run(error); 5210 callback.Run(error);
5191 } 5211 }
5192 5212
5193 } // namespace gdata 5213 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698