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

Side by Side Diff: webkit/browser/chromeos/fileapi/remote_file_stream_writer.h

Issue 17644006: Move files under webkit/browser/fileapi/... to chrome/browser/chromeos/fileapi/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments. Created 7 years, 5 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
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 #ifndef WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
7
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h"
13 #include "webkit/browser/fileapi/file_stream_writer.h"
14 #include "webkit/browser/fileapi/file_system_context.h"
15 #include "webkit/browser/fileapi/file_system_url.h"
16
17 namespace net {
18 class IOBuffer;
19 }
20
21 namespace webkit_blob {
22 class ShareableFileReference;
23 }
24
25 namespace fileapi {
26
27 class RemoteFileSystemProxyInterface;
28
29 // FileStreamWriter interface for writing to a file on remote file system.
30 class RemoteFileStreamWriter : public fileapi::FileStreamWriter {
31 public:
32 // Creates a writer for a file on |remote_filesystem| with path url |url|
33 // (like "filesystem:chrome-extension://id/external/drive/...") that
34 // starts writing from |offset|. When invalid parameters are set, the first
35 // call to Write() method fails.
36 // Uses |local_task_runner| for local file operations.
37 RemoteFileStreamWriter(
38 const scoped_refptr<RemoteFileSystemProxyInterface>& remote_filesystem,
39 const FileSystemURL& url,
40 int64 offset,
41 base::TaskRunner* local_task_runner);
42 virtual ~RemoteFileStreamWriter();
43
44 // FileWriter override.
45 virtual int Write(net::IOBuffer* buf, int buf_len,
46 const net::CompletionCallback& callback) OVERRIDE;
47 virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE;
48 virtual int Flush(const net::CompletionCallback& callback) OVERRIDE;
49
50 private:
51 // Callback function to do the continuation of the work of the first Write()
52 // call, which tries to open the local copy of the file before writing.
53 void OnFileOpened(
54 net::IOBuffer* buf,
55 int buf_len,
56 const net::CompletionCallback& callback,
57 base::PlatformFileError open_result,
58 const base::FilePath& local_path,
59 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
60 // Calls |pending_cancel_callback_|, assuming it is non-null.
61 void InvokePendingCancelCallback(int result);
62
63 scoped_refptr<RemoteFileSystemProxyInterface> remote_filesystem_;
64 scoped_refptr<base::TaskRunner> local_task_runner_;
65 const FileSystemURL url_;
66 const int64 initial_offset_;
67 scoped_ptr<fileapi::FileStreamWriter> local_file_writer_;
68 scoped_refptr<webkit_blob::ShareableFileReference> file_ref_;
69 bool has_pending_create_snapshot_;
70 net::CompletionCallback pending_cancel_callback_;
71
72 base::WeakPtrFactory<RemoteFileStreamWriter> weak_factory_;
73
74 DISALLOW_COPY_AND_ASSIGN(RemoteFileStreamWriter);
75 };
76
77 } // namespace fileapi
78
79 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_STREAM_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698