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

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: Fix spelling error of 'completion' and a few unnecessary newlines. 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } // namespace 835 } // namespace
836 836
837 void ReadOnlyFindEntryCallback(GDataEntry** out,
838 base::PlatformFileError error,
839 GDataEntry* entry) {
840 if (error == base::PLATFORM_FILE_OK)
841 *out = entry;
842 }
843
837 // GDataFileSystem::GetDocumentsParams struct implementation. 844 // GDataFileSystem::GetDocumentsParams struct implementation.
838 845
839 GDataFileSystem::GetDocumentsParams::GetDocumentsParams( 846 GDataFileSystem::GetDocumentsParams::GetDocumentsParams(
840 int start_changestamp, 847 int start_changestamp,
841 int root_feed_changestamp, 848 int root_feed_changestamp,
842 std::vector<DocumentFeed*>* feed_list, 849 std::vector<DocumentFeed*>* feed_list,
843 bool should_fetch_multiple_feeds, 850 bool should_fetch_multiple_feeds,
844 const FilePath& search_file_path, 851 const FilePath& search_file_path,
845 const std::string& search_query, 852 const std::string& search_query,
846 const std::string& directory_resource_id, 853 const std::string& directory_resource_id,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 update_timer_.Stop(); 1050 update_timer_.Stop();
1044 } 1051 }
1045 1052
1046 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) { 1053 void GDataFileSystem::Authenticate(const AuthStatusCallback& callback) {
1047 // TokenFetcher, used in DocumentsService, must be run on UI thread. 1054 // TokenFetcher, used in DocumentsService, must be run on UI thread.
1048 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1055 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1049 1056
1050 documents_service_->Authenticate(callback); 1057 documents_service_->Authenticate(callback);
1051 } 1058 }
1052 1059
1053 void GDataFileSystem::FindEntryByResourceIdSync( 1060 void GDataFileSystem::FindEntryByResourceId(const std::string& resource_id,
1061 const FindEntryCallback& callback) {
1062 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
1063 BrowserThread::CurrentlyOn(BrowserThread::IO));
1064 RunTaskOnUIThread(
1065 base::Bind(&GDataFileSystem::FindEntryByResourceIdOnUIThread,
1066 ui_weak_ptr_,
1067 resource_id,
1068 CreateRelayCallback(callback)));
1069 }
1070
1071 void GDataFileSystem::FindEntryByResourceIdOnUIThread(
1054 const std::string& resource_id, 1072 const std::string& resource_id,
1055 const FindEntryCallback& callback) { 1073 const FindEntryCallback& callback) {
1074 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1075
1056 base::AutoLock lock(lock_); // To access root. 1076 base::AutoLock lock(lock_); // To access root.
1057
1058 GDataFile* file = NULL; 1077 GDataFile* file = NULL;
1059 GDataEntry* entry = root_->GetEntryByResourceId(resource_id); 1078 GDataEntry* entry = root_->GetEntryByResourceId(resource_id);
1060 if (entry) 1079 if (entry)
1061 file = entry->AsGDataFile(); 1080 file = entry->AsGDataFile();
1062 1081
1063 if (file) 1082 if (file)
1064 callback.Run(base::PLATFORM_FILE_OK, file); 1083 callback.Run(base::PLATFORM_FILE_OK, file);
1065 else 1084 else
1066 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); 1085 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL);
1067 } 1086 }
(...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after
5203 base::PlatformFileError error, 5222 base::PlatformFileError error,
5204 const std::string& resource_id, 5223 const std::string& resource_id,
5205 const std::string& md5) { 5224 const std::string& md5) {
5206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 5225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
5207 5226
5208 if (!callback.is_null()) 5227 if (!callback.is_null())
5209 callback.Run(error); 5228 callback.Run(error);
5210 } 5229 }
5211 5230
5212 } // namespace gdata 5231 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698