Index: chrome/browser/extensions/api/developer_private/developer_private_api.cc |
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
index 1642e47f0a563d02acce615f5a858dfe6eefddbb..0e36e9e2c86a740696af4d14752264aa486121bf 100644 |
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
@@ -834,28 +834,33 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
return; |
} |
+ pendingCallbacksCount_ = 1; |
+ |
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
ReadSyncFileSystemDirectory, |
- this, project_path)); |
+ this, project_path, project_path.BaseName())); |
} |
void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
- ReadSyncFileSystemDirectory(const base::FilePath& project_path) { |
+ ReadSyncFileSystemDirectory(const base::FilePath& project_path, |
+ const base::FilePath& current_path) { |
std::string origin_url( |
Extension::GetBaseURLFromExtensionId(extension_id()).spec()); |
fileapi::FileSystemURL url(sync_file_system::CreateSyncableFileSystemURL( |
GURL(origin_url), |
- project_path.BaseName())); |
+ current_path)); |
context_->operation_runner()->ReadDirectory( |
url, base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
- ReadSyncFileSystemDirectoryCb, this, project_path)); |
+ ReadSyncFileSystemDirectoryCb, |
+ this, project_path, current_path)); |
} |
void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
ReadSyncFileSystemDirectoryCb( |
const base::FilePath& project_path, |
+ const base::FilePath& current_path, |
base::PlatformFileError status, |
const fileapi::FileSystemOperation::FileEntryList& file_list, |
bool has_more) { |
@@ -865,24 +870,20 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
return; |
} |
- // Create an empty project folder if there are no files. |
- if (!file_list.size()) { |
- content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
- base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
- CreateFolderAndSendResponse, |
- this, |
- project_path)); |
- return; |
- } |
- |
- pendingCallbacksCount_ = file_list.size(); |
+ pendingCallbacksCount_ += file_list.size(); |
miket_OOO
2013/06/12 19:39:24
This is pretty confusing. You're adding N to pendi
Gaurav
2013/06/21 22:11:00
Done.
|
for (size_t i = 0; i < file_list.size(); ++i) { |
+ if (file_list[i].is_directory) { |
+ ReadSyncFileSystemDirectory(project_path.Append(file_list[i].name), |
+ current_path.Append(file_list[i].name)); |
+ continue; |
miket_OOO
2013/06/12 19:39:24
This is a good example of why it's confusing. It s
Gaurav
2013/06/21 22:11:00
Done.
|
+ } |
+ |
std::string origin_url( |
Extension::GetBaseURLFromExtensionId(extension_id()).spec()); |
fileapi::FileSystemURL url(sync_file_system::CreateSyncableFileSystemURL( |
GURL(origin_url), |
- project_path.BaseName().Append(file_list[i].name))); |
+ current_path.Append(file_list[i].name))); |
base::FilePath target_path = project_path; |
target_path = target_path.Append(file_list[i].name); |
@@ -893,19 +894,16 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
SnapshotFileCallback, |
this, |
target_path)); |
- } |
-} |
-void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
- CreateFolderAndSendResponse(const base::FilePath& project_path) { |
- if (!(success_ = file_util::CreateDirectory(project_path))) { |
- SetError("Error in copying files from sync filesystem."); |
} |
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
- base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
- SendResponse, |
- this, |
- success_)); |
+ pendingCallbacksCount_--; |
+ if (!pendingCallbacksCount_) { |
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
+ base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: |
+ SendResponse, |
+ this, |
+ success_)); |
+ } |
} |
void DeveloperPrivateExportSyncfsFolderToLocalfsFunction::SnapshotFileCallback( |