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 "webkit/blob/local_file_reader.h" | 5 #include "webkit/blob/local_file_reader.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/file_util_proxy.h" | 8 #include "base/file_util_proxy.h" |
| 9 #include "base/location.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
11 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
12 #include "net/base/file_stream.h" | 13 #include "net/base/file_stream.h" |
13 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 | 16 |
16 namespace webkit_blob { | 17 namespace webkit_blob { |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: | 76 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: |
76 return net::ERR_ACCESS_DENIED; | 77 return net::ERR_ACCESS_DENIED; |
77 default: | 78 default: |
78 return net::ERR_FAILED; | 79 return net::ERR_FAILED; |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
82 // A helper class to open, verify and seek a file stream for a given path. | 83 // A helper class to open, verify and seek a file stream for a given path. |
83 class LocalFileReader::OpenFileStreamHelper { | 84 class LocalFileReader::OpenFileStreamHelper { |
84 public: | 85 public: |
85 OpenFileStreamHelper(base::MessageLoopProxy* file_thread_proxy) | 86 explicit OpenFileStreamHelper(base::MessageLoopProxy* file_thread_proxy) |
86 : file_thread_proxy_(file_thread_proxy), | 87 : file_thread_proxy_(file_thread_proxy), |
87 file_handle_(base::kInvalidPlatformFileValue), | 88 file_handle_(base::kInvalidPlatformFileValue), |
88 result_(net::OK) {} | 89 result_(net::OK) {} |
89 ~OpenFileStreamHelper() { | 90 ~OpenFileStreamHelper() { |
90 if (file_handle_ != base::kInvalidPlatformFileValue) { | 91 if (file_handle_ != base::kInvalidPlatformFileValue) { |
91 file_thread_proxy_->PostTask( | 92 file_thread_proxy_->PostTask( |
92 FROM_HERE, | 93 FROM_HERE, |
93 base::Bind(base::IgnoreResult(&base::ClosePlatformFile), | 94 base::Bind(base::IgnoreResult(&base::ClosePlatformFile), |
94 file_handle_)); | 95 file_handle_)); |
95 } | 96 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return; | 209 return; |
209 } | 210 } |
210 DCHECK(stream_impl.get()); | 211 DCHECK(stream_impl.get()); |
211 stream_impl_ = stream_impl.Pass(); | 212 stream_impl_ = stream_impl.Pass(); |
212 const int read_error = stream_impl_->Read(buf, buf_len, callback); | 213 const int read_error = stream_impl_->Read(buf, buf_len, callback); |
213 if (read_error != net::ERR_IO_PENDING) | 214 if (read_error != net::ERR_IO_PENDING) |
214 callback.Run(read_error); | 215 callback.Run(read_error); |
215 } | 216 } |
216 | 217 |
217 } // namespace webkit_blob | 218 } // namespace webkit_blob |
OLD | NEW |