| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/file_manager/private_api_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
| 6 | 6 |
| 7 #include <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
| 8 | 8 |
| 9 #include "base/posix/eintr_wrapper.h" | 9 #include "base/posix/eintr_wrapper.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 file_system_context->operation_runner()->Cancel( | 224 file_system_context->operation_runner()->Cancel( |
| 225 operation_id, base::Bind(&OnCopyCancelled)); | 225 operation_id, base::Bind(&OnCopyCancelled)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace | 228 } // namespace |
| 229 | 229 |
| 230 void FileBrowserPrivateRequestFileSystemFunction::DidFail( | 230 void FileBrowserPrivateRequestFileSystemFunction::DidFail( |
| 231 base::File::Error error_code) { | 231 base::File::Error error_code) { |
| 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 233 | 233 |
| 234 error_ = base::StringPrintf("File error %d", static_cast<int>(error_code)); | 234 SetError(base::StringPrintf("File error %d", static_cast<int>(error_code))); |
| 235 SendResponse(false); | 235 SendResponse(false); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool FileBrowserPrivateRequestFileSystemFunction:: | 238 bool FileBrowserPrivateRequestFileSystemFunction:: |
| 239 SetupFileSystemAccessPermissions( | 239 SetupFileSystemAccessPermissions( |
| 240 scoped_refptr<fileapi::FileSystemContext> file_system_context, | 240 scoped_refptr<fileapi::FileSystemContext> file_system_context, |
| 241 int child_id, | 241 int child_id, |
| 242 scoped_refptr<const extensions::Extension> extension) { | 242 scoped_refptr<const extensions::Extension> extension) { |
| 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 244 | 244 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 bool FileBrowserPrivateStartCopyFunction::RunImpl() { | 514 bool FileBrowserPrivateStartCopyFunction::RunImpl() { |
| 515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 516 | 516 |
| 517 using extensions::api::file_browser_private::StartCopy::Params; | 517 using extensions::api::file_browser_private::StartCopy::Params; |
| 518 const scoped_ptr<Params> params(Params::Create(*args_)); | 518 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 519 EXTENSION_FUNCTION_VALIDATE(params); | 519 EXTENSION_FUNCTION_VALIDATE(params); |
| 520 | 520 |
| 521 if (params->source_url.empty() || params->parent.empty() || | 521 if (params->source_url.empty() || params->parent.empty() || |
| 522 params->new_name.empty()) { | 522 params->new_name.empty()) { |
| 523 // Error code in format of DOMError.name. | 523 // Error code in format of DOMError.name. |
| 524 error_ = "EncodingError"; | 524 SetError("EncodingError"); |
| 525 return false; | 525 return false; |
| 526 } | 526 } |
| 527 | 527 |
| 528 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 528 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
| 529 file_manager::util::GetFileSystemContextForRenderViewHost( | 529 file_manager::util::GetFileSystemContextForRenderViewHost( |
| 530 GetProfile(), render_view_host()); | 530 GetProfile(), render_view_host()); |
| 531 | 531 |
| 532 fileapi::FileSystemURL source_url( | 532 fileapi::FileSystemURL source_url( |
| 533 file_system_context->CrackURL(GURL(params->source_url))); | 533 file_system_context->CrackURL(GURL(params->source_url))); |
| 534 fileapi::FileSystemURL destination_url(file_system_context->CrackURL( | 534 fileapi::FileSystemURL destination_url(file_system_context->CrackURL( |
| 535 GURL(params->parent + "/" + params->new_name))); | 535 GURL(params->parent + "/" + params->new_name))); |
| 536 | 536 |
| 537 if (!source_url.is_valid() || !destination_url.is_valid()) { | 537 if (!source_url.is_valid() || !destination_url.is_valid()) { |
| 538 // Error code in format of DOMError.name. | 538 // Error code in format of DOMError.name. |
| 539 error_ = "EncodingError"; | 539 SetError("EncodingError"); |
| 540 return false; | 540 return false; |
| 541 } | 541 } |
| 542 | 542 |
| 543 return BrowserThread::PostTaskAndReplyWithResult( | 543 return BrowserThread::PostTaskAndReplyWithResult( |
| 544 BrowserThread::IO, | 544 BrowserThread::IO, |
| 545 FROM_HERE, | 545 FROM_HERE, |
| 546 base::Bind(&StartCopyOnIOThread, | 546 base::Bind(&StartCopyOnIOThread, |
| 547 GetProfile(), | 547 GetProfile(), |
| 548 file_system_context, | 548 file_system_context, |
| 549 source_url, | 549 source_url, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 574 // We don't much take care about the result of cancellation. | 574 // We don't much take care about the result of cancellation. |
| 575 BrowserThread::PostTask( | 575 BrowserThread::PostTask( |
| 576 BrowserThread::IO, | 576 BrowserThread::IO, |
| 577 FROM_HERE, | 577 FROM_HERE, |
| 578 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); | 578 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); |
| 579 SendResponse(true); | 579 SendResponse(true); |
| 580 return true; | 580 return true; |
| 581 } | 581 } |
| 582 | 582 |
| 583 } // namespace extensions | 583 } // namespace extensions |
| OLD | NEW |