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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 840843002: Expose computation of md5 content checksums for files via a file manager private API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/drive/drive.pb.h" 15 #include "chrome/browser/chromeos/drive/drive.pb.h"
16 #include "chrome/browser/chromeos/drive/file_system_interface.h" 16 #include "chrome/browser/chromeos/drive/file_system_interface.h"
17 #include "chrome/browser/chromeos/drive/file_system_util.h" 17 #include "chrome/browser/chromeos/drive/file_system_util.h"
18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" 18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
19 #include "chrome/browser/chromeos/extensions/file_manager/event_router_factory.h " 19 #include "chrome/browser/chromeos/extensions/file_manager/event_router_factory.h "
20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
22 #include "chrome/browser/chromeos/file_manager/volume_manager.h" 22 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" 23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
24 #include "chrome/browser/drive/drive_api_util.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/common/extensions/api/file_manager_private.h" 27 #include "chrome/common/extensions/api/file_manager_private.h"
27 #include "chrome/common/extensions/api/file_manager_private_internal.h" 28 #include "chrome/common/extensions/api/file_manager_private_internal.h"
28 #include "chromeos/disks/disk_mount_manager.h" 29 #include "chromeos/disks/disk_mount_manager.h"
29 #include "content/public/browser/child_process_security_policy.h" 30 #include "content/public/browser/child_process_security_policy.h"
30 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/common/url_constants.h" 33 #include "content/public/common/url_constants.h"
33 #include "net/base/escape.h" 34 #include "net/base/escape.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 entry->file_full_path = 703 entry->file_full_path =
703 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe(); 704 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe();
704 entry->file_is_directory = entry_definition_list->at(i).is_directory; 705 entry->file_is_directory = entry_definition_list->at(i).is_directory;
705 entries.push_back(entry); 706 entries.push_back(entry);
706 } 707 }
707 708
708 results_ = extensions::api::file_manager_private_internal:: 709 results_ = extensions::api::file_manager_private_internal::
709 ResolveIsolatedEntries::Results::Create(entries); 710 ResolveIsolatedEntries::Results::Create(entries);
710 SendResponse(true); 711 SendResponse(true);
711 } 712 }
713
714 bool FileManagerPrivateComputeChecksumFunction::RunAsync() {
715 using extensions::api::file_manager_private::ComputeChecksum::Params;
716 const scoped_ptr<Params> params(Params::Create(*args_));
717 EXTENSION_FUNCTION_VALIDATE(params);
718
719 if (params->file_url.empty()) {
720 // TODO(kenobi): call SetError()
721 return false;
722 }
723
724 scoped_refptr<storage::FileSystemContext> file_system_context =
725 file_manager::util::GetFileSystemContextForRenderViewHost(
726 GetProfile(), render_view_host());
727
728 storage::FileSystemURL file_url(
729 file_system_context->CrackURL(GURL(params->file_url)));
730 if (!file_url.is_valid()) {
731 // TODO(kenobi): Call SetError()
732 return false;
733 }
734
735 const std::string& md5 = drive::util::GetMd5Digest(file_url.path());
mtomasz 2015/01/08 00:38:40 This utility makes file IO, it must not be called
Ben Kwa 2015/01/08 19:29:14 Interesting, the doc for AsyncExtensionFunction ma
mtomasz 2015/01/09 05:19:02 The comment sounds very cryptic. IIUC AsyncExtensi
736 SetResult(new base::StringValue(md5));
737 SendResponse(true);
738
739 return true;
740 }
712 } // namespace extensions 741 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698