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/fileapi/file_system_url_request_job.h" | 5 #include "webkit/fileapi/file_system_url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util_proxy.h" | 10 #include "base/file_util_proxy.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 116 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
117 stream_(NULL), | 117 stream_(NULL), |
118 is_directory_(false), | 118 is_directory_(false), |
119 remaining_bytes_(0) { | 119 remaining_bytes_(0) { |
120 } | 120 } |
121 | 121 |
122 FileSystemURLRequestJob::~FileSystemURLRequestJob() { | 122 FileSystemURLRequestJob::~FileSystemURLRequestJob() { |
123 // Since we use the two-arg constructor of FileStream, we need to call Close() | 123 // Since we use the two-arg constructor of FileStream, we need to call Close() |
124 // manually: ~FileStream won't call it for us. | 124 // manually: ~FileStream won't call it for us. |
125 if (stream_ != NULL) | 125 if (stream_ != NULL) |
126 stream_->Close(); | 126 stream_->CloseSync(); |
127 } | 127 } |
128 | 128 |
129 void FileSystemURLRequestJob::Start() { | 129 void FileSystemURLRequestJob::Start() { |
130 MessageLoop::current()->PostTask( | 130 MessageLoop::current()->PostTask( |
131 FROM_HERE, | 131 FROM_HERE, |
132 base::Bind(&FileSystemURLRequestJob::StartAsync, | 132 base::Bind(&FileSystemURLRequestJob::StartAsync, |
133 weak_factory_.GetWeakPtr())); | 133 weak_factory_.GetWeakPtr())); |
134 } | 134 } |
135 | 135 |
136 void FileSystemURLRequestJob::Kill() { | 136 void FileSystemURLRequestJob::Kill() { |
137 if (stream_ != NULL) { | 137 if (stream_ != NULL) { |
138 stream_->Close(); | 138 stream_->CloseSync(); |
139 stream_.reset(NULL); | 139 stream_.reset(NULL); |
140 } | 140 } |
141 URLRequestJob::Kill(); | 141 URLRequestJob::Kill(); |
142 weak_factory_.InvalidateWeakPtrs(); | 142 weak_factory_.InvalidateWeakPtrs(); |
143 } | 143 } |
144 | 144 |
145 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, | 145 bool FileSystemURLRequestJob::ReadRawData(net::IOBuffer* dest, int dest_size, |
146 int *bytes_read) { | 146 int *bytes_read) { |
147 DCHECK_NE(dest_size, 0); | 147 DCHECK_NE(dest_size, 0); |
148 DCHECK(bytes_read); | 148 DCHECK(bytes_read); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 | 322 |
323 return false; | 323 return false; |
324 } | 324 } |
325 | 325 |
326 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 326 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
327 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 327 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
328 } | 328 } |
329 | 329 |
330 } // namespace fileapi | 330 } // namespace fileapi |
OLD | NEW |