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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader.h

Issue 496953003: [fsp] Make the reading operation abortable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_ H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_ H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_ H_ 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READER_ H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 25 matching lines...) Expand all
36 virtual ~FileStreamReader(); 36 virtual ~FileStreamReader();
37 37
38 // storage::FileStreamReader overrides. 38 // storage::FileStreamReader overrides.
39 virtual int Read(net::IOBuffer* buf, 39 virtual int Read(net::IOBuffer* buf,
40 int buf_len, 40 int buf_len,
41 const net::CompletionCallback& callback) OVERRIDE; 41 const net::CompletionCallback& callback) OVERRIDE;
42 virtual int64 GetLength( 42 virtual int64 GetLength(
43 const net::Int64CompletionCallback& callback) OVERRIDE; 43 const net::Int64CompletionCallback& callback) OVERRIDE;
44 44
45 private: 45 private:
46 // Helper class for executing operations on the provided file system. All
47 // of its methods must be called on UI thread. Callbacks are called on IO
48 // thread.
49 class OperationRunner;
50
46 // State of the file stream reader. 51 // State of the file stream reader.
47 enum State { NOT_INITIALIZED, INITIALIZING, INITIALIZED, FAILED }; 52 enum State { NOT_INITIALIZED, INITIALIZING, INITIALIZED, FAILED };
48 53
49 // Called when Read() operation is completed with either a success of an 54 // Called when Read() operation is completed with either a success of an
50 // error. 55 // error.
51 void OnReadCompleted(net::CompletionCallback callback, int result); 56 void OnReadCompleted(net::CompletionCallback callback, int result);
52 57
53 // Initializes the reader by opening the file. When completed with success, 58 // Initializes the reader by opening the file. When completed with success,
54 // runs the |pending_closure|. Otherwise, calls the |error_callback|. 59 // runs the |pending_closure|. Otherwise, calls the |error_callback|.
55 void Initialize(const base::Closure& pending_closure, 60 void Initialize(const base::Closure& pending_closure,
56 const net::Int64CompletionCallback& error_callback); 61 const net::Int64CompletionCallback& error_callback);
57 62
58 // Called when opening a file is completed with either a success or an error. 63 // Called when opening a file is completed with either a success or an error.
59 void OnOpenFileCompleted( 64 void OnOpenFileCompleted(
60 const base::Closure& pending_closure, 65 const base::Closure& pending_closure,
61 const net::Int64CompletionCallback& error_callback, 66 const net::Int64CompletionCallback& error_callback,
62 base::WeakPtr<ProvidedFileSystemInterface> file_system,
63 const base::FilePath& file_path,
64 int file_handle,
65 base::File::Error result); 67 base::File::Error result);
66 68
67 // Called when initialization is completed with either a success or an error. 69 // Called when initialization is completed with either a success or an error.
68 void OnInitializeCompleted(const base::Closure& pending_closure, 70 void OnInitializeCompleted(const base::Closure& pending_closure,
69 const net::Int64CompletionCallback& error_callback, 71 const net::Int64CompletionCallback& error_callback,
70 const EntryMetadata& metadata, 72 const EntryMetadata& metadata,
71 base::File::Error result); 73 base::File::Error result);
72 74
73 // Called when a file system provider returns chunk of read data. Note, that 75 // Called when a file system provider returns chunk of read data. Note, that
74 // this may be called multiple times per single Read() call, as long as 76 // this may be called multiple times per single Read() call, as long as
(...skipping 16 matching lines...) Expand all
91 int buffer_length, 93 int buffer_length,
92 const net::CompletionCallback& callback); 94 const net::CompletionCallback& callback);
93 95
94 // Same as GetLength(), but called after initializing is completed. 96 // Same as GetLength(), but called after initializing is completed.
95 void GetLengthAfterInitialized(const net::Int64CompletionCallback& callback); 97 void GetLengthAfterInitialized(const net::Int64CompletionCallback& callback);
96 98
97 storage::FileSystemURL url_; 99 storage::FileSystemURL url_;
98 int64 current_offset_; 100 int64 current_offset_;
99 int64 current_length_; 101 int64 current_length_;
100 base::Time expected_modification_time_; 102 base::Time expected_modification_time_;
103 scoped_refptr<OperationRunner> runner_;
101 State state_; 104 State state_;
102 105
103 // Set during initialization (in case of a success).
104 base::WeakPtr<ProvidedFileSystemInterface> file_system_;
105 base::FilePath file_path_;
106 int file_handle_;
107
108 base::WeakPtrFactory<FileStreamReader> weak_ptr_factory_; 106 base::WeakPtrFactory<FileStreamReader> weak_ptr_factory_;
109 DISALLOW_COPY_AND_ASSIGN(FileStreamReader); 107 DISALLOW_COPY_AND_ASSIGN(FileStreamReader);
110 }; 108 };
111 109
112 } // namespace file_system_provider 110 } // namespace file_system_provider
113 } // namespace chromeos 111 } // namespace chromeos
114 112
115 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READ ER_H_ 113 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_FILEAPI_FILE_STREAM_READ ER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698