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

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

Issue 622513002: Create a cache file before mounting zip file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/private_api_mount.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_mount.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (path.empty()) 66 if (path.empty())
67 return false; 67 return false;
68 68
69 // Check if the source path is under Drive cache directory. 69 // Check if the source path is under Drive cache directory.
70 if (drive::util::IsUnderDriveMountPoint(path)) { 70 if (drive::util::IsUnderDriveMountPoint(path)) {
71 drive::FileSystemInterface* file_system = 71 drive::FileSystemInterface* file_system =
72 drive::util::GetFileSystemByProfile(GetProfile()); 72 drive::util::GetFileSystemByProfile(GetProfile());
73 if (!file_system) 73 if (!file_system)
74 return false; 74 return false;
75 75
76 file_system->MarkCacheFileAsMounted( 76 // Ensure that the cache file exists.
77 drive::util::ExtractDrivePath(path), 77 const base::FilePath drive_path = drive::util::ExtractDrivePath(path);
78 base::Bind( 78 file_system->GetFile(
79 &FileManagerPrivateAddMountFunction::RunAfterMarkCacheFileAsMounted, 79 drive_path,
80 this, path.BaseName())); 80 base::Bind(&FileManagerPrivateAddMountFunction::RunAfterGetDriveFile,
81 this,
82 drive_path));
81 } else { 83 } else {
82 file_manager::VolumeManager* volume_manager = 84 file_manager::VolumeManager* volume_manager =
83 file_manager::VolumeManager::Get(GetProfile()); 85 file_manager::VolumeManager::Get(GetProfile());
84 DCHECK(volume_manager); 86 DCHECK(volume_manager);
85 87
86 bool is_under_downloads = false; 88 bool is_under_downloads = false;
87 const std::vector<file_manager::VolumeInfo> volumes = 89 const std::vector<file_manager::VolumeInfo> volumes =
88 volume_manager->GetVolumeInfoList(); 90 volume_manager->GetVolumeInfoList();
89 for (size_t i = 0; i < volumes.size(); ++i) { 91 for (size_t i = 0; i < volumes.size(); ++i) {
90 if (volumes[i].type == file_manager::VOLUME_TYPE_DOWNLOADS_DIRECTORY && 92 if (volumes[i].type == file_manager::VOLUME_TYPE_DOWNLOADS_DIRECTORY &&
(...skipping 16 matching lines...) Expand all
107 this, 109 this,
108 path.BaseName())))); 110 path.BaseName()))));
109 } else { 111 } else {
110 RunAfterMarkCacheFileAsMounted( 112 RunAfterMarkCacheFileAsMounted(
111 path.BaseName(), drive::FILE_ERROR_OK, path); 113 path.BaseName(), drive::FILE_ERROR_OK, path);
112 } 114 }
113 } 115 }
114 return true; 116 return true;
115 } 117 }
116 118
119 void FileManagerPrivateAddMountFunction::RunAfterGetDriveFile(
120 const base::FilePath& drive_path,
121 drive::FileError error,
122 const base::FilePath& cache_path,
123 scoped_ptr<drive::ResourceEntry> entry) {
124 DCHECK_CURRENTLY_ON(BrowserThread::UI);
125
126 if (error != drive::FILE_ERROR_OK) {
127 SendResponse(false);
128 return;
129 }
130
131 drive::FileSystemInterface* const file_system =
132 drive::util::GetFileSystemByProfile(GetProfile());
133 if (!file_system) {
134 SendResponse(false);
135 return;
136 }
137
138 file_system->MarkCacheFileAsMounted(
139 drive_path,
140 base::Bind(
141 &FileManagerPrivateAddMountFunction::RunAfterMarkCacheFileAsMounted,
142 this,
143 drive_path.BaseName()));
144 }
145
117 void FileManagerPrivateAddMountFunction::RunAfterMarkCacheFileAsMounted( 146 void FileManagerPrivateAddMountFunction::RunAfterMarkCacheFileAsMounted(
118 const base::FilePath& display_name, 147 const base::FilePath& display_name,
119 drive::FileError error, 148 drive::FileError error,
120 const base::FilePath& file_path) { 149 const base::FilePath& file_path) {
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
122 151
123 if (error != drive::FILE_ERROR_OK) { 152 if (error != drive::FILE_ERROR_OK) {
124 SendResponse(false); 153 SendResponse(false);
125 return; 154 return;
126 } 155 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 result.size()); 251 result.size());
223 } 252 }
224 253
225 results_ = 254 results_ =
226 file_manager_private::GetVolumeMetadataList::Results::Create(result); 255 file_manager_private::GetVolumeMetadataList::Results::Create(result);
227 SendResponse(true); 256 SendResponse(true);
228 return true; 257 return true;
229 } 258 }
230 259
231 } // namespace extensions 260 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/private_api_mount.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698