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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 10008100: gdata: Support mouting archive file in GData cache (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Support mounting archive files under GData cache Created 8 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_browser_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 const std::string& mount_type_str, 994 const std::string& mount_type_str,
995 const SelectedFileInfoList& files) { 995 const SelectedFileInfoList& files) {
996 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 996 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
997 997
998 if (!files.size()) { 998 if (!files.size()) {
999 SendResponse(false); 999 SendResponse(false);
1000 return; 1000 return;
1001 } 1001 }
1002 1002
1003 #if defined(OS_CHROMEOS) 1003 #if defined(OS_CHROMEOS)
1004 FilePath source_file = files[0].path; 1004 const FilePath& source_path = files[0].path;
1005 const std::string& display_name = files[0].display_name;
Ben Chan 2012/04/17 20:57:53 const FilePath::StringType&
1006 // check if the source path is under GData cache directory
1007 gdata::GDataSystemService* system_service =
1008 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1009 if (system_service && system_service->file_system() &&
1010 system_service->file_system()->IsUnderGDataCacheDirectory(source_path)) {
tbarzic 2012/04/17 21:33:13 are you sure this is ever satisfied? afaik |files|
tbarzic 2012/04/17 21:51:04 Ok, looks like this changed recently :) ignore the
1011 system_service->file_system()->SetMountedState(source_path, display_name,
1012 mount_type_str, base::Bind(&AddMountFunction::OnMountedStateSet, this));
1013 } else {
1014 OnMountedStateSet(base::PLATFORM_FILE_OK, source_path, std::string(),
1015 mount_type_str);
1016 }
1017 #else
1018 SendResponse(true);
1019 #endif // defined(OS_CHROMEOS)
1020 }
1021
1022 void AddMountFunction::OnMountedStateSet(base::PlatformFileError error,
Ben Chan 2012/04/17 20:57:53 seems like this method is only used on Chrome OS,
tbarzic 2012/04/17 21:33:13 actually, whole file is used only on chromeos.. bu
1023 const FilePath& file_path,
1024 const std::string& file_name,
1025 const std::string& mount_type) {
1026 #if defined(OS_CHROMEOS)
1027 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1005 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); 1028 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
1006 // MountPath() takes a std::string. 1029 // MountPath() takes a std::string.
1007 disk_mount_manager->MountPath(source_file.AsUTF8Unsafe(), 1030 disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), file_name,
Ben Chan 2012/04/17 20:57:53 passing file_name as the second argument to MountP
1008 DiskMountManager::MountTypeFromString(mount_type_str)); 1031 DiskMountManager::MountTypeFromString(mount_type));
1009 #endif // defined(OS_CHROMEOS) 1032 #endif // defined(OS_CHROMEOS)
1010 1033
1011 SendResponse(true); 1034 SendResponse(true);
1012 } 1035 }
1013 1036
1014 RemoveMountFunction::RemoveMountFunction() { 1037 RemoveMountFunction::RemoveMountFunction() {
1015 } 1038 }
1016 1039
1017 RemoveMountFunction::~RemoveMountFunction() { 1040 RemoveMountFunction::~RemoveMountFunction() {
1018 } 1041 }
(...skipping 18 matching lines...) Expand all
1037 1060
1038 void RemoveMountFunction::GetLocalPathsResponseOnUIThread( 1061 void RemoveMountFunction::GetLocalPathsResponseOnUIThread(
1039 const SelectedFileInfoList& files) { 1062 const SelectedFileInfoList& files) {
1040 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1063 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1041 1064
1042 if (files.size() != 1) { 1065 if (files.size() != 1) {
1043 SendResponse(false); 1066 SendResponse(false);
1044 return; 1067 return;
1045 } 1068 }
1046 #if defined(OS_CHROMEOS) 1069 #if defined(OS_CHROMEOS)
1047 DiskMountManager::GetInstance()->UnmountPath(files[0].path.value()); 1070 // look up source path from mount path
1071 const std::string& mount_path = files[0].path.value();
1072 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
1073 DiskMountManager::MountPointMap mount_points =
1074 disk_mount_manager->mount_points();
1075 DiskMountManager::MountPointMap::const_iterator it =
1076 mount_points.find(mount_path);
1077 if (it == mount_points.end()) {
1078 SendResponse(false);
1079 return;
1080 }
1081 DiskMountManager::MountPointInfo mount_point_info = it->second;
1082 FilePath source_path = FilePath(mount_point_info.source_path);
1083 // unmount archive
1084 disk_mount_manager->UnmountPath(mount_path);
1085 // check if the source path is under GData cache directory
tbarzic 2012/04/17 21:33:13 Comments have to end with . Also, they have to beg
1086 gdata::GDataSystemService* system_service =
1087 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1088 if (system_service && system_service->file_system() &&
1089 system_service->file_system()->IsUnderGDataCacheDirectory(source_path)) {
1090 system_service->file_system()->ClearMountedState(source_path, base::Bind(
Ben Chan 2012/04/17 20:57:53 nit: line break before base::Bind
1091 &RemoveMountFunction::OnMountedStateCleared, this));
1092 } else {
1093 OnMountedStateCleared(base::PLATFORM_FILE_OK);
1094 }
1095 #else
1096 SendResponse(true);
1048 #endif 1097 #endif
1098 }
1049 1099
1100 void RemoveMountFunction::OnMountedStateCleared(base::PlatformFileError error) {
1050 SendResponse(true); 1101 SendResponse(true);
1051 } 1102 }
1052 1103
1053 GetMountPointsFunction::GetMountPointsFunction() { 1104 GetMountPointsFunction::GetMountPointsFunction() {
1054 } 1105 }
1055 1106
1056 GetMountPointsFunction::~GetMountPointsFunction() { 1107 GetMountPointsFunction::~GetMountPointsFunction() {
1057 } 1108 }
1058 1109
1059 bool GetMountPointsFunction::RunImpl() { 1110 bool GetMountPointsFunction::RunImpl() {
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 if (value->GetBoolean("cellularDisabled", &tmp)) { 2023 if (value->GetBoolean("cellularDisabled", &tmp)) {
1973 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 2024 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
1974 } 2025 }
1975 2026
1976 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 2027 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
1977 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 2028 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
1978 } 2029 }
1979 2030
1980 return true; 2031 return true;
1981 } 2032 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698