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 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 5 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
6 #define WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 6 #define WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 namespace fileapi { | 23 namespace fileapi { |
24 | 24 |
25 // This class is a thin wrapper around net::FileStream for writing local files. | 25 // This class is a thin wrapper around net::FileStream for writing local files. |
26 class WEBKIT_STORAGE_EXPORT_PRIVATE LocalFileStreamWriter | 26 class WEBKIT_STORAGE_EXPORT_PRIVATE LocalFileStreamWriter |
27 : public FileStreamWriter { | 27 : public FileStreamWriter { |
28 public: | 28 public: |
29 // Create a writer for the existing file in the path |file_path| starting from | 29 // Create a writer for the existing file in the path |file_path| starting from |
30 // |initial_offset|. | 30 // |initial_offset|. |
31 LocalFileStreamWriter(const FilePath& file_path, int64 initial_offset); | 31 LocalFileStreamWriter(const base::FilePath& file_path, int64 initial_offset); |
32 virtual ~LocalFileStreamWriter(); | 32 virtual ~LocalFileStreamWriter(); |
33 | 33 |
34 // FileStreamWriter overrides. | 34 // FileStreamWriter overrides. |
35 virtual int Write(net::IOBuffer* buf, int buf_len, | 35 virtual int Write(net::IOBuffer* buf, int buf_len, |
36 const net::CompletionCallback& callback) OVERRIDE; | 36 const net::CompletionCallback& callback) OVERRIDE; |
37 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; | 37 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; |
38 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE; | 38 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE; |
39 | 39 |
40 private: | 40 private: |
41 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). | 41 // Opens |file_path_| and if it succeeds, proceeds to InitiateSeek(). |
(...skipping 23 matching lines...) Expand all Loading... |
65 | 65 |
66 // Flushes asynchronously to the file. | 66 // Flushes asynchronously to the file. |
67 int InitiateFlush(const net::CompletionCallback& callback); | 67 int InitiateFlush(const net::CompletionCallback& callback); |
68 void DidFlush(const net::CompletionCallback& callback, int result); | 68 void DidFlush(const net::CompletionCallback& callback, int result); |
69 | 69 |
70 // Stops the in-flight operation and calls |cancel_callback_| if it has been | 70 // Stops the in-flight operation and calls |cancel_callback_| if it has been |
71 // set by Cancel() for the current operation. | 71 // set by Cancel() for the current operation. |
72 bool CancelIfRequested(); | 72 bool CancelIfRequested(); |
73 | 73 |
74 // Initialization parameters. | 74 // Initialization parameters. |
75 const FilePath file_path_; | 75 const base::FilePath file_path_; |
76 const int64 initial_offset_; | 76 const int64 initial_offset_; |
77 | 77 |
78 // Current states of the operation. | 78 // Current states of the operation. |
79 bool has_pending_operation_; | 79 bool has_pending_operation_; |
80 scoped_ptr<net::FileStream> stream_impl_; | 80 scoped_ptr<net::FileStream> stream_impl_; |
81 net::CompletionCallback cancel_callback_; | 81 net::CompletionCallback cancel_callback_; |
82 | 82 |
83 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; | 83 base::WeakPtrFactory<LocalFileStreamWriter> weak_factory_; |
84 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); | 84 DISALLOW_COPY_AND_ASSIGN(LocalFileStreamWriter); |
85 }; | 85 }; |
86 | 86 |
87 } // namespace fileapi | 87 } // namespace fileapi |
88 | 88 |
89 #endif // WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ | 89 #endif // WEBKIT_FILEAPI_LOCAL_FILE_STREAM_WRITER_H_ |
OLD | NEW |