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 // This file implements FileStream for Windows. | 5 // This file implements FileStream for Windows. |
6 | 6 |
7 #ifndef NET_BASE_FILE_STREAM_WIN_H_ | 7 #ifndef NET_BASE_FILE_STREAM_WIN_H_ |
8 #define NET_BASE_FILE_STREAM_WIN_H_ | 8 #define NET_BASE_FILE_STREAM_WIN_H_ |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 int Seek(Whence whence, int64 offset, | 42 int Seek(Whence whence, int64 offset, |
43 const Int64CompletionCallback& callback); | 43 const Int64CompletionCallback& callback); |
44 int64 SeekSync(Whence whence, int64 offset); | 44 int64 SeekSync(Whence whence, int64 offset); |
45 int64 Available(); | 45 int64 Available(); |
46 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 46 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
47 int ReadSync(char* buf, int buf_len); | 47 int ReadSync(char* buf, int buf_len); |
48 int ReadUntilComplete(char *buf, int buf_len); | 48 int ReadUntilComplete(char *buf, int buf_len); |
49 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 49 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
50 int WriteSync(const char* buf, int buf_len); | 50 int WriteSync(const char* buf, int buf_len); |
51 int64 Truncate(int64 bytes); | 51 int64 Truncate(int64 bytes); |
52 int Flush(); | 52 int Flush(const CompletionCallback& callback); |
| 53 int FlushSync(); |
53 void EnableErrorStatistics(); | 54 void EnableErrorStatistics(); |
54 void SetBoundNetLogSource(const net::BoundNetLog& owner_bound_net_log); | 55 void SetBoundNetLogSource(const net::BoundNetLog& owner_bound_net_log); |
55 base::PlatformFile GetPlatformFileForTesting(); | 56 base::PlatformFile GetPlatformFileForTesting(); |
56 | 57 |
57 private: | 58 private: |
58 class AsyncContext; | 59 class AsyncContext; |
59 | 60 |
60 // A helper method for Seek. | 61 // A helper method for Seek. |
61 void SeekFile(Whence whence, int64 offset, int64* result); | 62 void SeekFile(Whence whence, int64 offset, int64* result); |
62 | 63 |
| 64 // A helper method for Flush. |
| 65 void FlushFile(int* result); |
| 66 |
63 // Called when the file_ is opened asynchronously. |result| contains the | 67 // Called when the file_ is opened asynchronously. |result| contains the |
64 // result as a network error code. | 68 // result as a network error code. |
65 void OnOpened(const CompletionCallback& callback, int* result); | 69 void OnOpened(const CompletionCallback& callback, int* result); |
66 | 70 |
67 // Called when the file_ is closed asynchronously. | 71 // Called when the file_ is closed asynchronously. |
68 void OnClosed(const CompletionCallback& callback); | 72 void OnClosed(const CompletionCallback& callback); |
69 | 73 |
70 // Called when the file_ is seeked asynchronously. | 74 // Called when the file_ is seeked asynchronously. |
71 void OnSeeked(const Int64CompletionCallback& callback, int64* result); | 75 void OnSeeked(const Int64CompletionCallback& callback, int64* result); |
72 | 76 |
| 77 // Called when the file_ is flushed asynchronously. |
| 78 void OnFlushed(const CompletionCallback& callback, int* result); |
| 79 |
73 // Resets on_io_complete_ and WeakPtr's. | 80 // Resets on_io_complete_ and WeakPtr's. |
74 // Called in OnOpened, OnClosed and OnSeeked. | 81 // Called in OnOpened, OnClosed and OnSeeked. |
75 void ResetOnIOComplete(); | 82 void ResetOnIOComplete(); |
76 | 83 |
77 // Waits until the in-flight async open/close operation is complete. | 84 // Waits until the in-flight async open/close operation is complete. |
78 void WaitForIOCompletion(); | 85 void WaitForIOCompletion(); |
79 | 86 |
80 // This member is used to support asynchronous reads. It is non-null when | 87 // This member is used to support asynchronous reads. It is non-null when |
81 // the FileStreamWin was opened with PLATFORM_FILE_ASYNC. | 88 // the FileStreamWin was opened with PLATFORM_FILE_ASYNC. |
82 scoped_ptr<AsyncContext> async_context_; | 89 scoped_ptr<AsyncContext> async_context_; |
83 | 90 |
84 base::PlatformFile file_; | 91 base::PlatformFile file_; |
85 int open_flags_; | 92 int open_flags_; |
86 bool auto_closed_; | 93 bool auto_closed_; |
87 bool record_uma_; | 94 bool record_uma_; |
88 net::BoundNetLog bound_net_log_; | 95 net::BoundNetLog bound_net_log_; |
89 base::WeakPtrFactory<FileStreamWin> weak_ptr_factory_; | 96 base::WeakPtrFactory<FileStreamWin> weak_ptr_factory_; |
90 scoped_ptr<base::WaitableEvent> on_io_complete_; | 97 scoped_ptr<base::WaitableEvent> on_io_complete_; |
91 | 98 |
92 DISALLOW_COPY_AND_ASSIGN(FileStreamWin); | 99 DISALLOW_COPY_AND_ASSIGN(FileStreamWin); |
93 }; | 100 }; |
94 | 101 |
95 } // namespace net | 102 } // namespace net |
96 | 103 |
97 #endif // NET_BASE_FILE_STREAM_WIN_H_ | 104 #endif // NET_BASE_FILE_STREAM_WIN_H_ |
OLD | NEW |