| OLD | NEW |
| 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/gdata.h" | 5 #include "chrome/browser/chromeos/gdata/gdata.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" |
| (...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 // the physical file to upload. | 1195 // the physical file to upload. |
| 1196 upload_file_info.title = "Tech Crunch"; | 1196 upload_file_info.title = "Tech Crunch"; |
| 1197 upload_file_info.content_type = "application/pdf"; | 1197 upload_file_info.content_type = "application/pdf"; |
| 1198 FilePath file_path; | 1198 FilePath file_path; |
| 1199 PathService::Get(chrome::DIR_TEST_DATA, &file_path); | 1199 PathService::Get(chrome::DIR_TEST_DATA, &file_path); |
| 1200 file_path = file_path.AppendASCII("pyauto_private/pdf/TechCrunch.pdf"); | 1200 file_path = file_path.AppendASCII("pyauto_private/pdf/TechCrunch.pdf"); |
| 1201 upload_file_info.file_url = GURL(std::string("file:") + file_path.value()); | 1201 upload_file_info.file_url = GURL(std::string("file:") + file_path.value()); |
| 1202 | 1202 |
| 1203 // Create a FileStream to make sure the file can be opened successfully. | 1203 // Create a FileStream to make sure the file can be opened successfully. |
| 1204 scoped_ptr<net::FileStream> file(new net::FileStream(NULL)); | 1204 scoped_ptr<net::FileStream> file(new net::FileStream(NULL)); |
| 1205 int rv = file->Open(file_path, | 1205 int rv = file->OpenSync( |
| 1206 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); | 1206 file_path, |
| 1207 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); |
| 1207 if (rv != net::OK) { | 1208 if (rv != net::OK) { |
| 1208 // If the file can't be opened, we'll just upload an empty file. | 1209 // If the file can't be opened, we'll just upload an empty file. |
| 1209 DLOG(WARNING) << "Error opening \"" << file_path.value() | 1210 DLOG(WARNING) << "Error opening \"" << file_path.value() |
| 1210 << "\" for reading: " << strerror(rv); | 1211 << "\" for reading: " << strerror(rv); |
| 1211 return; | 1212 return; |
| 1212 } | 1213 } |
| 1213 // Cache the file stream to be used for actual reading of file later. | 1214 // Cache the file stream to be used for actual reading of file later. |
| 1214 upload_file_info.file_stream = file.release(); | 1215 upload_file_info.file_stream = file.release(); |
| 1215 | 1216 |
| 1216 // Obtain the file size for content length. | 1217 // Obtain the file size for content length. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 << "-" << end_range_received | 1350 << "-" << end_range_received |
| 1350 << " for [" << in_upload_file_info.title << "] (" | 1351 << " for [" << in_upload_file_info.title << "] (" |
| 1351 << in_upload_file_info.file_url.spec() << ")"; | 1352 << in_upload_file_info.file_url.spec() << ")"; |
| 1352 | 1353 |
| 1353 // Continue uploading if necessary. | 1354 // Continue uploading if necessary. |
| 1354 TestPrepareUploadContent(code, start_range_received, end_range_received, | 1355 TestPrepareUploadContent(code, start_range_received, end_range_received, |
| 1355 &upload_file_info); | 1356 &upload_file_info); |
| 1356 } | 1357 } |
| 1357 | 1358 |
| 1358 } // namespace gdata | 1359 } // namespace gdata |
| OLD | NEW |