OLD | NEW |
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/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/stringprintf.h" | |
12 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 12 #include "chrome/browser/chromeos/drive/drive.pb.h" |
14 #include "chrome/browser/chromeos/drive/file_cache.h" | 13 #include "chrome/browser/chromeos/drive/file_cache.h" |
15 #include "chrome/browser/chromeos/drive/file_change.h" | 14 #include "chrome/browser/chromeos/drive/file_change.h" |
16 #include "chrome/browser/chromeos/drive/file_errors.h" | 15 #include "chrome/browser/chromeos/drive/file_errors.h" |
17 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" | 16 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
18 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
19 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 18 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
20 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | |
21 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 19 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
22 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
23 #include "google_apis/drive/gdata_errorcode.h" | 21 #include "google_apis/drive/gdata_errorcode.h" |
24 | 22 |
25 using content::BrowserThread; | 23 using content::BrowserThread; |
26 | 24 |
27 namespace drive { | 25 namespace drive { |
28 namespace file_system { | 26 namespace file_system { |
29 namespace { | 27 namespace { |
30 | 28 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return FILE_ERROR_NOT_A_FILE; | 90 return FILE_ERROR_NOT_A_FILE; |
93 | 91 |
94 // For a hosted document, we create a special JSON file to represent the | 92 // For a hosted document, we create a special JSON file to represent the |
95 // document instead of fetching the document content in one of the exported | 93 // document instead of fetching the document content in one of the exported |
96 // formats. The JSON file contains the edit URL and resource ID of the | 94 // formats. The JSON file contains the edit URL and resource ID of the |
97 // document. | 95 // document. |
98 if (entry->file_specific_info().is_hosted_document()) { | 96 if (entry->file_specific_info().is_hosted_document()) { |
99 base::FilePath::StringType extension = base::FilePath::FromUTF8Unsafe( | 97 base::FilePath::StringType extension = base::FilePath::FromUTF8Unsafe( |
100 entry->file_specific_info().document_extension()).value(); | 98 entry->file_specific_info().document_extension()).value(); |
101 base::FilePath gdoc_file_path; | 99 base::FilePath gdoc_file_path; |
102 // TODO(rvargas): Convert this code to use base::File::Info. | |
103 base::File::Info file_info; | 100 base::File::Info file_info; |
104 // We add the gdoc file extension in the temporary file, so that in cross | 101 // We add the gdoc file extension in the temporary file, so that in cross |
105 // profile drag-and-drop between Drive folders, the destination profiles's | 102 // profile drag-and-drop between Drive folders, the destination profiles's |
106 // CopyOperation can detect the special JSON file only by the path. | 103 // CopyOperation can detect the special JSON file only by the path. |
107 if (!GeneratesUniquePathWithExtension(temporary_file_directory, | 104 if (!GeneratesUniquePathWithExtension(temporary_file_directory, |
108 extension, | 105 extension, |
109 &gdoc_file_path) || | 106 &gdoc_file_path) || |
110 !util::CreateGDocFile(gdoc_file_path, | 107 !util::CreateGDocFile(gdoc_file_path, |
111 GURL(entry->file_specific_info().alternate_url()), | 108 GURL(entry->file_specific_info().alternate_url()), |
112 entry->resource_id()) || | 109 entry->resource_id()) || |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 delegate_->OnFileChangedByOperation(changed_files); | 534 delegate_->OnFileChangedByOperation(changed_files); |
538 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); | 535 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); |
539 } | 536 } |
540 | 537 |
541 void DownloadOperation::CancelJob(JobID job_id) { | 538 void DownloadOperation::CancelJob(JobID job_id) { |
542 scheduler_->CancelJob(job_id); | 539 scheduler_->CancelJob(job_id); |
543 } | 540 } |
544 | 541 |
545 } // namespace file_system | 542 } // namespace file_system |
546 } // namespace drive | 543 } // namespace drive |
OLD | NEW |