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/local_file_stream_writer.h" | 5 #include "webkit/fileapi/local_file_stream_writer.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const int kOpenFlagsForWrite = base::PLATFORM_FILE_OPEN | | 17 const int kOpenFlagsForWrite = base::PLATFORM_FILE_OPEN | |
18 base::PLATFORM_FILE_WRITE | | 18 base::PLATFORM_FILE_WRITE | |
19 base::PLATFORM_FILE_ASYNC; | 19 base::PLATFORM_FILE_ASYNC; |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 LocalFileStreamWriter::LocalFileStreamWriter(const FilePath& file_path, | 23 LocalFileStreamWriter::LocalFileStreamWriter(const base::FilePath& file_path, |
24 int64 initial_offset) | 24 int64 initial_offset) |
25 : file_path_(file_path), | 25 : file_path_(file_path), |
26 initial_offset_(initial_offset), | 26 initial_offset_(initial_offset), |
27 has_pending_operation_(false), | 27 has_pending_operation_(false), |
28 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} | 28 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} |
29 | 29 |
30 LocalFileStreamWriter::~LocalFileStreamWriter() { | 30 LocalFileStreamWriter::~LocalFileStreamWriter() { |
31 // Invalidate weak pointers so that we won't receive any callbacks from | 31 // Invalidate weak pointers so that we won't receive any callbacks from |
32 // in-flight stream operations, which might be triggered during the file close | 32 // in-flight stream operations, which might be triggered during the file close |
33 // in the FileStream destructor. | 33 // in the FileStream destructor. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 return false; | 221 return false; |
222 | 222 |
223 net::CompletionCallback pending_cancel = cancel_callback_; | 223 net::CompletionCallback pending_cancel = cancel_callback_; |
224 has_pending_operation_ = false; | 224 has_pending_operation_ = false; |
225 cancel_callback_.Reset(); | 225 cancel_callback_.Reset(); |
226 pending_cancel.Run(net::OK); | 226 pending_cancel.Run(net::OK); |
227 return true; | 227 return true; |
228 } | 228 } |
229 | 229 |
230 } // namespace fileapi | 230 } // namespace fileapi |
OLD | NEW |