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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_file_system_proxy.cc

Issue 10870040: Rename FileSystemOperationInterface to FileSystemOperation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing Created 8 years, 3 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/gdata/drive_file_system_proxy.h" 5 #include "chrome/browser/chromeos/gdata/drive_file_system_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/chromeos/gdata/drive.pb.h" 14 #include "chrome/browser/chromeos/gdata/drive.pb.h"
15 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" 15 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
16 #include "chrome/browser/chromeos/gdata/drive_files.h" 16 #include "chrome/browser/chromeos/gdata/drive_files.h"
17 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 17 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
18 #include "chrome/browser/chromeos/gdata/gdata_util.h" 18 #include "chrome/browser/chromeos/gdata/gdata_util.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "webkit/blob/shareable_file_reference.h" 20 #include "webkit/blob/shareable_file_reference.h"
21 #include "webkit/fileapi/file_system_file_util_proxy.h" 21 #include "webkit/fileapi/file_system_file_util_proxy.h"
22 #include "webkit/fileapi/file_system_types.h" 22 #include "webkit/fileapi/file_system_types.h"
23 #include "webkit/fileapi/file_system_url.h" 23 #include "webkit/fileapi/file_system_url.h"
24 #include "webkit/fileapi/file_system_util.h" 24 #include "webkit/fileapi/file_system_util.h"
25 25
26 using base::MessageLoopProxy; 26 using base::MessageLoopProxy;
27 using content::BrowserThread; 27 using content::BrowserThread;
28 using fileapi::FileSystemURL; 28 using fileapi::FileSystemURL;
29 using fileapi::FileSystemOperationInterface; 29 using fileapi::FileSystemOperation;
30 using webkit_blob::ShareableFileReference; 30 using webkit_blob::ShareableFileReference;
31 31
32 namespace gdata { 32 namespace gdata {
33 33
34 namespace { 34 namespace {
35 35
36 const char kDriveRootDirectory[] = "drive"; 36 const char kDriveRootDirectory[] = "drive";
37 const char kFeedField[] = "feed"; 37 const char kFeedField[] = "feed";
38 38
39 // Helper function that creates platform file on blocking IO thread pool. 39 // Helper function that creates platform file on blocking IO thread pool.
40 void OpenPlatformFileOnIOPool(const FilePath& local_path, 40 void OpenPlatformFileOnIOPool(const FilePath& local_path,
41 int file_flags, 41 int file_flags,
42 base::PlatformFile* platform_file, 42 base::PlatformFile* platform_file,
43 base::PlatformFileError* open_error) { 43 base::PlatformFileError* open_error) {
44 bool created; 44 bool created;
45 *platform_file = base::CreatePlatformFile(local_path, 45 *platform_file = base::CreatePlatformFile(local_path,
46 file_flags, 46 file_flags,
47 &created, 47 &created,
48 open_error); 48 open_error);
49 } 49 }
50 50
51 // Helper function to run reply on results of OpenPlatformFileOnIOPool() on 51 // Helper function to run reply on results of OpenPlatformFileOnIOPool() on
52 // IO thread. 52 // IO thread.
53 void OnPlatformFileOpened( 53 void OnPlatformFileOpened(
54 const FileSystemOperationInterface::OpenFileCallback& callback, 54 const FileSystemOperation::OpenFileCallback& callback,
55 base::ProcessHandle peer_handle, 55 base::ProcessHandle peer_handle,
56 base::PlatformFile* platform_file, 56 base::PlatformFile* platform_file,
57 base::PlatformFileError* open_error) { 57 base::PlatformFileError* open_error) {
58 callback.Run(*open_error, *platform_file, peer_handle); 58 callback.Run(*open_error, *platform_file, peer_handle);
59 } 59 }
60 60
61 // Helper function to run OpenFileCallback from 61 // Helper function to run OpenFileCallback from
62 // DriveFileSystemProxy::OpenFile(). 62 // DriveFileSystemProxy::OpenFile().
63 void OnGetFileByPathForOpen( 63 void OnGetFileByPathForOpen(
64 const FileSystemOperationInterface::OpenFileCallback& callback, 64 const FileSystemOperation::OpenFileCallback& callback,
65 int file_flags, 65 int file_flags,
66 base::ProcessHandle peer_handle, 66 base::ProcessHandle peer_handle,
67 DriveFileError file_error, 67 DriveFileError file_error,
68 const FilePath& local_path, 68 const FilePath& local_path,
69 const std::string& unused_mime_type, 69 const std::string& unused_mime_type,
70 DriveFileType file_type) { 70 DriveFileType file_type) {
71 base::PlatformFileError error = 71 base::PlatformFileError error =
72 util::DriveFileErrorToPlatformError(file_error); 72 util::DriveFileErrorToPlatformError(file_error);
73 if (error != base::PLATFORM_FILE_OK) { 73 if (error != base::PLATFORM_FILE_OK) {
74 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); 74 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle);
(...skipping 13 matching lines...) Expand all
88 base::Bind(&OnPlatformFileOpened, 88 base::Bind(&OnPlatformFileOpened,
89 callback, 89 callback,
90 peer_handle, 90 peer_handle,
91 base::Owned(platform_file), 91 base::Owned(platform_file),
92 base::Owned(open_error))); 92 base::Owned(open_error)));
93 } 93 }
94 94
95 // Helper function to run SnapshotFileCallback from 95 // Helper function to run SnapshotFileCallback from
96 // DriveFileSystemProxy::CreateSnapshotFile(). 96 // DriveFileSystemProxy::CreateSnapshotFile().
97 void CallSnapshotFileCallback( 97 void CallSnapshotFileCallback(
98 const FileSystemOperationInterface::SnapshotFileCallback& callback, 98 const FileSystemOperation::SnapshotFileCallback& callback,
99 const base::PlatformFileInfo& file_info, 99 const base::PlatformFileInfo& file_info,
100 DriveFileError file_error, 100 DriveFileError file_error,
101 const FilePath& local_path, 101 const FilePath& local_path,
102 const std::string& unused_mime_type, 102 const std::string& unused_mime_type,
103 DriveFileType file_type) { 103 DriveFileType file_type) {
104 scoped_refptr<ShareableFileReference> file_ref; 104 scoped_refptr<ShareableFileReference> file_ref;
105 base::PlatformFileError error = 105 base::PlatformFileError error =
106 util::DriveFileErrorToPlatformError(file_error); 106 util::DriveFileErrorToPlatformError(file_error);
107 107
108 // If the file is a hosted document, a temporary JSON file is created to 108 // If the file is a hosted document, a temporary JSON file is created to
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 result); 145 result);
146 if (*result == base::PLATFORM_FILE_OK) { 146 if (*result == base::PLATFORM_FILE_OK) {
147 DCHECK_NE(base::kInvalidPlatformFileValue, file); 147 DCHECK_NE(base::kInvalidPlatformFileValue, file);
148 if (!base::TruncatePlatformFile(file, length)) 148 if (!base::TruncatePlatformFile(file, length))
149 *result = base::PLATFORM_FILE_ERROR_FAILED; 149 *result = base::PLATFORM_FILE_ERROR_FAILED;
150 base::ClosePlatformFile(file); 150 base::ClosePlatformFile(file);
151 } 151 }
152 } 152 }
153 153
154 void DidCloseFileForTruncate( 154 void DidCloseFileForTruncate(
155 const FileSystemOperationInterface::StatusCallback& callback, 155 const FileSystemOperation::StatusCallback& callback,
156 base::PlatformFileError truncate_result, 156 base::PlatformFileError truncate_result,
157 DriveFileError close_result) { 157 DriveFileError close_result) {
158 // Reports the first error. 158 // Reports the first error.
159 callback.Run(truncate_result == base::PLATFORM_FILE_OK ? 159 callback.Run(truncate_result == base::PLATFORM_FILE_OK ?
160 util::DriveFileErrorToPlatformError(close_result) : 160 util::DriveFileErrorToPlatformError(close_result) :
161 truncate_result); 161 truncate_result);
162 } 162 }
163 163
164 } // namespace 164 } // namespace
165 165
(...skipping 14 matching lines...) Expand all
180 180
181 DriveFileSystemProxy::DriveFileSystemProxy( 181 DriveFileSystemProxy::DriveFileSystemProxy(
182 DriveFileSystemInterface* file_system) 182 DriveFileSystemInterface* file_system)
183 : file_system_(file_system) { 183 : file_system_(file_system) {
184 // Should be created from the file browser extension API (AddMountFunction) 184 // Should be created from the file browser extension API (AddMountFunction)
185 // on UI thread. 185 // on UI thread.
186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
187 } 187 }
188 188
189 void DriveFileSystemProxy::GetFileInfo(const FileSystemURL& file_url, 189 void DriveFileSystemProxy::GetFileInfo(const FileSystemURL& file_url,
190 const FileSystemOperationInterface::GetMetadataCallback& callback) { 190 const FileSystemOperation::GetMetadataCallback& callback) {
191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
192 FilePath file_path; 192 FilePath file_path;
193 if (!ValidateUrl(file_url, &file_path)) { 193 if (!ValidateUrl(file_url, &file_path)) {
194 MessageLoopProxy::current()->PostTask(FROM_HERE, 194 MessageLoopProxy::current()->PostTask(FROM_HERE,
195 base::Bind(callback, 195 base::Bind(callback,
196 base::PLATFORM_FILE_ERROR_NOT_FOUND, 196 base::PLATFORM_FILE_ERROR_NOT_FOUND,
197 base::PlatformFileInfo(), 197 base::PlatformFileInfo(),
198 FilePath())); 198 FilePath()));
199 return; 199 return;
200 } 200 }
201 201
202 file_system_->GetEntryInfoByPath( 202 file_system_->GetEntryInfoByPath(
203 file_path, 203 file_path,
204 base::Bind(&DriveFileSystemProxy::OnGetMetadata, 204 base::Bind(&DriveFileSystemProxy::OnGetMetadata,
205 this, 205 this,
206 file_path, 206 file_path,
207 callback)); 207 callback));
208 } 208 }
209 209
210 void DriveFileSystemProxy::Copy(const FileSystemURL& src_file_url, 210 void DriveFileSystemProxy::Copy(const FileSystemURL& src_file_url,
211 const FileSystemURL& dest_file_url, 211 const FileSystemURL& dest_file_url,
212 const FileSystemOperationInterface::StatusCallback& callback) { 212 const FileSystemOperation::StatusCallback& callback) {
213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
214 214
215 FilePath src_file_path, dest_file_path; 215 FilePath src_file_path, dest_file_path;
216 if (!ValidateUrl(src_file_url, &src_file_path) || 216 if (!ValidateUrl(src_file_url, &src_file_path) ||
217 !ValidateUrl(dest_file_url, &dest_file_path)) { 217 !ValidateUrl(dest_file_url, &dest_file_path)) {
218 MessageLoopProxy::current()->PostTask(FROM_HERE, 218 MessageLoopProxy::current()->PostTask(FROM_HERE,
219 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 219 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
220 return; 220 return;
221 } 221 }
222 222
223 file_system_->Copy( 223 file_system_->Copy(
224 src_file_path, 224 src_file_path,
225 dest_file_path, 225 dest_file_path,
226 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback)); 226 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback));
227 } 227 }
228 228
229 void DriveFileSystemProxy::Move(const FileSystemURL& src_file_url, 229 void DriveFileSystemProxy::Move(const FileSystemURL& src_file_url,
230 const FileSystemURL& dest_file_url, 230 const FileSystemURL& dest_file_url,
231 const FileSystemOperationInterface::StatusCallback& callback) { 231 const FileSystemOperation::StatusCallback& callback) {
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
233 233
234 FilePath src_file_path, dest_file_path; 234 FilePath src_file_path, dest_file_path;
235 if (!ValidateUrl(src_file_url, &src_file_path) || 235 if (!ValidateUrl(src_file_url, &src_file_path) ||
236 !ValidateUrl(dest_file_url, &dest_file_path)) { 236 !ValidateUrl(dest_file_url, &dest_file_path)) {
237 MessageLoopProxy::current()->PostTask(FROM_HERE, 237 MessageLoopProxy::current()->PostTask(FROM_HERE,
238 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 238 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
239 return; 239 return;
240 } 240 }
241 241
242 file_system_->Move( 242 file_system_->Move(
243 src_file_path, 243 src_file_path,
244 dest_file_path, 244 dest_file_path,
245 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback)); 245 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback));
246 } 246 }
247 247
248 void DriveFileSystemProxy::ReadDirectory(const FileSystemURL& file_url, 248 void DriveFileSystemProxy::ReadDirectory(const FileSystemURL& file_url,
249 const FileSystemOperationInterface::ReadDirectoryCallback& callback) { 249 const FileSystemOperation::ReadDirectoryCallback& callback) {
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
251 251
252 FilePath file_path; 252 FilePath file_path;
253 if (!ValidateUrl(file_url, &file_path)) { 253 if (!ValidateUrl(file_url, &file_path)) {
254 base::MessageLoopProxy::current()->PostTask( 254 base::MessageLoopProxy::current()->PostTask(
255 FROM_HERE, 255 FROM_HERE,
256 base::Bind(callback, 256 base::Bind(callback,
257 base::PLATFORM_FILE_ERROR_NOT_FOUND, 257 base::PLATFORM_FILE_ERROR_NOT_FOUND,
258 std::vector<base::FileUtilProxy::Entry>(), 258 std::vector<base::FileUtilProxy::Entry>(),
259 false)); 259 false));
260 return; 260 return;
261 } 261 }
262 262
263 file_system_->ReadDirectoryByPath( 263 file_system_->ReadDirectoryByPath(
264 file_path, 264 file_path,
265 base::Bind(&DriveFileSystemProxy::OnReadDirectory, 265 base::Bind(&DriveFileSystemProxy::OnReadDirectory,
266 this, 266 this,
267 callback)); 267 callback));
268 } 268 }
269 269
270 void DriveFileSystemProxy::Remove(const FileSystemURL& file_url, bool recursive, 270 void DriveFileSystemProxy::Remove(const FileSystemURL& file_url, bool recursive,
271 const FileSystemOperationInterface::StatusCallback& callback) { 271 const FileSystemOperation::StatusCallback& callback) {
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
273 273
274 FilePath file_path; 274 FilePath file_path;
275 if (!ValidateUrl(file_url, &file_path)) { 275 if (!ValidateUrl(file_url, &file_path)) {
276 MessageLoopProxy::current()->PostTask(FROM_HERE, 276 MessageLoopProxy::current()->PostTask(FROM_HERE,
277 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 277 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
278 return; 278 return;
279 } 279 }
280 280
281 file_system_->Remove( 281 file_system_->Remove(
282 file_path, 282 file_path,
283 recursive, 283 recursive,
284 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback)); 284 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback));
285 } 285 }
286 286
287 void DriveFileSystemProxy::CreateDirectory( 287 void DriveFileSystemProxy::CreateDirectory(
288 const FileSystemURL& file_url, 288 const FileSystemURL& file_url,
289 bool exclusive, 289 bool exclusive,
290 bool recursive, 290 bool recursive,
291 const FileSystemOperationInterface::StatusCallback& callback) { 291 const FileSystemOperation::StatusCallback& callback) {
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
293 293
294 FilePath file_path; 294 FilePath file_path;
295 if (!ValidateUrl(file_url, &file_path)) { 295 if (!ValidateUrl(file_url, &file_path)) {
296 MessageLoopProxy::current()->PostTask(FROM_HERE, 296 MessageLoopProxy::current()->PostTask(FROM_HERE,
297 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 297 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
298 return; 298 return;
299 } 299 }
300 300
301 file_system_->CreateDirectory( 301 file_system_->CreateDirectory(
302 file_path, 302 file_path,
303 exclusive, 303 exclusive,
304 recursive, 304 recursive,
305 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback)); 305 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback));
306 } 306 }
307 307
308 void DriveFileSystemProxy::CreateFile( 308 void DriveFileSystemProxy::CreateFile(
309 const FileSystemURL& file_url, 309 const FileSystemURL& file_url,
310 bool exclusive, 310 bool exclusive,
311 const FileSystemOperationInterface::StatusCallback& callback) { 311 const FileSystemOperation::StatusCallback& callback) {
312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
313 313
314 FilePath file_path; 314 FilePath file_path;
315 if (!ValidateUrl(file_url, &file_path)) { 315 if (!ValidateUrl(file_url, &file_path)) {
316 MessageLoopProxy::current()->PostTask(FROM_HERE, 316 MessageLoopProxy::current()->PostTask(FROM_HERE,
317 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 317 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
318 return; 318 return;
319 } 319 }
320 320
321 file_system_->CreateFile( 321 file_system_->CreateFile(
322 file_path, 322 file_path,
323 exclusive, 323 exclusive,
324 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback)); 324 base::Bind(&DriveFileSystemProxy::OnStatusCallback, this, callback));
325 } 325 }
326 326
327 void DriveFileSystemProxy::Truncate( 327 void DriveFileSystemProxy::Truncate(
328 const FileSystemURL& file_url, int64 length, 328 const FileSystemURL& file_url, int64 length,
329 const FileSystemOperationInterface::StatusCallback& callback) { 329 const FileSystemOperation::StatusCallback& callback) {
330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
331 331
332 if (length < 0) { 332 if (length < 0) {
333 MessageLoopProxy::current()->PostTask(FROM_HERE, 333 MessageLoopProxy::current()->PostTask(FROM_HERE,
334 base::Bind(callback, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); 334 base::Bind(callback, base::PLATFORM_FILE_ERROR_INVALID_OPERATION));
335 return; 335 return;
336 } 336 }
337 337
338 FilePath file_path; 338 FilePath file_path;
339 if (!ValidateUrl(file_url, &file_path)) { 339 if (!ValidateUrl(file_url, &file_path)) {
(...skipping 10 matching lines...) Expand all
350 base::Bind(&DriveFileSystemProxy::OnFileOpenedForTruncate, 350 base::Bind(&DriveFileSystemProxy::OnFileOpenedForTruncate,
351 this, 351 this,
352 file_path, 352 file_path,
353 length, 353 length,
354 callback)); 354 callback));
355 } 355 }
356 356
357 void DriveFileSystemProxy::OnOpenFileForWriting( 357 void DriveFileSystemProxy::OnOpenFileForWriting(
358 int file_flags, 358 int file_flags,
359 base::ProcessHandle peer_handle, 359 base::ProcessHandle peer_handle,
360 const FileSystemOperationInterface::OpenFileCallback& callback, 360 const FileSystemOperation::OpenFileCallback& callback,
361 DriveFileError file_error, 361 DriveFileError file_error,
362 const FilePath& local_cache_path) { 362 const FilePath& local_cache_path) {
363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
364 364
365 base::PlatformFileError error = 365 base::PlatformFileError error =
366 util::DriveFileErrorToPlatformError(file_error); 366 util::DriveFileErrorToPlatformError(file_error);
367 367
368 if (error != base::PLATFORM_FILE_OK) { 368 if (error != base::PLATFORM_FILE_OK) {
369 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle); 369 callback.Run(error, base::kInvalidPlatformFileValue, peer_handle);
370 return; 370 return;
(...skipping 16 matching lines...) Expand all
387 peer_handle, 387 peer_handle,
388 base::Owned(platform_file), 388 base::Owned(platform_file),
389 base::Owned(result))); 389 base::Owned(result)));
390 DCHECK(posted); 390 DCHECK(posted);
391 } 391 }
392 392
393 void DriveFileSystemProxy::OnCreateFileForOpen( 393 void DriveFileSystemProxy::OnCreateFileForOpen(
394 const FilePath& file_path, 394 const FilePath& file_path,
395 int file_flags, 395 int file_flags,
396 base::ProcessHandle peer_handle, 396 base::ProcessHandle peer_handle,
397 const FileSystemOperationInterface::OpenFileCallback& callback, 397 const FileSystemOperation::OpenFileCallback& callback,
398 DriveFileError file_error) { 398 DriveFileError file_error) {
399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
400 base::PlatformFileError create_result = 400 base::PlatformFileError create_result =
401 util::DriveFileErrorToPlatformError(file_error); 401 util::DriveFileErrorToPlatformError(file_error);
402 402
403 if ((create_result == base::PLATFORM_FILE_OK) || 403 if ((create_result == base::PLATFORM_FILE_OK) ||
404 ((create_result == base::PLATFORM_FILE_ERROR_EXISTS) && 404 ((create_result == base::PLATFORM_FILE_ERROR_EXISTS) &&
405 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS))) { 405 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS))) {
406 // If we are trying to always create an existing file, then 406 // If we are trying to always create an existing file, then
407 // if it really exists open it as truncated. 407 // if it really exists open it as truncated.
(...skipping 11 matching lines...) Expand all
419 base::Bind(&DriveFileSystemProxy::OnOpenFileForWriting, 419 base::Bind(&DriveFileSystemProxy::OnOpenFileForWriting,
420 this, 420 this,
421 file_flags, 421 file_flags,
422 peer_handle, 422 peer_handle,
423 callback)); 423 callback));
424 } 424 }
425 425
426 void DriveFileSystemProxy::OnFileOpenedForTruncate( 426 void DriveFileSystemProxy::OnFileOpenedForTruncate(
427 const FilePath& virtual_path, 427 const FilePath& virtual_path,
428 int64 length, 428 int64 length,
429 const fileapi::FileSystemOperationInterface::StatusCallback& callback, 429 const fileapi::FileSystemOperation::StatusCallback& callback,
430 DriveFileError open_result, 430 DriveFileError open_result,
431 const FilePath& local_cache_path) { 431 const FilePath& local_cache_path) {
432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
433 433
434 if (open_result != DRIVE_FILE_OK) { 434 if (open_result != DRIVE_FILE_OK) {
435 callback.Run(util::DriveFileErrorToPlatformError(open_result)); 435 callback.Run(util::DriveFileErrorToPlatformError(open_result));
436 return; 436 return;
437 } 437 }
438 438
439 // Cache file prepared for modification is available. Truncate it. 439 // Cache file prepared for modification is available. Truncate it.
(...skipping 10 matching lines...) Expand all
450 base::Bind(&DriveFileSystemProxy::DidTruncate, 450 base::Bind(&DriveFileSystemProxy::DidTruncate,
451 this, 451 this,
452 virtual_path, 452 virtual_path,
453 callback, 453 callback,
454 base::Owned(result))); 454 base::Owned(result)));
455 DCHECK(posted); 455 DCHECK(posted);
456 } 456 }
457 457
458 void DriveFileSystemProxy::DidTruncate( 458 void DriveFileSystemProxy::DidTruncate(
459 const FilePath& virtual_path, 459 const FilePath& virtual_path,
460 const FileSystemOperationInterface::StatusCallback& callback, 460 const FileSystemOperation::StatusCallback& callback,
461 base::PlatformFileError* truncate_result) { 461 base::PlatformFileError* truncate_result) {
462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
463 463
464 // Truncation finished. We must close the file no matter |truncate_result| 464 // Truncation finished. We must close the file no matter |truncate_result|
465 // indicates an error or not. 465 // indicates an error or not.
466 file_system_->CloseFile( 466 file_system_->CloseFile(
467 virtual_path, 467 virtual_path,
468 base::Bind(&DidCloseFileForTruncate, 468 base::Bind(&DidCloseFileForTruncate,
469 callback, 469 callback,
470 base::PlatformFileError(*truncate_result))); 470 base::PlatformFileError(*truncate_result)));
471 } 471 }
472 472
473 void DriveFileSystemProxy::OpenFile( 473 void DriveFileSystemProxy::OpenFile(
474 const FileSystemURL& file_url, 474 const FileSystemURL& file_url,
475 int file_flags, 475 int file_flags,
476 base::ProcessHandle peer_handle, 476 base::ProcessHandle peer_handle,
477 const FileSystemOperationInterface::OpenFileCallback& callback) { 477 const FileSystemOperation::OpenFileCallback& callback) {
478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
479 479
480 FilePath file_path; 480 FilePath file_path;
481 if (!ValidateUrl(file_url, &file_path)) { 481 if (!ValidateUrl(file_url, &file_path)) {
482 MessageLoopProxy::current()->PostTask(FROM_HERE, 482 MessageLoopProxy::current()->PostTask(FROM_HERE,
483 base::Bind(callback, 483 base::Bind(callback,
484 base::PLATFORM_FILE_ERROR_NOT_FOUND, 484 base::PLATFORM_FILE_ERROR_NOT_FOUND,
485 base::kInvalidPlatformFileValue, 485 base::kInvalidPlatformFileValue,
486 peer_handle)); 486 peer_handle));
487 return; 487 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 FilePath file_path; 549 FilePath file_path;
550 if (!ValidateUrl(url, &file_path)) 550 if (!ValidateUrl(url, &file_path))
551 return; 551 return;
552 552
553 file_system_->CloseFile(file_path, 553 file_system_->CloseFile(file_path,
554 base::Bind(&EmitDebugLogForCloseFile, file_path)); 554 base::Bind(&EmitDebugLogForCloseFile, file_path));
555 } 555 }
556 556
557 void DriveFileSystemProxy::CreateSnapshotFile( 557 void DriveFileSystemProxy::CreateSnapshotFile(
558 const FileSystemURL& file_url, 558 const FileSystemURL& file_url,
559 const FileSystemOperationInterface::SnapshotFileCallback& callback) { 559 const FileSystemOperation::SnapshotFileCallback& callback) {
560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
561 561
562 FilePath file_path; 562 FilePath file_path;
563 if (!ValidateUrl(file_url, &file_path)) { 563 if (!ValidateUrl(file_url, &file_path)) {
564 MessageLoopProxy::current()->PostTask(FROM_HERE, 564 MessageLoopProxy::current()->PostTask(FROM_HERE,
565 base::Bind(callback, 565 base::Bind(callback,
566 base::PLATFORM_FILE_ERROR_NOT_FOUND, 566 base::PLATFORM_FILE_ERROR_NOT_FOUND,
567 base::PlatformFileInfo(), 567 base::PlatformFileInfo(),
568 FilePath(), 568 FilePath(),
569 scoped_refptr<ShareableFileReference>(NULL))); 569 scoped_refptr<ShareableFileReference>(NULL)));
570 return; 570 return;
571 } 571 }
572 572
573 file_system_->GetEntryInfoByPath( 573 file_system_->GetEntryInfoByPath(
574 file_path, 574 file_path,
575 base::Bind(&DriveFileSystemProxy::OnGetEntryInfoByPath, 575 base::Bind(&DriveFileSystemProxy::OnGetEntryInfoByPath,
576 this, 576 this,
577 file_path, 577 file_path,
578 callback)); 578 callback));
579 } 579 }
580 580
581 void DriveFileSystemProxy::OnGetEntryInfoByPath( 581 void DriveFileSystemProxy::OnGetEntryInfoByPath(
582 const FilePath& entry_path, 582 const FilePath& entry_path,
583 const FileSystemOperationInterface::SnapshotFileCallback& callback, 583 const FileSystemOperation::SnapshotFileCallback& callback,
584 DriveFileError error, 584 DriveFileError error,
585 scoped_ptr<DriveEntryProto> entry_proto) { 585 scoped_ptr<DriveEntryProto> entry_proto) {
586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
587 587
588 if (error != DRIVE_FILE_OK || !entry_proto.get()) { 588 if (error != DRIVE_FILE_OK || !entry_proto.get()) {
589 MessageLoopProxy::current()->PostTask(FROM_HERE, 589 MessageLoopProxy::current()->PostTask(FROM_HERE,
590 base::Bind(callback, 590 base::Bind(callback,
591 base::PLATFORM_FILE_ERROR_NOT_FOUND, 591 base::PLATFORM_FILE_ERROR_NOT_FOUND,
592 base::PlatformFileInfo(), 592 base::PlatformFileInfo(),
593 FilePath(), 593 FilePath(),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 const FileSystemURL& url, FilePath* file_path) { 640 const FileSystemURL& url, FilePath* file_path) {
641 // what platform you're on. 641 // what platform you're on.
642 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) { 642 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) {
643 return false; 643 return false;
644 } 644 }
645 *file_path = url.virtual_path(); 645 *file_path = url.virtual_path();
646 return true; 646 return true;
647 } 647 }
648 648
649 void DriveFileSystemProxy::OnStatusCallback( 649 void DriveFileSystemProxy::OnStatusCallback(
650 const fileapi::FileSystemOperationInterface::StatusCallback& callback, 650 const fileapi::FileSystemOperation::StatusCallback& callback,
651 DriveFileError error) { 651 DriveFileError error) {
652 callback.Run(util::DriveFileErrorToPlatformError(error)); 652 callback.Run(util::DriveFileErrorToPlatformError(error));
653 } 653 }
654 654
655 void DriveFileSystemProxy::OnGetMetadata( 655 void DriveFileSystemProxy::OnGetMetadata(
656 const FilePath& file_path, 656 const FilePath& file_path,
657 const FileSystemOperationInterface::GetMetadataCallback& callback, 657 const FileSystemOperation::GetMetadataCallback& callback,
658 DriveFileError error, 658 DriveFileError error,
659 scoped_ptr<DriveEntryProto> entry_proto) { 659 scoped_ptr<DriveEntryProto> entry_proto) {
660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
661 661
662 if (error != DRIVE_FILE_OK) { 662 if (error != DRIVE_FILE_OK) {
663 callback.Run(util::DriveFileErrorToPlatformError(error), 663 callback.Run(util::DriveFileErrorToPlatformError(error),
664 base::PlatformFileInfo(), 664 base::PlatformFileInfo(),
665 FilePath()); 665 FilePath());
666 return; 666 return;
667 } 667 }
668 DCHECK(entry_proto.get()); 668 DCHECK(entry_proto.get());
669 669
670 base::PlatformFileInfo file_info; 670 base::PlatformFileInfo file_info;
671 DriveEntry::ConvertProtoToPlatformFileInfo( 671 DriveEntry::ConvertProtoToPlatformFileInfo(
672 entry_proto->file_info(), 672 entry_proto->file_info(),
673 &file_info); 673 &file_info);
674 674
675 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path); 675 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path);
676 } 676 }
677 677
678 void DriveFileSystemProxy::OnReadDirectory( 678 void DriveFileSystemProxy::OnReadDirectory(
679 const FileSystemOperationInterface::ReadDirectoryCallback& 679 const FileSystemOperation::ReadDirectoryCallback&
680 callback, 680 callback,
681 DriveFileError error, 681 DriveFileError error,
682 bool hide_hosted_documents, 682 bool hide_hosted_documents,
683 scoped_ptr<DriveEntryProtoVector> proto_entries) { 683 scoped_ptr<DriveEntryProtoVector> proto_entries) {
684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
685 685
686 if (error != DRIVE_FILE_OK) { 686 if (error != DRIVE_FILE_OK) {
687 callback.Run(util::DriveFileErrorToPlatformError(error), 687 callback.Run(util::DriveFileErrorToPlatformError(error),
688 std::vector<base::FileUtilProxy::Entry>(), 688 std::vector<base::FileUtilProxy::Entry>(),
689 false); 689 false);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 void DriveFileSystemProxy::CloseWritableSnapshotFile( 733 void DriveFileSystemProxy::CloseWritableSnapshotFile(
734 const FilePath& virtual_path, 734 const FilePath& virtual_path,
735 const FilePath& local_path) { 735 const FilePath& local_path) {
736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
737 737
738 file_system_->CloseFile(virtual_path, 738 file_system_->CloseFile(virtual_path,
739 base::Bind(&EmitDebugLogForCloseFile, virtual_path)); 739 base::Bind(&EmitDebugLogForCloseFile, virtual_path));
740 } 740 }
741 741
742 } // namespace gdata 742 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698