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

Side by Side Diff: chrome/browser/chromeos/drive/download_handler.cc

Issue 15768004: drive: Rename drive::DriveFileSystemTest to drive::FileSystemTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
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/drive/download_handler.h" 5 #include "chrome/browser/chromeos/drive/download_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/supports_user_data.h" 9 #include "base/supports_user_data.h"
10 #include "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 SetDownloadParams(drive_path, download); 140 SetDownloadParams(drive_path, download);
141 141
142 if (util::IsUnderDriveMountPoint(drive_path)) { 142 if (util::IsUnderDriveMountPoint(drive_path)) {
143 // Can't access drive if the directory does not exist on Drive. 143 // Can't access drive if the directory does not exist on Drive.
144 // We set off a chain of callbacks as follows: 144 // We set off a chain of callbacks as follows:
145 // FileSystem::GetResourceEntryByPath 145 // FileSystem::GetResourceEntryByPath
146 // OnEntryFound calls FileSystem::CreateDirectory (if necessary) 146 // OnEntryFound calls FileSystem::CreateDirectory (if necessary)
147 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal 147 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal
148 const base::FilePath drive_dir_path = 148 const base::FilePath drive_dir_path =
149 util::ExtractDrivePath(drive_path.DirName()); 149 util::ExtractDrivePath(drive_path.DirName());
150 // Ensure the directory exists. This also forces FileSystem to 150 // Check if the directory exists, and create it if the directory does not
151 // initialize DriveRootDirectory. 151 // exist.
152 file_system_->GetResourceEntryByPath( 152 file_system_->GetResourceEntryByPath(
153 drive_dir_path, 153 drive_dir_path,
154 base::Bind(&DownloadHandler::OnEntryFound, 154 base::Bind(&DownloadHandler::OnEntryFound,
155 weak_ptr_factory_.GetWeakPtr(), 155 weak_ptr_factory_.GetWeakPtr(),
156 drive_dir_path, 156 drive_dir_path,
157 callback)); 157 callback));
158 } else { 158 } else {
159 callback.Run(drive_path); 159 callback.Run(drive_path);
160 } 160 }
161 } 161 }
(...skipping 19 matching lines...) Expand all
181 const DownloadItem* download) { 181 const DownloadItem* download) {
182 const DriveUserData* data = GetDriveUserData(download); 182 const DriveUserData* data = GetDriveUserData(download);
183 // If data is NULL, we've somehow lost the drive path selected by the file 183 // If data is NULL, we've somehow lost the drive path selected by the file
184 // picker. 184 // picker.
185 DCHECK(data); 185 DCHECK(data);
186 return data ? data->file_path() : base::FilePath(); 186 return data ? data->file_path() : base::FilePath();
187 } 187 }
188 188
189 bool DownloadHandler::IsDriveDownload(const DownloadItem* download) { 189 bool DownloadHandler::IsDriveDownload(const DownloadItem* download) {
190 // We use the existence of the DriveUserData object in download as a 190 // We use the existence of the DriveUserData object in download as a
191 // signal that this is a DriveDownload. 191 // signal that this is a download to Drive.
192 return GetDriveUserData(download) != NULL; 192 return GetDriveUserData(download) != NULL;
193 } 193 }
194 194
195 void DownloadHandler::CheckForFileExistence( 195 void DownloadHandler::CheckForFileExistence(
196 const DownloadItem* download, 196 const DownloadItem* download,
197 const content::CheckForFileExistenceCallback& callback) { 197 const content::CheckForFileExistenceCallback& callback) {
198 file_system_->GetResourceEntryByPath( 198 file_system_->GetResourceEntryByPath(
199 util::ExtractDrivePath(GetTargetPath(download)), 199 util::ExtractDrivePath(GetTargetPath(download)),
200 base::Bind(&ContinueCheckingForFileExistence, 200 base::Bind(&ContinueCheckingForFileExistence,
201 callback)); 201 callback));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 297
298 void DownloadHandler::UploadDownloadItem(DownloadItem* download) { 298 void DownloadHandler::UploadDownloadItem(DownloadItem* download) {
299 DCHECK(download->IsComplete()); 299 DCHECK(download->IsComplete());
300 file_write_helper_->PrepareWritableFileAndRun( 300 file_write_helper_->PrepareWritableFileAndRun(
301 util::ExtractDrivePath(GetTargetPath(download)), 301 util::ExtractDrivePath(GetTargetPath(download)),
302 base::Bind(&MoveDownloadedFile, download->GetTargetFilePath())); 302 base::Bind(&MoveDownloadedFile, download->GetTargetFilePath()));
303 } 303 }
304 304
305 } // namespace drive 305 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/debug_info_collector.cc ('k') | chrome/browser/chromeos/drive/drive_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698