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/drive/file_system/download_operation.cc

Issue 101143006: Convert base::file_util to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base:: Created 6 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 | Annotate | Revision Log
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/drive/file_system/download_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/download_operation.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // The file's entry should have its file specific info. 55 // The file's entry should have its file specific info.
56 DCHECK(entry->has_file_specific_info()); 56 DCHECK(entry->has_file_specific_info());
57 57
58 // For a hosted document, we create a special JSON file to represent the 58 // For a hosted document, we create a special JSON file to represent the
59 // document instead of fetching the document content in one of the exported 59 // document instead of fetching the document content in one of the exported
60 // formats. The JSON file contains the edit URL and resource ID of the 60 // formats. The JSON file contains the edit URL and resource ID of the
61 // document. 61 // document.
62 if (entry->file_specific_info().is_hosted_document()) { 62 if (entry->file_specific_info().is_hosted_document()) {
63 base::FilePath gdoc_file_path; 63 base::FilePath gdoc_file_path;
64 // TODO(rvargas): Convert this code to use base::File::Info.
64 base::PlatformFileInfo file_info; 65 base::PlatformFileInfo file_info;
65 if (!base::CreateTemporaryFileInDir(temporary_file_directory, 66 if (!base::CreateTemporaryFileInDir(temporary_file_directory,
66 &gdoc_file_path) || 67 &gdoc_file_path) ||
67 !util::CreateGDocFile(gdoc_file_path, 68 !util::CreateGDocFile(gdoc_file_path,
68 GURL(entry->file_specific_info().alternate_url()), 69 GURL(entry->file_specific_info().alternate_url()),
69 entry->resource_id()) || 70 entry->resource_id()) ||
70 !base::GetFileInfo(gdoc_file_path, &file_info)) 71 !base::GetFileInfo(gdoc_file_path,
72 reinterpret_cast<base::File::Info*>(&file_info)))
71 return FILE_ERROR_FAILED; 73 return FILE_ERROR_FAILED;
72 74
73 *cache_file_path = gdoc_file_path; 75 *cache_file_path = gdoc_file_path;
74 SetPlatformFileInfoToResourceEntry(file_info, entry); 76 SetPlatformFileInfoToResourceEntry(file_info, entry);
75 return FILE_ERROR_OK; 77 return FILE_ERROR_OK;
76 } 78 }
77 79
78 // Leave |cache_file_path| empty when no cache entry is found. 80 // Leave |cache_file_path| empty when no cache entry is found.
79 FileCacheEntry cache_entry; 81 FileCacheEntry cache_entry;
80 if (!cache->GetCacheEntry(local_id, &cache_entry)) 82 if (!cache->GetCacheEntry(local_id, &cache_entry))
(...skipping 10 matching lines...) Expand all
91 if (error != FILE_ERROR_OK) 93 if (error != FILE_ERROR_OK)
92 return error; 94 return error;
93 95
94 // If the cache file is dirty, the modified file info needs to be stored in 96 // If the cache file is dirty, the modified file info needs to be stored in
95 // |entry|. 97 // |entry|.
96 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in 98 // TODO(kinaba): crbug.com/246469. The logic below is a duplicate of that in
97 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once 99 // drive::FileSystem::CheckLocalModificationAndRun. We should merge them once
98 // the drive::FS side is also converted to run fully on blocking pool. 100 // the drive::FS side is also converted to run fully on blocking pool.
99 if (cache_entry.is_dirty()) { 101 if (cache_entry.is_dirty()) {
100 base::PlatformFileInfo file_info; 102 base::PlatformFileInfo file_info;
101 if (base::GetFileInfo(*cache_file_path, &file_info)) 103 if (base::GetFileInfo(*cache_file_path,
104 reinterpret_cast<base::File::Info*>(&file_info)))
102 SetPlatformFileInfoToResourceEntry(file_info, entry); 105 SetPlatformFileInfoToResourceEntry(file_info, entry);
103 } 106 }
104 107
105 return FILE_ERROR_OK; 108 return FILE_ERROR_OK;
106 } 109 }
107 110
108 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by 111 // Calls CheckPreConditionForEnsureFileDownloaded() with the entry specified by
109 // the given ID. Also fills |drive_file_path| with the path of the entry. 112 // the given ID. Also fills |drive_file_path| with the path of the entry.
110 FileError CheckPreConditionForEnsureFileDownloadedByLocalId( 113 FileError CheckPreConditionForEnsureFileDownloadedByLocalId(
111 internal::ResourceMetadata* metadata, 114 internal::ResourceMetadata* metadata,
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 observer_->OnDirectoryChangedByOperation(file_path.DirName()); 484 observer_->OnDirectoryChangedByOperation(file_path.DirName());
482 params->OnComplete(*cache_file_path); 485 params->OnComplete(*cache_file_path);
483 } 486 }
484 487
485 void DownloadOperation::CancelJob(JobID job_id) { 488 void DownloadOperation::CancelJob(JobID job_id) {
486 scheduler_->CancelJob(job_id); 489 scheduler_->CancelJob(job_id);
487 } 490 }
488 491
489 } // namespace file_system 492 } // namespace file_system
490 } // namespace drive 493 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system.cc ('k') | chrome/browser/chromeos/extensions/echo_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698