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

Side by Side Diff: storage/browser/fileapi/file_stream_writer.h

Issue 942633004: IndexedDB: Fixed support for empty blobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted CREATE_NEW_FILE. Creating file before using FileStreamWriter. Created 5 years, 9 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 #ifndef STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_ 5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_
6 #define STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_ 6 #define STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 #include "storage/browser/storage_browser_export.h" 10 #include "storage/browser/storage_browser_export.h"
11 11
12 namespace base { 12 namespace base {
13 class FilePath; 13 class FilePath;
14 class TaskRunner; 14 class TaskRunner;
15 } 15 }
16 16
17 namespace net { 17 namespace net {
18 class IOBuffer; 18 class IOBuffer;
19 } 19 }
20 20
21 namespace storage { 21 namespace storage {
22 22
23 // A generic interface for writing to a file-like object. 23 // A generic interface for writing to a file-like object.
24 class FileStreamWriter { 24 class FileStreamWriter {
25 public: 25 public:
26 enum OpenOrCreate { OPEN_EXISTING_FILE, CREATE_NEW_FILE };
27
28 // Creates a writer for the existing file in the path |file_path| starting 26 // Creates a writer for the existing file in the path |file_path| starting
29 // from |initial_offset|. Uses |task_runner| for async file operations. 27 // from |initial_offset|. Uses |task_runner| for async file operations.
30 STORAGE_EXPORT static FileStreamWriter* CreateForLocalFile( 28 STORAGE_EXPORT static FileStreamWriter* CreateForLocalFile(
31 base::TaskRunner* task_runner, 29 base::TaskRunner* task_runner,
32 const base::FilePath& file_path, 30 const base::FilePath& file_path,
33 int64 initial_offset, 31 int64 initial_offset);
34 OpenOrCreate open_or_create);
35 32
36 // Closes the file. If there's an in-flight operation, it is canceled (i.e., 33 // Closes the file. If there's an in-flight operation, it is canceled (i.e.,
37 // the callback function associated with the operation is not called). 34 // the callback function associated with the operation is not called).
38 virtual ~FileStreamWriter() {} 35 virtual ~FileStreamWriter() {}
39 36
40 // Writes to the current cursor position asynchronously. 37 // Writes to the current cursor position asynchronously.
41 // 38 //
42 // Up to buf_len bytes will be written. (In other words, partial 39 // Up to buf_len bytes will be written. (In other words, partial
43 // writes are allowed.) If the write completed synchronously, it returns 40 // writes are allowed.) If the write completed synchronously, it returns
44 // the number of bytes written. If the operation could not be performed, it 41 // the number of bytes written. If the operation could not be performed, it
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // is returned, and the callback will be run on the thread where Flush() was 79 // is returned, and the callback will be run on the thread where Flush() was
83 // called when the flush has completed. 80 // called when the flush has completed.
84 // 81 //
85 // It is invalid to call Flush while there is an in-flight async operation. 82 // It is invalid to call Flush while there is an in-flight async operation.
86 virtual int Flush(const net::CompletionCallback& callback) = 0; 83 virtual int Flush(const net::CompletionCallback& callback) = 0;
87 }; 84 };
88 85
89 } // namespace storage 86 } // namespace storage
90 87
91 #endif // STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_ 88 #endif // STORAGE_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698