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

Unified Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 10543037: gdata: Convert public synchronous functions in GDataFileSystem to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Toni's comments @ 06/08/12 10:59AM PDT. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_handler_util.cc
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index 08db70e8071fe9277c7b2c216a62ad115924204a..4bbdaa9a43c79b75b2e7efa73ffab01de452847d 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -547,6 +547,14 @@ void FileTaskExecutor::ExecuteFailedOnUIThread() {
Done(false);
}
+const Extension* FileTaskExecutor::GetExtension() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ ExtensionService* service = profile_->GetExtensionService();
+ return service ? service->GetExtensionById(extension_id_, false) :
+ NULL;
+}
+
void FileTaskExecutor::ExecuteFileActionsOnUIThread(
const std::string& file_system_name,
const GURL& file_system_root,
@@ -554,20 +562,37 @@ void FileTaskExecutor::ExecuteFileActionsOnUIThread(
int handler_pid) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ExtensionService* service = profile_->GetExtensionService();
- if (!service) {
+ const Extension* extension = GetExtension();
+ if (!extension) {
Done(false);
return;
}
- const Extension* extension = service->GetExtensionById(extension_id_, false);
+ InitHandlerHostFileAccessPermissions(
+ file_list,
+ extension,
+ action_id_,
+ base::Bind(&FileTaskExecutor::OnInitAccessForExecuteFileActionsOnUIThread,
+ this,
+ file_system_name,
+ file_system_root,
+ file_list,
+ handler_pid));
+}
+
+void FileTaskExecutor::OnInitAccessForExecuteFileActionsOnUIThread(
+ const std::string& file_system_name,
+ const GURL& file_system_root,
+ const FileDefinitionList& file_list,
+ int handler_pid) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ const Extension* extension = GetExtension();
if (!extension) {
Done(false);
return;
}
- InitHandlerHostFileAccessPermissions(file_list, extension, action_id_);
-
if (handler_pid > 0) {
SetupPermissionsAndDispatchEvent(file_system_name, file_system_root,
file_list, handler_pid, NULL);
@@ -649,9 +674,11 @@ void FileTaskExecutor::SetupPermissionsAndDispatchEvent(
void FileTaskExecutor::InitHandlerHostFileAccessPermissions(
const FileDefinitionList& file_list,
const Extension* handler_extension,
- const std::string& action_id) {
+ const std::string& action_id,
+ const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>);
for (FileDefinitionList::const_iterator iter = file_list.begin();
iter != file_list.end();
++iter) {
@@ -660,15 +687,22 @@ void FileTaskExecutor::InitHandlerHostFileAccessPermissions(
iter->absolute_path,
GetAccessPermissionsForHandler(handler_extension, action_id)));
- if (!gdata::util::IsUnderGDataMountPoint(iter->absolute_path))
- continue;
+ if (gdata::util::IsUnderGDataMountPoint(iter->absolute_path))
+ gdata_paths->push_back(iter->virtual_path);
+ }
- // If the file is on gdata mount point, we'll have to give handler host
- // permissions for file's gdata cache paths.
- // This has to be called on UI thread.
- gdata::util::InsertGDataCachePathsPermissions(profile_, iter->virtual_path,
- &handler_host_permissions_);
+ if (gdata_paths->empty()) {
+ // Invoke callback if none of the files are on gdata mount point.
+ callback.Run();
+ return;
}
+
+ // For files on gdata mount point, we'll have to give handler host permissions
+ // for their cache paths. This has to be called on UI thread.
+ gdata::util::InsertGDataCachePathsPermissions(profile_,
+ gdata_paths.Pass(),
+ &handler_host_permissions_,
+ callback);
}
void FileTaskExecutor::SetupHandlerHostFileAccessPermissions(int handler_pid) {
« no previous file with comments | « chrome/browser/chromeos/extensions/file_handler_util.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698