OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/base/upload_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 if (bytes_copied == count) { | 62 if (bytes_copied == count) { |
63 advance_to_next_element = true; | 63 advance_to_next_element = true; |
64 } else { | 64 } else { |
65 next_element_offset_ += bytes_copied; | 65 next_element_offset_ += bytes_copied; |
66 } | 66 } |
67 } else { | 67 } else { |
68 DCHECK(element.type() == UploadData::TYPE_FILE); | 68 DCHECK(element.type() == UploadData::TYPE_FILE); |
69 | 69 |
70 if (!next_element_stream_.IsOpen()) { | 70 if (!next_element_stream_.IsOpen()) { |
71 int rv = next_element_stream_.Open(element.file_path(), false); | 71 int flags = base::PLATFORM_FILE_OPEN | |
| 72 base::PLATFORM_FILE_READ; |
| 73 int rv = next_element_stream_.Open(element.file_path(), flags); |
72 // If the file does not exist, that's technically okay.. we'll just | 74 // If the file does not exist, that's technically okay.. we'll just |
73 // upload an empty file. This is for consistency with Mozilla. | 75 // upload an empty file. This is for consistency with Mozilla. |
74 DLOG_IF(WARNING, rv != OK) << "Failed to open \"" << | 76 DLOG_IF(WARNING, rv != OK) << "Failed to open \"" << |
75 element.file_path() << "\" for reading: " << rv; | 77 element.file_path() << "\" for reading: " << rv; |
76 | 78 |
77 next_element_remaining_ = 0; // Default to reading nothing. | 79 next_element_remaining_ = 0; // Default to reading nothing. |
78 if (rv == OK) { | 80 if (rv == OK) { |
79 uint64 offset = element.file_range_offset(); | 81 uint64 offset = element.file_range_offset(); |
80 if (offset && next_element_stream_.Seek(FROM_BEGIN, offset) < 0) { | 82 if (offset && next_element_stream_.Seek(FROM_BEGIN, offset) < 0) { |
81 DLOG(WARNING) << "Failed to seek \"" << element.file_path() << | 83 DLOG(WARNING) << "Failed to seek \"" << element.file_path() << |
(...skipping 19 matching lines...) Expand all Loading... |
101 if (advance_to_next_element) { | 103 if (advance_to_next_element) { |
102 ++next_element_; | 104 ++next_element_; |
103 next_element_offset_ = 0; | 105 next_element_offset_ = 0; |
104 next_element_stream_.Close(); | 106 next_element_stream_.Close(); |
105 } | 107 } |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 } // namespace net | 111 } // namespace net |
110 | 112 |
OLD | NEW |