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

Unified Diff: chrome/browser/local_discovery/storage/privet_filesystem_operations.cc

Issue 177373010: [Privet FS] Allow files to be able to be copied in to the privet filesystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « chrome/browser/local_discovery/storage/privet_filesystem_operations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/storage/privet_filesystem_operations.cc
diff --git a/chrome/browser/local_discovery/storage/privet_filesystem_operations.cc b/chrome/browser/local_discovery/storage/privet_filesystem_operations.cc
index aa84d25cc9d5fae550cda19d9a36160d0e2112da..4eb8ffab1d94cf783154b62cd0022dbce34c4a3f 100644
--- a/chrome/browser/local_discovery/storage/privet_filesystem_operations.cc
+++ b/chrome/browser/local_discovery/storage/privet_filesystem_operations.cc
@@ -243,6 +243,19 @@ void PrivetFileSystemOperationFactory::CreateDirectory(
operation->Start();
}
+void PrivetFileSystemOperationFactory::CopyInForeignFile(
+ base::FilePath src_file_path,
+ const fileapi::FileSystemURL& dest_url,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) {
+ TemporaryServiceDiscoveryClient();
+
+ PrivetFileSystemAsyncOperation* operation =
+ new PrivetFileSystemUploadOperation(
+ dest_url.path(), src_file_path, browser_context_, this, callback);
+ async_operations_.insert(operation);
+ operation->Start();
+}
+
void PrivetFileSystemOperationFactory::RemoveOperation(
PrivetFileSystemAsyncOperation* operation) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -811,4 +824,70 @@ void PrivetFileSystemStatusOperation::TriggerCallbackAndDestroy(
container_->RemoveOperation(this);
}
+PrivetFileSystemUploadOperation::PrivetFileSystemUploadOperation(
+ const base::FilePath& full_path,
+ const base::FilePath& upload_path,
+ content::BrowserContext* browser_context,
+ PrivetFileSystemAsyncOperationContainer* container,
+ const fileapi::AsyncFileUtil::StatusCallback& callback)
+ : core_(full_path, browser_context, this),
+ full_path_(full_path),
+ upload_path_(upload_path),
+ container_(container),
+ callback_(callback) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+}
+
+PrivetFileSystemUploadOperation::~PrivetFileSystemUploadOperation() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+}
+
+void PrivetFileSystemUploadOperation::Start() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ core_.Start();
+}
+
+void PrivetFileSystemUploadOperation::PrivetFileSystemResolved(
+ PrivetHTTPClient* http_client,
+ const std::string& path) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (!http_client) {
+ SignalError();
+ return;
+ }
+
+ overwrite_operation_ = http_client->CreateStorageOverwriteOperation(
+ path,
+ base::Bind(&PrivetFileSystemUploadOperation::OnStorageOverwriteResult,
+ base::Unretained(this)));
+ overwrite_operation_->SetUploadFile(upload_path_);
+ overwrite_operation_->Start();
+}
+
+void PrivetFileSystemUploadOperation::OnStorageOverwriteResult(
+ PrivetDataReadOperation::ResponseType result_type,
+ const std::string& data,
+ const base::FilePath& file) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ if (result_type == PrivetDataReadOperation::RESPONSE_TYPE_ERROR) {
+ SignalError();
+ } else {
+ TriggerCallbackAndDestroy(base::File::FILE_OK);
+ }
+}
+
+void PrivetFileSystemUploadOperation::SignalError() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ TriggerCallbackAndDestroy(base::File::FILE_ERROR_FAILED);
+}
+
+void PrivetFileSystemUploadOperation::TriggerCallbackAndDestroy(
+ base::File::Error result) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE, base::Bind(callback_, result));
+ container_->RemoveOperation(this);
+}
+
} // namespace local_discovery
« no previous file with comments | « chrome/browser/local_discovery/storage/privet_filesystem_operations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698