Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: net/base/file_stream_posix.h

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Correct fix for UploadFileElementReader Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file implements FileStream for POSIX.
6
7 #ifndef NET_BASE_FILE_STREAM_POSIX_H_
8 #define NET_BASE_FILE_STREAM_POSIX_H_
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h"
13 #include "net/base/completion_callback.h"
14 #include "net/base/file_stream_whence.h"
15 #include "net/base/net_export.h"
16 #include "net/base/net_log.h"
17
18 class FilePath;
19
20 namespace base {
21 class WaitableEvent;
22 }
23
24 namespace net {
25
26 class IOBuffer;
27
28 class NET_EXPORT FileStreamPosix {
29 public:
30 explicit FileStreamPosix(net::NetLog* net_log);
31 FileStreamPosix(base::PlatformFile file, int flags, net::NetLog* net_log);
32 ~FileStreamPosix();
33
34 // FileStream implementations.
35 void Close(const CompletionCallback& callback);
36 void CloseSync();
37 int Open(const FilePath& path, int open_flags,
38 const CompletionCallback& callback);
39 int OpenSync(const FilePath& path, int open_flags);
40 bool IsOpen() const;
41 int Seek(Whence whence, int64 offset,
42 const Int64CompletionCallback& callback);
43 int64 SeekSync(Whence whence, int64 offset);
44 int64 Available();
45 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
46 int ReadSync(char* buf, int buf_len);
47 int ReadUntilComplete(char *buf, int buf_len);
48 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
49 int WriteSync(const char* buf, int buf_len);
50 int64 Truncate(int64 bytes);
51 int Flush();
52 void EnableErrorStatistics();
53 void SetBoundNetLogSource(
54 const net::BoundNetLog& owner_bound_net_log);
55 base::PlatformFile GetPlatformFileForTesting();
56
57 // Resets on_io_complete_ and WeakPtr's.
58 // Called when Read() or Write() is completed.
59 void ResetOnIOComplete();
60
61 private:
62 // Called when the file_ is closed asynchronously.
63 void OnClosed(const CompletionCallback& callback);
64
65 // Waits until the in-flight async open/close/read/write operation is
66 // complete.
67 void WaitForIOCompletion();
68
69 base::PlatformFile file_;
70 int open_flags_;
71 bool auto_closed_;
72 bool record_uma_;
73 net::BoundNetLog bound_net_log_;
74 base::WeakPtrFactory<FileStreamPosix> weak_ptr_factory_;
75 scoped_ptr<base::WaitableEvent> on_io_complete_;
76
77 DISALLOW_COPY_AND_ASSIGN(FileStreamPosix);
78 };
79
80 } // namespace net
81
82 #endif // NET_BASE_FILE_STREAM_POSIX_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698