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

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: Created 8 years, 4 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
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 POSIX. 5 // This file implements FileStream for POSIX.
6 6
7 #ifndef NET_BASE_FILE_STREAM_POSIX_H_ 7 #ifndef NET_BASE_FILE_STREAM_POSIX_H_
8 #define NET_BASE_FILE_STREAM_POSIX_H_ 8 #define NET_BASE_FILE_STREAM_POSIX_H_
9 9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h" 10 #include "base/platform_file.h"
13 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
14 #include "net/base/file_stream_whence.h" 12 #include "net/base/file_stream_whence.h"
15 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
16 #include "net/base/net_log.h" 14 #include "net/base/net_log.h"
17 15
18 class FilePath; 16 class FilePath;
19 17
20 namespace base { 18 namespace base {
21 class WaitableEvent; 19 class WaitableEvent;
(...skipping 25 matching lines...) Expand all
47 int ReadUntilComplete(char *buf, int buf_len); 45 int ReadUntilComplete(char *buf, int buf_len);
48 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); 46 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
49 int WriteSync(const char* buf, int buf_len); 47 int WriteSync(const char* buf, int buf_len);
50 int64 Truncate(int64 bytes); 48 int64 Truncate(int64 bytes);
51 int Flush(); 49 int Flush();
52 void EnableErrorStatistics(); 50 void EnableErrorStatistics();
53 void SetBoundNetLogSource( 51 void SetBoundNetLogSource(
54 const net::BoundNetLog& owner_bound_net_log); 52 const net::BoundNetLog& owner_bound_net_log);
55 base::PlatformFile GetPlatformFileForTesting(); 53 base::PlatformFile GetPlatformFileForTesting();
56 54
57 // Resets on_io_complete_ and WeakPtr's. 55 private:
58 // Called when Read() or Write() is completed. 56 class AsyncContext;
59 void ResetOnIOComplete();
60 57
61 private: 58 bool is_async() { return !!(open_flags_ & base::PLATFORM_FILE_ASYNC); }
62 // Called when the file_ is closed asynchronously.
63 void OnClosed(const CompletionCallback& callback);
64 59
65 // Waits until the in-flight async open/close/read/write operation is 60 // Context performing I/O operations. Despite its name the context is used
66 // complete. 61 // for synchronous operations too, but it was extracted into separate class
67 void WaitForIOCompletion(); 62 // to perform asynchronous operations correctly.
63 AsyncContext* context_;
68 64
69 base::PlatformFile file_;
70 int open_flags_; 65 int open_flags_;
71 bool auto_closed_;
72 bool record_uma_;
73 net::BoundNetLog bound_net_log_; 66 net::BoundNetLog bound_net_log_;
74 base::WeakPtrFactory<FileStreamPosix> weak_ptr_factory_;
75 scoped_ptr<base::WaitableEvent> on_io_complete_;
76 67
77 DISALLOW_COPY_AND_ASSIGN(FileStreamPosix); 68 DISALLOW_COPY_AND_ASSIGN(FileStreamPosix);
78 }; 69 };
79 70
80 } // namespace net 71 } // namespace net
81 72
82 #endif // NET_BASE_FILE_STREAM_POSIX_H 73 #endif // NET_BASE_FILE_STREAM_POSIX_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698