| Index: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
|
| diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
|
| index b7b52fac6cfea2125c6d5f1404114165293f3e4c..8614f9a9e07caecf44344c11486472d81b64acfc 100644
|
| --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
|
| +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
|
| @@ -34,6 +34,7 @@
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/common/url_constants.h"
|
| #include "net/base/escape.h"
|
| +#include "storage/browser/blob/file_stream_reader.h"
|
| #include "storage/browser/fileapi/file_system_context.h"
|
| #include "storage/browser/fileapi/file_system_file_util.h"
|
| #include "storage/browser/fileapi/file_system_operation_context.h"
|
| @@ -713,13 +714,22 @@ void FileManagerPrivateInternalResolveIsolatedEntriesFunction::
|
| SendResponse(true);
|
| }
|
|
|
| +FileManagerPrivateComputeChecksumFunction::
|
| + FileManagerPrivateComputeChecksumFunction()
|
| + : digester_(new drive::util::FileStreamMd5Digester()) {
|
| +}
|
| +
|
| +FileManagerPrivateComputeChecksumFunction::
|
| + ~FileManagerPrivateComputeChecksumFunction() {
|
| +}
|
| +
|
| bool FileManagerPrivateComputeChecksumFunction::RunAsync() {
|
| using extensions::api::file_manager_private::ComputeChecksum::Params;
|
| const scoped_ptr<Params> params(Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params);
|
|
|
| if (params->file_url.empty()) {
|
| - // TODO(kenobi): call SetError()
|
| + SetError("File URL must be provided");
|
| return false;
|
| }
|
|
|
| @@ -730,13 +740,13 @@ bool FileManagerPrivateComputeChecksumFunction::RunAsync() {
|
| storage::FileSystemURL file_url(
|
| file_system_context->CrackURL(GURL(params->file_url)));
|
| if (!file_url.is_valid()) {
|
| - // TODO(kenobi): Call SetError()
|
| + SetError("File URL was invalid");
|
| return false;
|
| }
|
|
|
| - BrowserThread::PostTaskAndReplyWithResult(
|
| - BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&drive::util::GetMd5Digest, file_url.path()),
|
| + digester_->GetMd5Digest(
|
| + file_system_context->CreateFileStreamReader(
|
| + file_url, 0, storage::kMaximumLength, base::Time()),
|
| base::Bind(&FileManagerPrivateComputeChecksumFunction::Respond, this));
|
|
|
| return true;
|
| @@ -744,6 +754,7 @@ bool FileManagerPrivateComputeChecksumFunction::RunAsync() {
|
|
|
| void FileManagerPrivateComputeChecksumFunction::Respond(
|
| const std::string& hash) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| SetResult(new base::StringValue(hash));
|
| SendResponse(true);
|
| }
|
|
|